examples/book/digital-artists/chapter1/Listing1.18.ck
raw| 1 | // Listing 1.18 Musical while loop |
| 2 | |
| 3 | SinOsc s => dac; |
| 4 | |
| 5 | // initialize variable i |
| 6 | 20 => int i; // (1) Initializes the counter/frequency to 20. |
| 7 | |
| 8 | // while loop (instead of for loop) |
| 9 | while ( i < 400) // (2) A while loop only has a conditional test |
| 10 | { // (3) Block of code to execute, including... |
| 11 | <<< i >>>; |
| 12 | i => s.freq; |
| 13 | 10::ms => now; |
| 14 | i++; // (4) ...increment counter (very important!!) |
| 15 | } |