-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment_3_Fck_Techno.ck
258 lines (221 loc) · 6.43 KB
/
Assignment_3_Fck_Techno.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
//Assignment_3_Fck_Techno
<<< "Assignment_3_Fck_Techno" >>>;
//Sound Network
SawOsc rythm => Pan2 rythmPan => Gain melody => dac;
SawOsc lead => Pan2 leadPan => melody => dac;
SndBuf kick => Pan2 kickPan => Gain drums => dac;
SndBuf snare => Pan2 snarePan => drums => dac;
SndBuf chihat => Pan2 hihatPan => drums => dac;
SndBuf ohihat => hihatPan => drums => dac;
SndBuf rand1 => Pan2 rand1Pan => Gain randGain => dac;
SndBuf rand2 => Pan2 rand2Pan => randGain => dac;
//sound file loading (Drumkit)
me.dir() + "/audio/kick_01.wav" => kick.read;
me.dir() + "/audio/snare_01.wav" => snare.read;
me.dir() + "/audio/hihat_01.wav" => chihat.read;
me.dir() + "/audio/hihat_04.wav" => ohihat.read;
//String array containing soundfiles
[me.dir() + "/audio/clap_01.wav",
me.dir() + "/audio/click_01.wav",
me.dir() + "/audio/cowbell_01.wav",
me.dir() + "/audio/stereo_fx_01.wav",
me.dir() + "/audio/click_02.wav",
me.dir() + "/audio/click_03.wav",
me.dir() + "/audio/stereo_fx_03.wav"] @=> string files[];
//Scale definition
[50, 52, 53, 55, 57, 59, 60] @=> int D_d[];
//Dur definitions
0.25::second => dur quarter;
quarter/2 => dur eighth;
quarter/4 => dur sixteenth;
quarter*2 => dur half;
quarter*4 => dur whole;
//Set Drum Rates
1.0 => snare.rate;
1.0 => kick.rate;
1.0 => chihat.rate;
1.0 => ohihat.rate;
//Set Gains
0.3 => kick.gain;
0.7 => snare.gain;
0.2 => chihat.gain;
0.2 => ohihat.gain;
0.5 => lead.gain;
0.5 => rythm.gain;
1 => rand1.gain;
1 => rand2.gain;
0 => melody.gain;
0 => drums.gain;
0 => randGain.gain;
//Set Drumkit headers to end
kick.samples() => kick.pos;
snare.samples() => snare.pos;
chihat.samples() => chihat.pos;
ohihat.samples() => ohihat.pos;
//Panning
-1.0 => rythmPan.pan;
1.0 => leadPan.pan;
-0.2 => hihatPan.pan;
0.2 => snarePan.pan;
//Figures construction, used later in different ways
//to create different phrases, the first array
//represents the note, the second one represents
//the cotave it should be played in according to the
//main scale defined above
[ 0, 0, 2, 0, 0, 1, 0, 0] @=> int c1[];
[-1, -1, 0, -1, 0, 0, -1, -1] @=> int oc1[];
[2, 0, 0, 1, 0, 0, 6, 0] @=> int c2[];
[0, -1, 0, 0, -1, -1, -1, 0] @=> int oc2[];
[5, 0, 4, 0, 3, 0, 6, 0] @=> int c3[];
[0, -1, 0, -1, 0, -1, -1, 0] @=> int oc3[];
[2, 0, 0, 1, 0, 0, 6, 0, 6] @=> int c4[];
[0, -1, 0, 0, -1, -1, -1, 0, -1] @=> int oc4[];
[ 4, 4, 6, 4, 6 , 0, 4, 4] @=> int c5[];
[-1, -1, -1, -1, -1 , 0, -1, -1] @=> int oc5[];
[ 5, 5, 6, 5, 6, 5, 6, 5, 6, 0, 1, 0] @=> int c6[];
[-1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1] @=> int oc6[];
[ 5, 5, 5, 5, 4, 5, 3, 5] @=> int c7[];
[-1, -1, 0, -1, 0, -1, 0, -1] @=> int oc7[];
[2, 5, 1, 5, 2, 5, 1, 2] @=> int c8[];
[0, -1, 0, -1, 0, -1, 0, 0] @=> int oc8[];
//Construction of main phrase using the figures above
[ c1, c2, c1, c3, c1, c4, c5, c6] @=> int p1[][];
[oc1, oc2, oc1, oc3, oc1, oc4, oc5, oc6] @=> int op1[][];
//Construction of Intro phrase
[ c1, c2, c3, c4, c5] @=> int p2[][];
//Background note
Std.mtof(D_d[0] - 12);
0 => float gain;
for(0 => int i; i < p2.cap(); i++)
{
for (0 => int j; j < p2[i].cap(); j++)
{
//Each note of the figures in arandom octave
Std.mtof(D_d[p2[i][j]] + 12*Math.random2(-2,2)) => lead.freq;
//Bring up the Gain up to 0.4
if(gain < 0.4) gain + 0.02 => gain;
gain => melody.gain;
gain => randGain.gain;
//Load a 2 random soundfiles
files[Math.random2(0, files.cap()-1)] => rand1.read;
files[Math.random2(0, files.cap()-1)] => rand2.read;
//set header to the last sample
rand1.samples() => rand1.pos;
rand2.samples() => rand2.pos;
//Set a random panning for both soundfiles
Math.random2f(-1.0, 1.0) => rand1Pan.pan;
Math.random2f(-1.0, 1.0) => rand2Pan.pan;
//Set a random reverse rate for both soundfiles
Math.random2f(-1.0, -0.2) => rand1.rate;
Math.random2f(-1.0, -0.2) => rand2.rate;
//Advance time
quarter => now;
}
}
//Set frequency of lead
Std.mtof(D_d[0]) => lead.freq;
//Wait in the same notes for 3 compasses
whole*3 => now;
//kill random soundfiles
0 => randGain.gain;
//kill any sounding notes
0 => melody.gain;
//First drumkit hit
0.5 => drums.gain;
//Set positions to 0 in order to read the sample
0 => snare.pos;
0 => kick.pos;
0 => ohihat.pos;
<<< "Fck Techno! You Want Metal, Right?!" >>>;
whole => now;
//drum counter
0 => int drumc;
//Set Melody and Percussion gains
0.35 => melody.gain;
0.3 => drums.gain;
//Execute main phrase (p1)
for(0 => int i; i<p1.cap() ; i++)
{
for(0 => int j; j<p1[i].cap(); j++)
{
// snare every pair hit
if (drumc % 2 == 0) 0=> snare.pos;
//closed hihat and kick every odd hit
else
{
0 => kick.pos;
0 => chihat.pos;
}
//Note of the melody
Std.mtof(D_d[p1[i][j]] + 12*op1[i][j]) => rythm.freq => lead.freq;
//Alteration in the rythmic pattern
if (i == 5 && (j == 6 || j == 7))
{
if (j == 7) drumc++; //Increase Drum Counter
sixteenth => now;
}
else
{
//Increase Drum Counter
drumc++;
eighth => now;
}
}
}
//Alteration on main phrase;
c7 @=> p1[6];
oc7 @=> op1[6];
c8 @=> p1[7];
oc8 @=> op1[7];
//Reset drum counter
0 => drumc;
//Bring Down melody gain
0.3 => melody.gain;
//Execute Altered Main Phrase
for(0 => int i; i<p1.cap() ; i++)
{
for(0 => int j; j<p1[i].cap(); j++)
{
// snare every pair hit
if (drumc % 2 == 0) 0=> snare.pos;
//open hihat and kick every odd hit
else
{
0 => kick.pos;
0 => ohihat.pos;
}
//Note of the Melody
Std.mtof(D_d[p1[i][j]] + 12*op1[i][j]) => lead.freq;
//Harmony
if(p1[i][j]<=4){
Std.mtof(D_d[p1[i][j]+2]+12*op1[i][j]) => rythm.freq;
}
else{
Std.mtof(D_d[p1[i][j]-5]+12*(op1[i][j]+1)) => rythm.freq;
}
//Same alteration as above
if (i == 5 && (j == 6 || j == 7))
{
if (j == 7) drumc++;//Increase Drum Counter
sixteenth => now;
}
else
{
// Increase Drum Counter
drumc++;
eighth => now;
}
}
}
//Last Hit
0 => ohihat.pos;
0 => snare.pos;
0 => kick.pos;
//Fade Out
0.3 => gain;
for(0 => int i; i <100; i++)
{
gain - 0.003 => gain;
gain => melody.gain;
sixteenth/2 => now;
}