-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment1_SanDiegoPowerPlant.ck
85 lines (78 loc) · 1.93 KB
/
Assignment1_SanDiegoPowerPlant.ck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* Title: The Basics
Author: Brian Harrington
Assignment: 1 - Basics, Sound waves, and ChucK programming
Soundcloud link: https://soundcloud.com/destruction_synthesis/assignment1-sandiegopowerplant
*/
<<< "Assignment_1_SanDiegoPowerPlant" >>>;
// using two types of oscillators
TriOsc s => dac;
TriOsc saw => dac;
// keys
164.813778456434964 => float E3;
174.614115716501942 => float F3;
195.997717990874647 => float G3;
220.000 => float A3;
246.941650628062055 => float B3;
261.625565300598634 => float C;
293.664767917407560 => float D;
329.627556912869929 => float E;
349.228231433003884 => float F;
391.995435981749294 => float G;
440.000 => float A;
493.883301256124111 => float B;
// start in middle C
C => saw.freq;
0 => s.gain;
0.4 => saw.gain;
// flag to start the harmony
0 => int harmony;
// some melody / beat
now + 32::second => time consistent; // simple 60 bpm
while (now < consistent){
if(harmony != 0){ // start when flag is set
0.5 => s.gain;
C => s.freq;
} // starting in C
now + 4::second => time start;
while(now < start) {
0.5::second => now;
0 => saw.gain;
0.5::second => now;
0.4 => saw.gain;
}
// key change
E => saw.freq;
A3 => s.freq;
now + 4::second => start;
while(now < start){
0.5::second => now;
0 => saw.gain;
0.5::second => now;
0.4 => saw.gain;
}
// key change
A => saw.freq;
F3 => s.freq;
now + 4::second => start;
while(now < start){
0.5::second => now;
0 => saw.gain;
0.5::second => now;
0.4 => saw.gain;
}
// key change
G => saw.freq;
G3 => s.freq;
now + 4::second => start;
while(now < start){
0.5::second => now;
0 => saw.gain;
0.5::second => now;
0.4 => saw.gain;
}
1 => harmony; // begin harmony second time around
}
// resolve
C => s.freq;
E => saw.freq;
1.5::second => now;