-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathintro.scd
289 lines (241 loc) · 5.87 KB
/
intro.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
/*
WavesetsEvent
*/
s.boot; // boot the server
// if you like, record a soundfile (wait 8 sec)
(
var time = 8;
var f = {
var mod = Line.kr(0, 1, time);
var imp = Impulse.ar(mod.linexp(0, 1, 1, 16) * [2, 3]);
var fmod = SinOsc.ar(mod.linexp(0, 1, 244 * rrand(0.4, 1.4), 0.01));
fmod = fmod * Decay2.ar(imp, 0.02, 0.08, 2pi, 0.3pi);
SinOsc.ar(300 + (mod * 145), fmod) * 0.1
};
f.asBuffer(time, fadeTime:0.1, action: { |buffer|
buffer.write(Platform.resourceDir +/+ "sc-wavesets-test-mono.aiff");
"... finished writing ....".postln;
buffer.free;
}
);
)
// load two files for wavesets
(
a = WavesetsEvent.read(Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff");
b = WavesetsEvent.read(Platform.resourceDir +/+ "sc-wavesets-test-mono.aiff");
WavesetsEvent.prepareSynthDefs;
)
// how many wavesets?
a.size;
b.size;
// play some.
// you pass an event with parameters and get back an event with parameters
a.asEvent((start: 76, end: 899)).play;
b.asEvent((start: 76, end: 899)).play;
a.asEvent((start: 136, num: 99)).play;
a.asEvent((start: 136, num: 9911, rate: -1)).play; // backwards
a.buffer.play
// this sounds better in a repetition:
(
Tdef(\u, {
inf.do { |i|
a.asEvent((start: i * 10 % 1850, num: 39)).play;
0.05.wait;
}
}).play
)
// what parameters can you pass?
start: from which waveset to start
num: how many wavesets to play
end: up to which waveset to play (if given, overrides num)
repeats: how many times to repeat the selected wavesets
startTime: where to start in the file - will be rounded to the next waveset (if given, overrides start)
endTime: where to end in the file - will be rounded to the next waveset (if given, overrides start)
amp: scale the amplitude of the original sound
wsamp: normalize the amplitude to that value
wsustain: sustain time - will be rounded to the next waveset (if given, overrides end and num)
fixsustain: sustain time - wavesets will be rate adjusted so it matches the sustain
rate: playback speed of the audio file
rate2: end playback speed of the audio file (will create a linear glisson sweep)
pan: stereo panorama position
// dur and legato
the waveset event also includes a \dur value (usually, dur is the inter-onset time between events). it is calculated from the actual duration of the selected wavesets. if you provide \legato, it will scale the duration, so that wavesets will overlap or have gaps between them.
// reproduce original
(
Tdef(\u, {
inf.do { |i|
var event = a.asEvent((start: i % a.size, num: 1, legato: 1));
event.play;
event[\dur].wait;
}
}).play
)
// reproduce original with varying chunk size, but reverse the chunks
(
Tdef(\u, {
var start = 0, num = 1;
inf.do { |i|
var event;
event = a.asEvent((start: start, num: num, rate: -1));
event.play;
event[\dur].wait;
start = start + num % a.size;
num = rrand(1, 3) * (i / 10 % a.size + 1)
}
}).play
)
// rate and legato
(
Tdef(\u, {
inf.do { |i|
var event = a.asEvent((start: i % a.size, num: 1, legato: 3/2, rate: 2/3));
event.play;
event[\dur].wait;
}
}).play
)
// rate and legato
(
Tdef(\u, {
inf.do { |i|
var event = a.asEvent((start: i * 18 % a.size, num: 213, legato: 1, rate: 1.2, rate2: 0.8));
event.play;
event[\dur].wait;
}
}).play
)
// repeats
(
Tdef(\u, {
inf.do { |i|
var event = a.asEvent((start: i % a.size, num: 1, legato: 1, repeats: 80, legato: 0.9));
event.play;
event[\dur].wait;
}
}).play
)
// use a slider to search for interesting places. hit some key to post them, hit space to start the Tdef
// edit the other parameters in the code as you like them.
(
Tdef(\u, {
inf.do { |i|
var event;
event = (
start: ~start ? 0,
num: rrand(1, 10),
rate: 1,
repeats:1
);
event = a.asEvent(event);
event.play;
event[\dur].wait;
}
}).play;
)
(
var w = Window("adjust start", Rect(100, 100, 820, 50)).front;
var sl = Slider(w);
sl.orientation = \horizontal;
sl.action = { |view| ~start = view.value.linlin(0, 1, 0, a.size) };
sl.keyDownAction = { |view, char| if(char == $ ) { Tdef(\u).play } { ~start.trunc.post; ",".postln; } };
w.layout = HLayout(sl);
)
// e.g. put in a pseq for later on.
(
Pseq([
610,
805,
986,
298,
841,
], inf);
)
// patterns
// using Pwavesets, we can use wavesets in event patterns directly
Pwavesets((start: 56, num: 78, wavesets: a)).play;
// we can add a waveset to a global dictionary
a.add(\one);
b.add(\two);
// then you can access by name:
Pwavesets((start: 56, num: 78, name: \one)).play;
// currentSize returns a stream with the wavesets size for the current name
Pwavesets(Pbind(\name, \one, \start, Pseries(0, 1, Pwavesets.currentSize - 1))).play;
Pwavesets(Pbind(\name, Pdup(30, Prand([\one, \two], inf)), \start, Pseries(0, 1, Pwavesets.currentSize - 1))).play;
(
Pwavesets(
Pseq([
(start: 56, num: 78, name: \one),
(start: 123, num: 78, name: \one),
(start: 562, num: 118, name: \one, legato: 0.5),
], inf)
).play;
)
(
Pwavesets(
Pbind(
\name, \one,
\start, Pn(Pseries(0, 2, 1000)),
\end, Pn(Pseries(0, 2.6, 1000)),
\repeats, 3,
\legato, 1.0,
\amp, 0.1,
\pan, Pbrown(-0.5, 0.5, 0.001)
)
).play
)
// for easy experimentation: use a Pdef
(
Pdef(\x,
Pwavesets(
Pbind(
\name, Prand([\one, \two], inf),
\start, Pn(Pseries(0, 2, a.size - 1)),
\end, Pn(Pseries(0, 2.6, a.size - 1)),
\repeats, 1,
\legato, 1.0,
\amp, 0.1,
\pan, Pbrown(-0.5, 0.5, 0.001)
)
)
).play
)
(
Pdef(\x,
Pwavesets(
Pbind(
\name, \one,
\start, Pn(Pseries(0, 2, a.size - 1)) + 900,
\num, Pn(Pseries(10, 0.6, 80)),
\repeats, 9,
\legato, 1,
\rate, Pbrown(0.5, 2, 0.01, inf),
\amp, 0.1,
\pan, Pbrown(-0.5, 0.5, 0.001)
)
)
).play
)
// from the values above
(
Pdef(\x,
Pwavesets(
Pbind(
\name, \one,
\start,
Pstutter(120, Pseq([
610,
805,
986,
298,
841,
], inf)),
\num, Pn(Pseries(10, 0.6, 80)),
\repeats, 1,
\legato, 1,
\rate, Pbrown(0.5, 2, 0.01, inf),
\amp, 0.1,
\pan, Pbrown(-0.5, 0.5, 0.001)
)
)
).play
)