-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch-06-06-2023.scd
233 lines (169 loc) · 3.42 KB
/
sketch-06-06-2023.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
s.boot;
s.options.sampleRate = 24000;
s.reboot;
(
~fn = {
var sig0, sig1;
sig0 = PinkNoise.ar(mul: 0.2 ! 2);
sig1 = SinOsc.ar(200, mul: 0.1 ! 2);
sig0 + sig1;
}
)
x = ~fn.play;
x.free;
(
~fn = {
arg amp = 0.2;
var sig, mod;
mod= SinOsc.kr(
freq: 1/4,
phase: 3pi/2, // shifts where the fist cycle begins
mul: 0.5, // mul: is a value that is multiplied by every sample
add: 0.5, // add: is a value that is added to every sample in the output signal
);
sig = PinkNoise.ar(amp ! 2);
sig = sig * mod;
}
)
(
~fn = {
arg amp = 0.2;
var sig, mod;
mod= SinOsc.kr(
freq: 1/4,
phase: 3pi/2,
).range(0, 1);
sig = PinkNoise.ar(amp ! 2);
sig = sig * mod;
}
)
(
~fn = {
arg modwidth = 200;
var sig, mod;
mod = SinOsc.kr(freq: 5).bipolar(modwidth);
sig = SinOsc.ar(300 + mod, mul: 0.1);
}
)
x = ~fn.play;
x.set(\modwidth, 100)
x.free;
x.release(5);
// Envelopes
(
~fn = {
var sig, env;
sig = SinOsc.ar(ExpRand(200, 1000), mul: 0.1) ! 2;
// env = Line.kr(1, 0, 1, doneAction: 2); // just straign line
env = XLine.kr(1, 0.001, 1, doneAction: 2); // exponential line
sig = sig * env;
};
)
x = ~fn.play;
x.free;
s.plotTree;
(
e = Env.new(
levels: [0, 1, 0.4, 0.6, 0],
times: [0.5, 0.5, 2, 0.5],
curve: [0, 0, 0, 0],
);
)
(
e = Env.new(
levels: [0, 1, 0.4, 0.6, 0],
times: [0.5, 0.5, 2, 0.5],
curve: [3, 0, 0, 0],
);
)
(
e = Env.new(
levels: [0, 1, 0.4, 0.6, 0],
times: [0.5, 0.5, 2, 0.5],
curve: [-3, 0, 0, 0],
);
)
e.plot;
// fixed duration envelope
(
~fn = {
var sig, env;
sig = SinOsc.ar(ExpRand(200, 1000), mul: 0.1) ! 2;
env = EnvGen.kr(
envelope: Env(
levels: [0, 1, 0.4, 0.6, 0],
times: [0.5, 0.5, 2, 0.5],
curve: [0, 0, 0, 0],
),
doneAction: 2,
);
sig = sig * env;
};
)
x = ~fn.play;
x.free;
// can be sustained indefinitely, until gate set to 0
(
~fn = {
arg gate = 1;
var sig, env;
sig = SinOsc.ar(ExpRand(200, 1000), mul: 0.1) ! 2;
env = EnvGen.kr(
envelope: Env(
levels: [0, 1, 0.3, 0],
// attack, decay, release
times: [0.05, 0.6, 2],
curve: [-3, -1, -1],
releaseNode: 2,
),
gate: gate,
doneAction: 2,
);
sig = sig * env;
};
)
x = ~fn.play;
x.set(\gate, 0);
x.free;
// fixed duration envelope
(
~fn = {
// t_gate is a trigger control and helps to play the fixed duration envelope from the beginning as many times as i want
// without it, i would have to set the gate value to 0 and then to 1, because it ends at 1;
// works only with doneAction: 0, unless quick enough with the doneAction: 2
arg t_gate = 1;
var sig, env;
sig = SinOsc.ar(ExpRand(200, 1000), mul: 0.1) ! 2;
env = EnvGen.kr(
envelope: Env(
levels: [0, 1, 0],
times: [0.02, 1],
curve: [-2, -4],
),
gate: t_gate,
// when done action at 0, it will persist until freed
doneAction: 0,
);
sig = sig * env;
};
)
x = ~fn.play;
x.set(\t_gate, 1);
x.free;
// Multichannel Expansion
s.options.numOutputBusChannels = 24; // kind of 24 speakers
s.reboot;
s.meter;
{ PinkNoise.ar(0.1) ! 4 }.play;
{ PinkNoise.ar([0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64]) }.play;
{ PinkNoise.ar(0.1 ! 2) }.play;
// example what to avoid to do when setting multichannel signals
// these example tries to expand multichannel signal that is already expanded
(
{
var sig;
sig = [PinkNoise.ar(0.1), SinOsc.ar(200, mul: 0.1)];
sig = (sig ! 2).postln;
0;
}.play;
)