Debian Codegraph @

examples/book/digital-artists/chapter9/UseBPM3.ck

raw
1 // Listing 9.10 UseBPM3.ck randomly sets BPM tempo and sweeps another sine
2
3 // This lives in another file, UseBPM3.ck
4 SinOsc s => dac;
5
6 BPM t2; // Define another BPM called t2
7 0.3 => s.gain;
8
9 // and set tempo to a random number
10 Math.random2f(200.0,1000.0) => t2.tempo; // (1) Sets random tempo
11 1000 => int freq;
12
13 while (freq > 400) // (2) Sweeps sine frequency downward
14 {
15 freq => s.freq;
16 t2.quarterNote => now;
17 50 -=> freq;
18 }