-
Notifications
You must be signed in to change notification settings - Fork 4
/
SuperDirt.test.scd
373 lines (260 loc) · 7.53 KB
/
SuperDirt.test.scd
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/*
INIT SUPERDIRT
*/
(
s.quit;
s.options.numBuffers = 1024 * 16;
s.options.memSize = 8192 * 16;
~dirt.free; // free old instance
s.waitForBoot {
~dirt = SuperDirt(2, s);
~dirt.loadSoundFiles;
s.sync; // wait until all soundfiles are really loaded
~dirt.start([57120, 57121]); // listen on two different ports
}
)
/*
In theory, it should now receive tidal messages ...
---------------------------------------------------
*/
OSCFunc.trace(true, true); // see if network messages are coming in from tidal
OSCFunc.trace(false); // stop tracing
/*
SOME CONTROL
*/
// access separate dirt busses directly
(
~d1 = ~dirt.dirtBusses[0]; // one port
~d2 = ~dirt.dirtBusses[1]; // the other
)
// stop temporarily
~dirt.stop;
// start again
~dirt.start([57120, 57121]); // listen on two different ports: you can add any number of ports here
// finally, after the tests, you can free everything again:
~dirt.free;
/*
The rest can be done from tidal, but here are some tests that call the function directly from sclang.
-----------------------------------------------------------------------------------------------------
*/
/*
TEST SPEED/START/END
*/
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'cy:10', 0, 0.3.rand, 1.0.rand, 1 + 1.3.rand2, 2.rand2, accelerate:0);
(0.2 * [1, 2, 1/3]).choose.wait;
}
}).play;
)
~d1.(nil, 1, 'cy:10', speed: 1);
~d1.(nil, 1, 'cy:10', speed: -1);
~d1.(nil, 1, 'cy:10', speed: 2, accelerate: -1);
~d1.(nil, 1, 'cy:10', speed: -2, accelerate: 1);
~d1.(nil, 1, 'cy:10', speed: 1, accelerate: -0.2);
~d1.(nil, 1, 'cy:10', speed: 0.5, accelerate: -0.3);
~d1.(nil, 1, 'sd:8', speed: 1);
~d1.(nil, 1, 'cy:10', speed: 2);
/*
TEST PANNING
*/
~d1.(nil, 1, 'cy:10', pan:0);
~d1.(nil, 1, 'cy:10', pan:1);
~d1.(nil, 1, 'cy:10', pan:0.5);
~d1.(nil, 1, 'uxay', pan:0); // stereo
~d1.(nil, 1, 'uxay', pan:1);
~d1.(nil, 1, 'uxay', pan:0.5);
/*
TEST EFFECTS
*/
~d1.(nil, 1, 'cy:10', speed: 0.2, crush: 4);
~d1.(nil, 1, 'cy:10', speed: 0.2, coarse: 8);
~d1.(nil, 1, 'cy:10', speed: 0.2, crush: 4, coarse: 38);
~d1.(nil, 1, 'cy:10', speed: 1, crush: 4);
~d1.(nil, 1, 'cy:10', speed: 1, hcutoff: 1000, hresonance: 20);
~d1.(nil, 1, 'cy:10', speed: 1, hcutoff: 3000, hresonance: 10);
~d1.(nil, 1, 'cy:10', speed: 1, bandqf: 3000, bandq: 100);
~d1.(nil, 1, 'cy:10', speed: 1, bandqf: 3000, bandq: 100, coarse: 13);
~d1.(nil, 1, 'cy:10', speed: 1, bandqf: 3000, bandq: 100, crush: 1);
~d1.(nil, 1, 'cy:10', speed: 1, hcutoff: 1000, hresonance: 20, coarse: 0.10);
// test vowels
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \a);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \i, resonance: 1, cutoff: 200, gain: 2);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \a, resonance: 0.1);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \o, resonance: 0.1);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \o, resonance: 0.1, coarse: 30);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \a, resonance: 0.1, pan: 0);
~d1.(nil, 1, 'cy:10', speed: 1, vowel: \a, resonance: 0.1, pan: 1);
Tdef(\x).stop;
~d1.releaseTime = 0.002;
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'sd:8', start: 0, end: 1, speed: 1, vowel: "aeiou".choose.asSymbol, resonance: 0.6, cutoff: 540, gain: 1);
1.wait;
//(0.3 * [1, 2, 1/3]).choose.wait;
}
}).play;
)
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'sd:8', start: 0, end: 1.0.rand, speed: 2.5, vowel: "aeiou".choose.asSymbol, resonance: 0.5, cutoff: 202);
0.1.wait;
}
}).play;
)
// tough test
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'sd:8', start: 0, end: 1.0.rand, speed: 12.5, vowel: "a", resonance: 1, cutoff: 202);
0.02.wait;
}
}).play;
)
Tdef(\x).stop;
// test delay:
~d1.(nil, 1, 'cy:10', speed: 1, delaytime: 0.8, delay: 1);
~d1.(nil, 1, 'cy:10', speed: 1, delaytime: 0.8, delay: 1, delayfeedback: 0.4);
~d1.(nil, 1, 'cy:10', speed: 1, delaytime: 0.8, delay: 0);
~d1.(nil, 1, 'cy:10', speed: 1, delaytime: 0.2, delay: 1);
fork { (0, 0.1 ..1).do { |a| ~d1.(nil, 1, 'cy:10', speed: 1, delaytime: 0.33, delay: a); 1.wait } };
/*
TEST CUTGROUPS
*/
// cutgroup tests
~d1.(nil, 1, 'cy:10', speed: 0.02, cutgroup: -8); // really slow, to keep it on: see synth reading
~d1.(nil, 1, 'cy:10', speed: 0.02, cutgroup: -8); // cut the old one: number stays the same
~d1.(nil, 1, 'cy:10', speed: 0.02, cutgroup: -8); // ... again
// this should add another one, as the cutgroups are independent between ~d1 and ~d2
~d2.(nil, 1, 'cy:10', speed: 0.02, cutgroup: -8);
~d2.(nil, 1, 'cy:10', speed: 0.02, cutgroup: -8); // cut the old one, add the new one, same synth count
// With negative, only stop the same sample from playing in the same cutgroup
~d1.(nil, 1, 'cy:9', speed: 0.02, cutgroup: -8); // a different sample, is added
~d1.(nil, 1, 'cy:9', speed: 0.02, cutgroup: -8); // the same sample, frees
// with positive integers, stop samples playing that are in the same cutgroup.
~d1.(nil, 1, 'cy:10', speed: 0.02, cutgroup: 8); // should free all others
/*
TEST UNIT
*/
/*
s unit -
"r" makes unit of speed and start/end time in terms of
ratio (the default described above),
"c" in terms of cycles per second
(i.e. 1 to play back at a speed that makes the sample exactly fill one
cycle), and
"s" in terms of seconds
*/
// \r
(
Tdef(\x, {
var name = 'cy:10';
var cps = 2;
20.do {
~d1.(nil, cps:cps, sound:name, unit: \r, start: 0, end: 1);
cps = cps + 0.3;
(1/cps).wait;
}
}).play
)
// \c
(
Tdef(\x, {
var name = 'cy:10';
var cps = 2;
20.do {
~d1.(nil, cps:cps, sound:name, unit: \c, start: 0, end: 1);
cps = cps + 0.3;
(1/cps).wait;
}
}).play
)
// \s
(
Tdef(\x, {
var name = 'cy:10';
var cps = 0.2;
loop {
~d1.(nil, cps:cps, sound:name, unit: \s, start: 0, end: 0.2);
0.2.wait;
}
}).play
)
/*
TEST LIVE CODING SYNTHS
*/
// this is a default synth def
~d1.(nil, 1, 'imp', speed: 1, start: 0, end: 1);
~d1.(nil, 1, 'imp', speed: 1, start: 0.5, end: 1);
~d1.(nil, 1, 'imp', speed: 0.1, start: 0, end: 1, accelerate: 3);
~d1.(nil, 1, 'imp', speed: 1, start: 0, end: 0.3.rand, delay: 1, delaytime: 3);
~d1.(nil, 1, 'imp', speed: 1, start: 0, end: 0.3.rand, delay: 1, delaytime: 3);
~d1.(nil, 1, 'imp', speed: 1, start: 0, end: 0.3.rand, delay: 1, delaytime: 3);
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'imp', 0,
speed: rrand(0.1, 2.0),
start:1.0.rand,
end: 2.0.rand,
accelerate:2.0.rand,
hcutoff: 4000.0.rand,
hresonance: 0.5.rand,
delay: 1.0.rand,
delaytime: 0.2
);
0.5.wait;
}
}).play;
)
(
Tdef(\x, {
loop {
~d1.(nil, 1, 'inr', 0,
speed: rrand(0.5, 2.0),
start:1.0.rand,
end: 2.0.rand,
//accelerate:2.0.rand,
//hcutoff: 4000.0.rand,
//hresonance: 0.5.rand,
delay: 1.0.rand,
//delaytime: 0.2
);
0.15.wait;
}
}).play;
)
// rewrite this at runtime
(
SynthDef(\imp, { |speed = 1, start=0, end=1, pan, accelerate, amp = 1, offset|
var env, sound, dur, rate, phase;
dur = (end - start) / speed;
env = EnvGen.ar(Env.linen(0, 0.2, 0.8, amp * 0.1, -4), timeScale:dur, doneAction:2);
phase = Line.ar(start + 0.0001, end, dur);
rate = (start + 1) * (speed + Sweep.kr(1, accelerate));
sound = Saw.ar(rate.linexp(0, 1, 1/[1, 3, 7], [1, 2, 5]) * 200).sum;
sound = RHPF.ar(sound, phase.linexp(start, end, 300, 9000));
env = env * ~dirt.gateCutGroup; // this synth can be freed by cutgroup mechanism
~dirt.panOut(sound, pan, env)
}).add;
)
/*
NETWORK TEST
*/
// network test
n = NetAddr("127.0.0.1", 57120);
// Should pan left and right?
n.sendMsg(\play, 1, 'cy:10',0,0,1,1,0);
n.sendMsg(\play, 1, 'cy:10',0,0,1,1,1);
// feeding back
n.sendMsg(\play, 1, 'cy:10',0,0,1,1,0.5,0,"o");
n.sendMsg(\play, 1, 'cy:10',0,0,1,1,0.5,0);
n.sendMsg(\play, 1, 'breaks125');
n.sendMsg(\play, 1, \imp);
(
n.sendBundle(1.2, [\play, 1, 'cy']);
n.sendBundle(1.2, [\play, 1, 'cy']);
)