You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB
Plaintext

(
SynthDef(\mellotron, {
arg freq = 440, amp = 0.8, gate = 1, pan = 0, vibratoRate = 1, vibratoDepth = 0.15,
noiseLevel = 0.2, ringModFreq = 3, lpfFreq = 2000, res = 0.8, lpfLfoRate = 1, lpfLfoDepth = 100,
detune = 0.005;
var sig, osc1, osc2, vibrato, noise, env, lpfMod, freq1, freq2;
vibrato = SinOsc.kr(vibratoRate, 0, vibratoDepth).range(0.98, 1.02);
freq1 = freq * (0.99);
freq2 = freq * (1.01);
osc1 = Mix([
LFTri.ar(freq1 * vibrato),
LFTri.ar(freq2 * vibrato)
]) * 0.5;
noise = WhiteNoise.ar(noiseLevel);
osc1 = Mix([osc1, noise * 0.5]);
osc2 = Mix([
Saw.ar(freq1 * ringModFreq),
SinOscFB.ar(freq2 * ringModFreq)
]) * 0.5 * osc1;
sig = Mix([ osc1, osc2 * 0.5]);
lpfMod = SinOsc.kr(lpfLfoRate).range(lpfFreq - lpfLfoDepth, lpfFreq + lpfLfoDepth);
sig = RLPF.ar(sig, lpfMod, res);
env = EnvGen.kr(Env.adsr(0.2, 3, 1, 2), gate, doneAction: 2);
sig = sig * env * amp;
sig = sig.tanh(8);
sig = BLowShelf.ar(sig, 200, 0.5, 9);
Out.ar(0, Pan2.ar(sig, pan));
}).add;
)
(
Pbind(
\instrument, \mellotron,
\freq, Pseq([
[48, 20, 53], [10, 58, 60], [10, 55, 63], [12, 55, 58],
[48, 20, 53], [10, 58, 60], [55, 72, 74], [10, 63, 70],
].midicps, inf),
\dur, 2,
).play;
)