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.

79 lines
2.5 KiB
Plaintext

(
SynthDef(\mellotronFlute, {
arg freq = 440, amp = 0.3, gate = 1, pan = 0, vibratoRate = 1, vibratoDepth = 0.15,
noiseLevel = 0.2, ringModFreq = 3, lpfFreq = 1200, res = 0.8, lpfLfoRate = 1, lpfLfoDepth = 80,
detune = 0.005; // Detune amount (in ratio)
var sig, osc1, osc2, vibrato, noise, env, lpfMod, freq1, freq2;
// Natural vibrato (LFO)
vibrato = SinOsc.kr(vibratoRate, 0, vibratoDepth).range(0.98, 1.02);
// Detuned frequencies (slight offsets)
freq1 = freq * (1.01); // Slightly sharp
freq2 = freq * (1.01); // Slightly flat
// 1st Oscillator: Triangle waves with vibrato
osc1 = Mix([
LFTri.ar(freq1 * vibrato),
LFTri.ar(freq2 * vibrato)
]) * 0.5; // Mix detuned voices
// Pink noise mixed into the first oscillator for breathiness
noise = PinkNoise.ar(noiseLevel);
osc1 = Mix([osc1, noise * 0.5]); // Blend noise into osc1
// 2nd Oscillator: Detuned ring modulation for a natural tone
osc2 = Mix([
Saw.ar(freq1 * ringModFreq),
SinOscFB.ar(freq2 * ringModFreq)
]) * 0.5 * osc1; // Ring-modulated with detuned pair
// Mix oscillators together
sig = Mix([ osc1, osc2 * 0.5]);
// LFO for filter frequency modulation
lpfMod = SinOsc.kr(lpfLfoRate).range(lpfFreq - lpfLfoDepth, lpfFreq + lpfLfoDepth);
// Low-pass filter with LFO modulation and slight resonance
sig = RLPF.ar(sig, lpfMod, res);
// Envelope (slow attack for a natural swell)
env = EnvGen.kr(Env.adsr(0.2, 3, 1, 1), gate, doneAction: 2);
// Apply envelope and amp
sig = sig * env * amp;
// sig = sig.tanh(8);
sig = BLowShelf.ar(sig, 200, 0.5, 9);
// sig = sig.blend(GVerb.ar(sig, 200, 4), 0.15);
// sig = sig.blend(BPF.ar(sig, 800, 0.5), 0.9);
// Output with panning
Out.ar(0, Pan2.ar(sig, pan));
}).add;
)
// Play the flute synth
x = Synth(\mellotronFlute, [\freq, 53.midicps, \detune, 0.1]); // Slight detune for a richer sound
(
Pbind(
\instrument, \mellotronFlute, // Use your SynthDef
// \freq, Pseq([40, 37, 38, 30, 45, 30].midicps, inf), // Sequence of MIDI notes converted to Hz
\freq, Pseq([[48, 20, 53], [10, 58, 60], [10, 55, 63], [12, 55, 58]].midicps, inf), // Sequence of MIDI notes converted to Hz
// \freq, Pseq([[50, 65], [55, 72], [72, 74], [48, 20]].midicps, inf), // Sequence of MIDI notes converted to Hz
\detune, Pseq([0.2], inf), // Varying detune values
\dur, Pseq([2], inf), // Duration per note
// \amp, 0.02;
).play;
)