| 1 |
// Listing 7.16 Building a simple formant (resonant filter) voice model |
| 2 |
|
| 3 |
// Simple singing voice model |
| 4 |
// by Enrico C., August 1921 |
| 5 |
SawOsc folds => ResonZ formant1 => dac; // (1) Sawtooth models vocal folds through formant filter |
| 6 |
folds => ResonZ formant2 => dac; // (2) 2nd formant (vocal tract resonance) |
| 7 |
folds => ResonZ formant3 => dac; // (3) 3rd formant |
| 8 |
|
| 9 |
// hook up a modulation (vibrato) oscillator |
| 10 |
SinOsc vibrato => folds; // (4) Adds vibrato to voice source |
| 11 |
6.0 => vibrato.freq; |
| 12 |
1.5 => vibrato.gain; |
| 13 |
2 => folds.sync; |
| 14 |
|
| 15 |
// Set up filter resonance amounts |
| 16 |
20 => formant1.Q => formant2.Q => formant3.Q; // (5) Sets resonance of all three formant filters |
| 17 |
|
| 18 |
// Sing forever, randomly |
| 19 |
while (1) { // (6) Sings a random "song" forever |
| 20 |
// (7) Random "vowel" (formant frequencies) |
| 21 |
Math.random2f(200,750) => formant1.freq; |
| 22 |
Math.random2f(900,2300) => formant2.freq; |
| 23 |
Math.random2f(2400,3600) => formant3.freq; |
| 24 |
if (Math.random2(0,3) == 0) |
| 25 |
{ // (8) Random voice pitch |
| 26 |
Math.random2f(60.0,200.0) => folds.freq; |
| 27 |
} |
| 28 |
Math.random2f(0.2,0.5) :: second => now; |
| 29 |
} |