examples/basic/fm.ck
raw| 1 | // FM synthesis by hand |
| 2 | |
| 3 | // carrier |
| 4 | SinOsc c => dac; |
| 5 | // modulator |
| 6 | SinOsc m => blackhole; |
| 7 | |
| 8 | // carrier frequency |
| 9 | 220 => float cf; |
| 10 | // modulator frequency |
| 11 | 550 => float mf => m.freq; |
| 12 | // index of modulation |
| 13 | 200 => float index; |
| 14 | |
| 15 | // time-loop |
| 16 | while( true ) |
| 17 | { |
| 18 | // modulate |
| 19 | cf + (index * m.last()) => c.freq; |
| 20 | // advance time by 1 samp |
| 21 | 1::samp => now; |
| 22 | } |