Subversion Repositories DIN Is Noise

Rev

Rev 1823 | Rev 2009 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1528 jag 1
/*
2
* modulator.h
1858 jag 3
* DIN Is Noise is copyright (c) 2006-2022 Jagannathan Sampath
1713 jag 4
* DIN Is Noise is released under GNU Public License 2.0
1528 jag 5
* For more information, please visit https://dinisnoise.org/
6
*/
7
#ifndef __modulator__
8
#define __modulator__
9
 
1806 jag 10
#include "chrono.h"
1823 jag 11
#include "mod_params.h"
1693 jag 12
 
13
#include <fstream>
1528 jag 14
#include <string>
15
 
16
struct multi_curve;
17
 
18
struct modulator {
1688 jag 19
 
20
  enum {AM, FM};
1797 jag 21
 
1688 jag 22
  mod_params am, fm;
1528 jag 23
 
24
  enum {FROZEN=-1, NOT_ACTIVE, ACTIVE};
25
  int active;
26
 
1728 jag 27
  int scrubbed; // used by point_modulator
1528 jag 28
 
1806 jag 29
  double t, dt;
30
 
1728 jag 31
  modulator (multi_curve* fmc, multi_curve* amc) :
32
    am (amc, mod_params::VERTICAL, mod_params::vertical),
33
    fm (fmc, mod_params::HORIZONTAL, mod_params::horizontal)
34
  {
1666 jag 35
    active = scrubbed = 0;
1806 jag 36
    t = ui_clk ();
1808 jag 37
    dt = 0.0;
1666 jag 38
  }
1528 jag 39
 
40
  void clear () {
1688 jag 41
    am.clear ();
1528 jag 42
    fm.clear ();
43
    active = 0;
44
  }
45
 
46
  void calc () {
1806 jag 47
 
48
    double now = ui_clk ();
49
    dt = now - t;
50
    t = now;
51
 
52
    am.calc (dt);
53
    fm.calc (dt);
54
 
1528 jag 55
  }
56
 
57
};
58
 
59
#endif