Debian Codegraph @

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

raw
1 // Listing 7.7 Playing a scale on the STK Bowed string model
2
3 // Bowed string demo
4 Bowed viol => dac; // (1) Bowed string physical model
5
6 // define a D Major Scale (in MIDI note numbers)
7 [62, 64, 66, 67, 69, 71, 73, 74] @=> int scale[];
8
9 // run through our scale one note at a time
10 for (0 => int i; i < scale.cap(); i++)
11 {
12 // set frequency according to note number
13 Std.mtof(scale[i]) => viol.freq; // (2) Sets pitch with .freq, just like other UGens
14
15
16 // note on for a while, then note off
17 1 => viol.noteOn; // (3) noteOn starts it bowing automatically
18 0.3 :: second => now;
19
20 1 => viol.noteOff;
21 0.1 :: second => now;
22 }
23
24 // repeat last note with lots of vibrato
25 1 => viol.noteOn;
26 0.1 => viol.vibratoGain; // (4) A little extra vibrato on the last note
27 2.0 :: second => now;
28
29 0 => viol.noteOff;
30 0.2 :: second => now;