tidal-voltage/voltage.scd

113 lines
2.1 KiB
Plaintext
Raw Normal View History

2020-05-20 11:02:06 +01:00
(
2020-08-09 13:35:55 +01:00
(
2023-01-11 11:21:33 +00:00
SynthDef(\pitch, {
|
out,
2021-01-03 12:35:42 +00:00
n,
channel,
stepsPerOctave = 12,
rate = 1,
delta,
begin,
end,
portamento = 0 |
2020-08-09 13:35:55 +01:00
var slew, env, phase;
n = n + (stepsPerOctave / 12);
n = (n + (n / stepsPerOctave) * (1 / (stepsPerOctave + 1)) / 10);
2021-01-03 12:35:42 +00:00
slew = (portamento);
2020-08-09 13:35:55 +01:00
slew = (slew + (slew / stepsPerOctave) * (1 / (stepsPerOctave + 1)) / 10);
2023-01-11 11:21:33 +00:00
env = Env([n, n + slew], [delta / rate]);
phase = Line.ar(begin, end, delta / rate);
OffsetOut.ar(channel, IEnvGen.ar(env, phase));
2020-08-09 13:35:55 +01:00
}).add
);
2020-05-20 11:02:06 +01:00
2020-08-09 13:35:55 +01:00
(
2023-01-11 11:21:33 +00:00
SynthDef(\gate, {
|
out,
2021-01-03 12:35:42 +00:00
channel,
2023-01-11 11:21:33 +00:00
amp,
2021-01-03 12:35:42 +00:00
n |
n = n * 5;
2023-01-11 11:21:33 +00:00
OffsetOut.ar(channel, DC.ar(n) * amp);
2021-01-03 12:35:42 +00:00
}).add
);
(
2023-01-11 11:21:33 +00:00
SynthDef(\voltage, {
|
out,
2021-01-03 12:35:42 +00:00
channel,
n,
rate = 1,
delta,
begin,
2023-01-11 11:21:33 +00:00
amp = 1,
2021-01-03 12:35:42 +00:00
end,
portamento = 0 |
2020-08-09 13:35:55 +01:00
var slew, env, phase;
n = n * 5;
2021-01-03 12:35:42 +00:00
slew = (portamento);
rate = rate;
2023-01-11 11:21:33 +00:00
env = Env([n, n + slew], [delta / rate]);
phase = Line.ar(begin, end, delta / rate);
OffsetOut.ar(channel, EnvGen.ar(env, phase) * amp);
2020-08-09 13:35:55 +01:00
}).add
);
2020-08-09 13:29:44 +01:00
2020-08-09 13:35:55 +01:00
(
2023-01-11 11:21:33 +00:00
SynthDef(\saw, {
|
out,
channel,
amp = 1,
rate = 0.5 |
OffsetOut.ar(channel, abs(Saw.ar(rate)) * amp);
}).add;
);
(
SynthDef(\lfo, {
|
out,
channel,
amp = 1,
rate = 0.5 |
OffsetOut.ar(channel, K2A.ar(abs(SinOsc.ar(rate, 0)) * amp));
}).add;
);
(
SynthDef(\ar, {
|
out,
2021-01-03 12:35:42 +00:00
channel,
attack = 0.01,
decay = 0.25,
sustain = 0.25,
release = 0.25,
begin,
2023-01-11 11:21:33 +00:00
amp = 1,
2021-01-03 12:35:42 +00:00
end |
2020-08-09 13:35:55 +01:00
var env, phase;
2023-01-11 11:21:33 +00:00
env = Env.adsr(attack, decay, sustain, release);
phase = Line.ar(begin, end, sustain);
OffsetOut.ar(channel, IEnvGen.ar(env, phase) * amp);
2020-08-09 13:35:55 +01:00
}).add
);
2021-01-03 12:35:42 +00:00
2023-02-11 12:05:21 +00:00
(
SynthDef(\nPitch, {
| out,
channel = 0,
freq = 440,
portamento = 0 |
var n = Lag.ar(log2(K2A.ar(freq)/440), portamento);
var sig = LinLin.ar(n, -1, 9, 0, 1);
OffsetOut.ar(channel, [sig]);
}).add
);
2020-08-09 13:29:44 +01:00
)