examples/book/digital-artists/chapter1/Listing1.17.ck
raw| 1 | // Listing 1.17 Musical use of a for loop |
| 2 | |
| 3 | // set up our patch |
| 4 | SinOsc s => dac; // Sine wave to dac |
| 5 | |
| 6 | // a musical for loop |
| 7 | for (20 => int i; i < 400; i++) // (1) For loop from 20 to 399 |
| 8 | { |
| 9 | <<< i >>>; // (2) Prints out current value |
| 10 | i => s.freq; // (3) Sets frequency to i |
| 11 | 10::ms => now; // advance time // (4) Waits 10ms, then loops again |
| 12 | } |
| 13 |