Debian Codegraph @

examples/book/digital-artists/chapter7/Listing7.14.ck

raw
1 // Listing 7.14 ChucK's shout-out to the Minimoog, the Moog UGen
2
3 // Homage to a classic analog synth sound
4 Moog mog => dac;
5
6 // table of pitches to use
7 [77,72,69,75,70,67,74,70,65,72] @=> int cars[];
8
9 // play first note;
10 play(cars[0],0.25);
11
12 // then play most of the rest
13 for (1 => int i; i < cars.cap()-1; i++)
14 {
15 if (i % 3 == 0) play(cars[i],0.5);
16 else play(cars[i],0.25);
17 }
18
19 // push up "mod wheel" for last note
20 0.25 => mog.vibratoGain;
21 play(cars[cars.cap()-1], 1.0);
22
23 // function to play notes on/off
24 fun void play(int note, float howLong)
25 {
26 Std.mtof(note) => mog.freq;
27 1 => mog.noteOn;
28 (howLong - 0.05) :: second => now;
29 1 => mog.noteOff;
30 0.05 :: second => now;
31 }
32