1
/******************************************/
2
/* Singing Voice Synthesis Subclass */
3
/* of Algorithm 6 (TX81Z) Subclass of */
4
/* 4 Operator FM Synth */
5
/* by Perry R. Cook, 1996 */
6
/******************************************/
11
FMVoices :: FMVoices() : FM4Alg6()
13
// Concatenate the STK RAWWAVE_PATH to the rawwave file
18
strcpy(file1, RAWWAVE_PATH);
19
strcpy(file2, RAWWAVE_PATH);
20
strcpy(file3, RAWWAVE_PATH);
21
strcpy(file4, RAWWAVE_PATH);
22
this->loadWaves(strcat(file1,"rawwaves/sinewave.raw"),
23
strcat(file2,"rawwaves/sinewave.raw"),
24
strcat(file3,"rawwaves/sinewave.raw"),
25
strcat(file4,"rawwaves/fwavblnk.raw"));
27
this->setRatio(0,(MY_FLOAT) 2.00);
28
this->setRatio(1,(MY_FLOAT) 4.00);
29
this->setRatio(2,(MY_FLOAT) 12.0);
30
this->setRatio(3,(MY_FLOAT) 1.00);
31
gains[3] = __FM4Op_gains[80];
32
adsr[0]->setAllTimes((MY_FLOAT) 0.050,(MY_FLOAT) 0.050,
33
__FM4Op_susLevels[15],(MY_FLOAT) 0.050);
34
adsr[1]->setAllTimes((MY_FLOAT) 0.050,(MY_FLOAT) 0.050,
35
__FM4Op_susLevels[15],(MY_FLOAT) 0.050);
36
adsr[2]->setAllTimes((MY_FLOAT) 0.050,(MY_FLOAT) 0.050,
37
__FM4Op_susLevels[15],(MY_FLOAT) 0.050);
38
adsr[3]->setAllTimes((MY_FLOAT) 0.010,(MY_FLOAT) 0.010,
39
__FM4Op_susLevels[15],(MY_FLOAT) 0.500);
40
twozero->setGain((MY_FLOAT) 0.0);
41
modDepth = (MY_FLOAT) 0.005;
43
tilt[0] = (MY_FLOAT) 1.0;
44
tilt[1] = (MY_FLOAT) 0.5;
45
tilt[2] = (MY_FLOAT) 0.2;
46
mods[0] = (MY_FLOAT) 1.0;
47
mods[1] = (MY_FLOAT) 1.1;
48
mods[2] = (MY_FLOAT) 1.1;
49
baseFreq = (MY_FLOAT) 110.0;
50
this->setFreq((MY_FLOAT) 110.0);
53
/* #include "phonTabl.h" */
55
extern double phonGains[32][2];
56
extern double phonParams[32][4][3];
57
extern char phonemes[32][4];
59
void FMVoices :: setFreq(MY_FLOAT frequency)
61
MY_FLOAT temp, temp2 = 0.0;
62
int tempi, tempi2 = 0;
64
if (currentVowel < 32) {
65
tempi2 = currentVowel;
66
temp2 = (MY_FLOAT) 0.9;
68
else if (currentVowel < 64) {
69
tempi2 = currentVowel - 32;
70
temp2 = (MY_FLOAT) 1.0;
72
else if (currentVowel < 96) {
73
tempi2 = currentVowel - 64;
74
temp2 = (MY_FLOAT) 1.1;
76
else if (currentVowel <= 128) {
77
tempi2 = currentVowel - 96;
78
temp2 = (MY_FLOAT) 1.2;
81
temp = (temp2 * (MY_FLOAT) phonParams[tempi2][0][0] / baseFreq) + (MY_FLOAT) 0.5;
83
this->setRatio(0,(MY_FLOAT) tempi);
84
temp = (temp2 * (MY_FLOAT) phonParams[tempi2][1][0] / baseFreq) + (MY_FLOAT) 0.5;
86
this->setRatio(1,(MY_FLOAT) tempi);
87
temp = (temp2 * (MY_FLOAT) phonParams[tempi2][2][0] / baseFreq) + (MY_FLOAT) 0.5;
89
this->setRatio(2,(MY_FLOAT) tempi);
90
gains[0] = (MY_FLOAT) 1.0; // pow(10.0,phonParams[tempi2][0][2] * 0.05);
91
gains[1] = (MY_FLOAT) 1.0; // pow(10.0,phonParams[tempi2][1][2] * 0.05);
92
gains[2] = (MY_FLOAT) 1.0; // pow(10.0,phonParams[tempi2][2][2] * 0.05);
95
void FMVoices :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
100
tilt[2] = amp * amp * amp;
103
printf("FMVoices : NoteOn: Freq=%lf Amp=%lf\n",freq,amp);
107
void FMVoices :: controlChange(int number, MY_FLOAT value)
113
printf("FM4Op : ControlChange: Number=%i Value=%f\n",number,value);
115
if (number == __SK_Breath_)
116
gains[3] = __FM4Op_gains[(int) (value * 0.78125)];
117
else if (number == __SK_FootControl_) {
119
currentVowel = tempi;
120
this->setFreq(baseFreq);
122
else if (number == __SK_ModFrequency_)
123
this->setModulationSpeed(value * NORM_7 * (MY_FLOAT) 12.0); /* 0 to 12 Hz */
124
else if (number == __SK_ModWheel_)
125
this->setModulationDepth(value * NORM_7);
126
else if (number == __SK_AfterTouch_Cont_) {
127
temp = value * NORM_7;
129
tilt[1] = temp * temp;
130
tilt[2] = temp * temp * temp;
133
printf("FM4Op : Undefined Control Number!!\n");