-
Notifications
You must be signed in to change notification settings - Fork 77
/
default-synths.scd
186 lines (161 loc) · 5.21 KB
/
default-synths.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
/*
Add your own instruments here.
They can be used in Tidal just as samples (ignoring the sample number, so instead of "bd:2" write "inr")
// supported parameters are e.g.
// sustain, speed, endSpeed, begin, end, pan, accelerate, offset, cps
// all instruments ought to use: out
If your SuperDirt instance is assigned to the variable ~dirt, you can livecode these synths.
*/
(
// modulated band limited impulse
(
SynthDef(\imp, { |out, sustain = 1, freq = 440, speed = 1, begin=0, end=1, pan, accelerate, offset|
var env, sound, rate, phase;
env = EnvGen.ar(Env.perc(0.01, 0.99, 1, -1), timeScale:sustain, doneAction:2);
phase = Line.kr(begin, end, sustain);
rate = (begin + 1) * (speed + Sweep.kr(1, accelerate));
sound = Blip.ar(rate.linexp(0, 1, 1, freq) * [1, 1.25, 1.51, 1.42], ExpRand(80, 118) * phase).sum;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan, env)
)
}).add
);
// modulated phase mod sines
(
SynthDef(\psin, { |out, sustain = 1, freq = 440, speed = 1, begin=0, end=1, pan, accelerate, offset, modfreq = 40|
var env, sound, rate, phase, amp;
amp = AmpCompA.kr(freq);
env = EnvGen.ar(Env.perc(0.002, sustain, 1, -1), doneAction:2);
phase = Line.ar(begin, end, sustain);
rate = speed + Sweep.kr(1, accelerate);
sound = SinOsc.ar(freq, SinOsc.ar(modfreq * (1..5), 0, 1 - phase * 10 * env / (1..5), 0.5pi)).sum;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan, env)
)
}).add
);
// cursor modulated phase mod sines
(
SynthDef(\pmsin, { |out, sustain = 1, freq = 440, speed = 1, begin=0, end=1, pan, accelerate, offset|
var env, sound, rate, phase, modfreq, amp;
freq = (MouseX.kr(30, 80).round + freq);
modfreq = MouseY.kr(1, 200, 1);
amp = AmpCompA.kr(freq);
env = EnvGen.ar(Env.perc(0.002, sustain, 1, -1), doneAction:2);
phase = Line.ar(begin, end, sustain);
rate = speed + Sweep.kr(1, accelerate);
sound = SinOsc.ar(freq, SinOsc.ar(modfreq * (1..5), 0, 1 - phase * 10 * env / (1..5), 0.5pi)).sum;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan, env)
)
}).add
);
// live audio input
(
SynthDef(\in, { |out, soundin = 0, sustain = 1, pan, inputFadeTime = 0.03|
var env, sound;
env = Env.linen(inputFadeTime, sustain - (2 * inputFadeTime), inputFadeTime).kr;
sound = SoundIn.ar([0, 1] + soundin); // stereo in
sound = sound * env;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan)
)
}).add
);
(
SynthDef(\in1, { |out, soundin = 0, sustain = 1, pan, inputFadeTime = 0.03|
var env, sound;
env = Env.linen(inputFadeTime, sustain - (2 * inputFadeTime), inputFadeTime).kr;
sound = SoundIn.ar(soundin); // mono in
sound = sound * env;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan)
)
}).add
);
// read input from nth routing bus
// see also: effect "to"
(
SynthDef(\dirt_from, { |out, sustain = 1, in, pan, inputFadeTime = 0.03|
var env, sound;
env = Env.linen(inputFadeTime, sustain - (2 * inputFadeTime), inputFadeTime).kr;
sound = InFeedback.ar(in, ~dirt.numChannels);
sound = sound * env;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan)
)
}).add;
~dirt.soundLibrary.addSynth(\from,
(
instrument: \dirt_from,
in: {
~dirt.audioRoutingBusses.wrapAt(~from ? 0).index
}
)
)
);
// panic button - equivalent of ctrl-.
(
~dirt.soundLibrary.addSynth(\superpanic, (play: { ~dirt.orbits.do(_.freeSynths) }))
);
// pitch shifted live audio input
(
SynthDef(\inr, { |out, sustain = 1, freq = 440, speed = 1, begin=0, end=1, pan, accelerate, offset, inputFadeTime = 0.03|
var env, sound, rate, phase;
env = Env.linen(inputFadeTime, sustain - (2 * inputFadeTime), inputFadeTime).kr;
phase = Line.ar(begin, end, sustain);
rate = (begin + 1) * (speed + Sweep.kr(1, accelerate)) * freq / 440;
sound = SoundIn.ar([0, 1]); // stereo in
sound = sound * env;
sound = PitchShift.ar(sound, 0.1, rate, 0.02, 0.01);
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan)
)
}).add
);
// gabor grain
(
SynthDef(\gabor, { |out, sustain = 0.03, freq = 440, pan = 0, width = 0.3|
var env, sound;
sound = SinOsc.ar(freq, 0.5pi);
env = LFGauss.ar(sustain, width, loop: 0).range(0, 1);
Out.ar(out,
DirtPan.ar(env * sound, ~dirt.numChannels, pan)
)
}).add;
);
// dirac delta function approximation
(
SynthDef(\dirac, { |out, sustain = 0.03, pan = 0|
Out.ar(out,
DirtPan.ar(Impulse.ar(0), ~dirt.numChannels, pan)
)
}).add;
);
// shepard on a cycle
(
SynthDef(\cyclo, { |out, freq, sustain = 1, speed = 1, begin = 0, end = 1, pan, accelerate, cycle, ratio = 1|
var env, sound, rate, phase;
env = EnvGen.ar(Env.perc(0.01, 0.99, 1, -1), timeScale:sustain, doneAction:2);
phase = Line.kr(begin, 1 - end, sustain);
rate = (begin + 1) * (speed + Sweep.kr(1, accelerate));
freq = (cycle * speed) % ((1..16) * ratio + phase) + 1 * freq * rate;
sound = SinOsc.ar(freq).mean;
Out.ar(out,
DirtPan.ar(sound, ~dirt.numChannels, pan, env)
)
}).add
);
// debug a few time related values
(
SynthDef(\debug, { |begin = -1, end = -1, delta = -1, sustain = -1, unitDuration = -1, cycle = -1|
cycle.poll(Impulse.kr(0), label: "cycle");
begin.poll(Impulse.kr(0), label: "begin");
end.poll(Impulse.kr(0), label: "end");
delta.poll(Impulse.kr(0), label: "delta");
sustain.poll(Impulse.kr(0), label: "sustain");
unitDuration.poll(Impulse.kr(0), label: "unitDuration");
DC.kr(0).poll(Impulse.kr(0), label: "\n\n");
}).add
);
)