Subversion Repositories DIN Is Noise

Rev

Rev 2097 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1370 jag 1
/*
2
* modulator.cc
2302 jag 3
* DIN Is Noise is copyright (c) 2006-2025 Jagannathan Sampath
1713 jag 4
* DIN Is Noise is released under GNU Public License 2.0
1479 jag 5
* For more information, please visit https://dinisnoise.org/
1370 jag 6
*/
7
 
868 jag 8
#include "multi_curve.h"
9
#include "modulator.h"
10
#include "audio.h"
1659 jag 11
#include "chrono.h"
1693 jag 12
#include "drone.h"
1805 jag 13
#include "ui_list.h"
868 jag 14
 
1822 jag 15
extern const float TWO_PI;
1695 jag 16
extern const char spc;
1688 jag 17
 
1844 jag 18
 
19
void mod_params::comconst (multi_curve* c, const std::string& n) {
868 jag 20
  bv.name = n;
21
  bv.crv = c;
1728 jag 22
  bv.setup ();
868 jag 23
  depth = result = initial = 0;
1823 jag 24
  id = 0;
25
  dirx = diry = 0;
26
}
1680 jag 27
 
1844 jag 28
mod_params::mod_params (multi_curve* c, const std::string& n) {
29
  comconst (c, n);
30
}
31
 
32
mod_params::mod_params (multi_curve* c, int i, point<float>& p, const std::string& n) {
33
  comconst (c, n);
1823 jag 34
  setdir (i, &p.x, &p.y);
868 jag 35
}
36
 
1718 jag 37
void mod_params::clear () {
868 jag 38
  depth = 0;
39
  result = 0;
40
  initial = 0;
1728 jag 41
  bv.set_bpm (bv.bpm);
868 jag 42
}
43
 
1806 jag 44
void mod_params::calc (double dt) {
2096 jag 45
  int dir = 1; if (bv.delta < 0) dir = -1;
2055 jag 46
  bv.delta = dir * dt * bv.bps;
2056 jag 47
  result = depth * bv.sol (bv.now, bv.delta, *bv.xmin, *bv.xmax);
1729 jag 48
}
49
 
1744 jag 50
void mod_params::calcdir (drone& dd) {
51
  float* px [] = {&vertical.x, &horizontal.x, &dd.vx, &dd.ax};
52
  float* py [] = {&vertical.y, &horizontal.y, &dd.vy, &dd.ay};
53
  dirx = px[id];
54
  diry = py[id];
55
}