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.
89 lines
2.1 KiB
Plaintext
89 lines
2.1 KiB
Plaintext
MIDIClient.init;
|
|
MIDIIn.connectAll;
|
|
MIDIClient.sources.do;
|
|
|
|
(
|
|
SynthDef(\rhubarb, {
|
|
|freq = 440, gate = 1, cutoff = 1e4, rq = 0.3, amp = 0.05, modDepth = 0.3, modDepth2 = 0.5, noiseLevel = 0.8, ringFreq = 80|
|
|
var env, osc1, osc2, osc3, filt1, filt2, filt3, lfo, lfo2, noise, noiseFilt, sig1, sig2, sig3, mix;
|
|
|
|
// Slightly Different Oscillators
|
|
osc1 = SinOsc.ar(freq);
|
|
osc2 = SinOsc.ar(freq * 0.5); // Slight detune for variation
|
|
osc3 = SawDPW.ar(freq * 2);
|
|
|
|
// LFO to Modulate Filter Frequency
|
|
lfo = LFNoise0.kr(4).range(1 - modDepth, 1 + modDepth);
|
|
lfo2 = LFNoise2.kr(4).range(1 - modDepth, 1 + modDepth);
|
|
// lfo2 = noise;
|
|
|
|
// Apply Different Filters to Each Oscillator
|
|
filt1 = SVF.ar(osc1, cutoff * lfo, rq);
|
|
filt2 = LPF.ar(osc2, cutoff * lfo, rq);
|
|
filt3 = BPF.ar(osc3, cutoff * lfo2, rq);
|
|
|
|
|
|
// ADSR Envelope
|
|
env = EnvGen.kr(Env.adsr(0.0, 0.3, 0.3, 0.1), gate, doneAction: 2);
|
|
|
|
// Panning and Mixing
|
|
sig1 = Pan2.ar(filt1 * env * amp, -0.3);
|
|
sig2 = Pan2.ar(filt2 * env * amp, 0.3);
|
|
sig3 = Pan2.ar(filt3 * env * amp, 0);
|
|
|
|
mix = sig1 + sig2; // Mix main signals
|
|
// mix = mix + (noise * env * noiseLevel); // Add noise with envelope control
|
|
|
|
// mix = DelayC.ar(mix, maxdelaytime: 0.2, delaytime: 0.3);
|
|
|
|
// Output
|
|
Out.ar(0, mix);
|
|
}).add;
|
|
)
|
|
|
|
|
|
(
|
|
// Test pattern
|
|
|
|
Pbind(
|
|
\instrument, \rhubarb,
|
|
/*\degree, Pseq([
|
|
[2, 4, 7, 12], [1, 5, 9], [4, 7, 11], [5, 9, 8]
|
|
], inf), // Chord progression*/
|
|
\degree, Pseq([[2, 7, 11], [1, 5, 9], [3, 9], [1,3,5]], inf),
|
|
// \degree, Pseq([2, 4, 11,], inf),
|
|
// \dur, 0.5, // Duration of each chord
|
|
\amp, 0.08, // Volume
|
|
// \cutoff, 1200,
|
|
\detune, 0, // Slight detune
|
|
\pan, Pwhite(-0.3, 0.3), // Random stereo width
|
|
).play;
|
|
)
|
|
|
|
|
|
(
|
|
|
|
~notes = Array.newClear(128);
|
|
|
|
// MIDI
|
|
|
|
MIDIdef.noteOn(\noteOnTest, {
|
|
arg vel, nn, chan, src;
|
|
[vel, nn].postln;
|
|
~notes[nn] = Synth.new(
|
|
\mellotronFlute,
|
|
[
|
|
\freq, nn.midicps,
|
|
\amp, vel.linexp(1,127,0.01,0.3),
|
|
\gate, 1,
|
|
]
|
|
);
|
|
});
|
|
|
|
MIDIdef.noteOff(\noteOffTest, {
|
|
arg vel, nn;
|
|
[vel, nn].postln;
|
|
~notes[nn].set(\gate, 0);
|
|
~notes[nn] = nil;
|
|
});
|
|
) |