Debian Codegraph @

examples/book/digital-artists/chapter1/Listing1.11.ck

raw
1 // Listing 1.11 Twinkle with dur variables
2
3 /* Sine Music using dur variables
4 by ChucK Programmer
5 January 2025 */
6
7 SinOsc s => dac;
8
9 220.0 => float twinkle;
10 0.55 :: second => dur onDur; // (1) Defines note durations as variables
11 0.05 :: second => dur offDur;
12
13 1 => int onGain;
14 0 => int offGain;
15
16 // Play one note
17 twinkle => s.freq;
18 onGain => s.gain;
19 onDur => now; // (2) Waits while note sounds...
20
21 offGain => s.gain;
22 offDur => now; // (3) ...then waits for space between notes
23
24 1.5 *=> twinkle; // (4) Next note frequency
25
26 // Play other note of 2nd "twinkle"
27 twinkle => s.freq; // (5) Sets it and plays another note
28 onGain => s.gain;
29 onDur => now;
30 offGain => s.gain;
31 offDur => now;