Debian Codegraph @

examples/book/digital-artists/chapter6/Listing6.6.ck

raw
1 // Listing 6.6 Simple FM test program
2
3 // FM Unit Generator Instrument Test Program
4 // by FM Dude, March 4, 1976
5 // make an FM instrument and connect to dac
6 Wurley instr => dac; // (1) FM electric piano
7
8 // play it forever with random frequency and duration
9 while (true) {
10 Math.random2f(100.0,300.0) => instr.freq;
11
12 // turn note on (trigger internal ADSR)
13 1 => instr.noteOn; // (2) Turns on note, waits a (random) bit
14 Math.random2f(0.2,0.5) :: second => now;
15
16 // turn note off (ramp down internal ADSR)
17 1 => instr.noteOff; // (3) Turns off note, waits a (random) bit
18 Math.random2f(0.05,0.1) :: second => now;
19 }