This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modulation.pde
84 lines (74 loc) · 1.64 KB
/
modulation.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class modulation{
float pitchAmt;
float filterAmt;
float ampAmt;
boolean osc2only;
int modSource;
sinOscillator sin;
squareOscillator sqr;
triOscillator tri;
sawOscillator saw;
modulation(){
sin = new sinOscillator(0.,0.);
tri = new triOscillator(0.,0.);
sqr = new squareOscillator(0.,0.);
saw = new sawOscillator(0.,0.);
}
void setFreq( float _freq){
_freq = _freq/2;
sin.setFreq(_freq);
tri.setFreq(_freq);
sqr.setFreq(_freq);
saw.setFreq(_freq);
}
void setModSource(int _modsource){
this.modSource = _modsource;
}
void setosc2only(boolean _osc2only){
this.osc2only = _osc2only;
}
void setPitchAmt(float _pitchAmt){
this.pitchAmt = _pitchAmt;
}
void setFilterAmt(float _filterAmt){
this.filterAmt = _filterAmt;
}
void setAmpAmt(float _ampAmt){
this.ampAmt = _ampAmt;
}
float getValue(){
float sinVal = sin.getValue();
float triVal = tri.getValue();
float sawVal = saw.getValue();
float sqrVal = sqr.getValue();
switch(this.modSource){
case 0:
return sinVal;
case 1:
return triVal;
case 2:
return sawVal;
case 3:
return sqrVal;
default:
return 0.;
}
}
float getPitchOsc1Value(){
if(!this.osc2only){
return this.getPitchValue();
}
else{
return 0.;
}
}
float getPitchValue(){
return (this.getValue() * this.pitchAmt)/100;
}
float getFilterValue(){
return (getValue()*this.filterAmt) + 1.;
}
float getAmpValue(){
return (getValue()*this.ampAmt) + 1.;
}
}