1
/******************************************/
2
/* Algorithm 4 (TX81Z) Subclass of */
3
/* 4 Operator FM Synth */
4
/* by Perry R. Cook, 1995-96 */
6
/* Alg 4 is : 4->3--\ */
9
/* Controls: control1 = total mod index */
10
/* control2 = crossfade of two */
12
/* control3 = LFO speed */
13
/* modWheel = LFO amount */
15
/******************************************/
19
FM4Alg4 :: FM4Alg4() : FM4Op()
21
/* We still don't make the waves here yet, because */
22
/* we still don't know what they will be. */
29
MY_FLOAT FM4Alg4 :: tick()
33
temp = vibWave->tick() * modDepth * (MY_FLOAT) 0.2;
34
waves[0]->setFreq(baseFreq * ((MY_FLOAT) 1.0 + temp) * ratios[0]);
35
waves[1]->setFreq(baseFreq * ((MY_FLOAT) 1.0 + temp) * ratios[1]);
36
waves[2]->setFreq(baseFreq * ((MY_FLOAT) 1.0 + temp) * ratios[2]);
37
waves[3]->setFreq(baseFreq * ((MY_FLOAT) 1.0 + temp) * ratios[3]);
39
waves[3]->addPhaseOffset(twozero->lastOut());
40
temp = gains[3] * adsr[3]->tick() * waves[3]->tick();
42
waves[2]->addPhaseOffset(temp);
43
temp = ((MY_FLOAT) 1.0 - (control2 * (MY_FLOAT) 0.5)) *
44
gains[2] * adsr[2]->tick() * waves[2]->tick();
45
temp += control2 * (MY_FLOAT) 0.5 * gains[1] * adsr[1]->tick() * waves[1]->tick();
46
temp = temp * control1;
47
waves[0]->addPhaseOffset(temp);
48
temp = gains[0] * adsr[0]->tick() * waves[0]->tick();
50
lastOutput = temp * (MY_FLOAT) 0.5;