1
/******************************************/
2
/* Algorithm 3 (TX81Z) Subclass of */
3
/* 4 Operator FM Synth */
4
/* by Perry R. Cook, 1995-96 */
7
/* 3-->2-- + -->1-->Out */
9
/* Controls: control1 = total mod index */
10
/* control2 = crossfade of two */
12
/* control3 = LFO speed */
13
/* modWheel = LFO amount */
15
/******************************************/
19
FM4Alg3 :: FM4Alg3() : 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 FM4Alg3 :: 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
temp = gains[2] * adsr[2]->tick() * waves[2]->tick();
40
waves[1]->addPhaseOffset(temp);
42
waves[3]->addPhaseOffset(twozero->lastOut());
43
temp = ((MY_FLOAT) 1.0 - (control2 * (MY_FLOAT) 0.5)) *
44
gains[3] * adsr[3]->tick() * waves[3]->tick();
47
temp += control2 * (MY_FLOAT) 0.5 * gains[1] * adsr[1]->tick() * waves[1]->tick();
48
temp = temp * control1;
50
waves[0]->addPhaseOffset(temp);
51
temp = gains[0] * adsr[0]->tick() * waves[0]->tick();
53
lastOutput = temp * (MY_FLOAT) 0.5;