From 90b4ca66b5d34e429fa5d502e3bf9e459c4c4e30 Mon Sep 17 00:00:00 2001 From: Leo Coogan Date: Tue, 8 Apr 2025 01:45:36 -0400 Subject: [PATCH] successgit status --- dubecho.scd | 24 ++++++ padsynth practice EF-edit.scd | 42 ++++++--- padsynth practice.scd | 156 ++++++++++++++++++++++++++++++---- saw pad.scd | 76 +++++++++++++++++ 4 files changed, 267 insertions(+), 31 deletions(-) create mode 100644 dubecho.scd create mode 100644 saw pad.scd diff --git a/dubecho.scd b/dubecho.scd new file mode 100644 index 0000000..489fb26 --- /dev/null +++ b/dubecho.scd @@ -0,0 +1,24 @@ +( +SynthDef(\dubecho,{|length = 1, fb = 0.8, sep = 0.012| +var input = In.ar(0, 2); +var output = input + Fb({ + +arg feedback; // this will contain the delayed output from the Fb unit + +var left,right; +var magic = LeakDC.ar(feedback*fb + input); +magic = HPF.ar(magic, 400); // filter's on the feedback path +magic = LPF.ar(magic, 5000); +magic = magic.tanh; // and some more non-linearity in the form of distortion +#left, right = magic; // let's have named variables for the left and right channels +magic = [DelayC.ar(left, 1, LFNoise2.ar(12).range(0,sep)), DelayC.ar(right, 1, LFNoise2.ar(12).range(sep,0))]; // In addition to the main delay handled by the feedback quark, this adds separately modulated delays to the left and right channels, which with a small "sep" value creates a bit of spatialization + +},length); +ReplaceOut.ar(0, output); +}).store; +) + +// Example Usage +~echo = Synth(\dubecho, [\length, TempoClock.default.tempo*(3/8), \fb, 0.1, \sep, 0.0014], addAction: \addToTail); +~echo.free; +~echo.set(\gate, 0); diff --git a/padsynth practice EF-edit.scd b/padsynth practice EF-edit.scd index 0f83d62..574248f 100644 --- a/padsynth practice EF-edit.scd +++ b/padsynth practice EF-edit.scd @@ -6,40 +6,42 @@ 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| + |freq = 440, gate = 1, cutoff = 1e4, rq = 0.3, amp = 0.05, modDepth = 0.3, modDepth2 = 0.5, noiseLevel = 0.8, ringFreq = 80, detune = 0| 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 + osc1 = LFTri.ar(freq + detune); + osc2 = Pulse.ar(freq + detune); + // osc1 = LFTri.ar((freq + detune) * 1); + // osc2 = Pulse.ar((freq + detune)* 0.5); 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); + lfo = LFNoise2.kr(20).range(1 - modDepth, 1 + modDepth); + lfo2 = LFNoise2.kr(1).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); + filt2 = RLPF.ar(osc2, cutoff * lfo, rq); + filt3 = RLPF.ar(osc3, cutoff * lfo2, rq); // ADSR Envelope - env = EnvGen.kr(Env.adsr(0.0, 0.3, 0.3, 0.1), gate, doneAction: 2); + env = EnvGen.kr(Env.adsr(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 + // sig2 = GVerb.ar(sig2, 299, 4); // 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); + Out.ar(0, sig2!2); }).add; ) @@ -59,7 +61,7 @@ Pbind( // \dur, 0.5, // Duration of each chord \amp, 0.08, // Volume // \cutoff, 1200, - \detune, 0, // Slight detune + \detune, -2, // Slight detune \pan, Pwhite(-0.3, 0.3), // Random stereo width ).play; ) @@ -75,21 +77,33 @@ Pbind( MIDIdef.noteOn(\noteOnTest, { arg vel, nn, chan, src; - [vel, nn].postln; + // [vel, nn].postln; ~notes[nn] = Synth.new( \rhubarb, [ \freq, nn.midicps, \amp, vel.linexp(1,127,0.01,0.3), \gate, 1, + \detune, 2, + \cutoff, 400, + \rq, 0.5, ] ); }); MIDIdef.noteOff(\noteOffTest, { arg vel, nn; - [vel, nn].postln; + // [vel, nn].postln; ~notes[nn].set(\gate, 0); ~notes[nn] = nil; }); -) \ No newline at end of file +) + + + + + + + + + diff --git a/padsynth practice.scd b/padsynth practice.scd index cfb0f6d..7511558 100644 --- a/padsynth practice.scd +++ b/padsynth practice.scd @@ -4,16 +4,16 @@ 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| + |freq = 440, gate = 1, cutoff = 1e4, rq = 0.3, amp = 0.3, modDepth = 0.3, modDepth2 = 0.5, noiseLevel = 0.8, ringFreq = 80, detune = 0| 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 + osc1 = SinOsc.ar(freq + detune); + osc2 = SinOsc.ar(freq + detune * 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); + lfo = LFDNoise3.kr(4).range(1 - modDepth, 1 + modDepth); lfo2 = LFNoise2.kr(4).range(1 - modDepth, 1 + modDepth); // lfo2 = noise; @@ -24,7 +24,7 @@ SynthDef(\rhubarb, { // ADSR Envelope - env = EnvGen.kr(Env.adsr(0.0, 0.3, 0.3, 0.1), gate, doneAction: 2); + env = EnvGen.kr(Env.adsr(1, 3, 0.3, 0.1), gate, doneAction: 2); // Panning and Mixing sig1 = Pan2.ar(filt1 * env * amp, -0.3); @@ -32,6 +32,8 @@ SynthDef(\rhubarb, { sig3 = Pan2.ar(filt3 * env * amp, 0); mix = sig1 + sig2; // Mix main signals + + // mix = mix.blend(GVerb.ar(mix.sum, 299, 4), 0.15); // mix = mix + (noise * env * noiseLevel); // Add noise with envelope control // mix = DelayC.ar(mix, maxdelaytime: 0.2, delaytime: 0.3); @@ -41,26 +43,77 @@ SynthDef(\rhubarb, { }).add; ) +( +SynthDef(\rhubarb, { + |freq = 440, gate = 1, cutoff = 1e4, rq = 0.3, amp = 0.1, modDepth = 0.3, modDepth2 = 0.5, noiseLevel = 0.8, ringFreq = 80, detune = 0| + var env, osc1, osc2, osc3, filt1, filt2, filt3, lfo, lfo2, noise, noiseFilt, sig1, sig2, sig3, mix, chorus, chorusDepth = 20, chorusRate = 80, chorusedSignal; + + // Slightly Different Oscillators + osc1 = SinOsc.ar(freq + detune); + osc2 = SinOsc.ar(freq + detune * 0.5); // Slight detune for variation + osc3 = SawDPW.ar(freq * 2); + + // LFO to Modulate Filter Frequency + lfo = LFDNoise3.kr(4).range(1 - modDepth, 1 + modDepth); + lfo2 = LFNoise2.kr(4).range(1 - modDepth, 1 + modDepth); + + // 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 + + // Chorusing effect using CombN (no delay added, just detuned voices) + chorusDepth = LFDNoise3.kr(0.2).range(0.01, 0.05); // Depth of modulation + chorusRate = LFDNoise3.kr(0.2).range(0.1, 0.3); // Rate of modulation + + // Apply CombN for chorusing + chorusedSignal = CombN.ar(mix, maxdelaytime: 0.01, decaytime: chorusDepth, feedback: chorusRate); + + // Output + Out.ar(0, chorusedSignal); // Send the chorused signal to the output +}).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, 7, 12], [1, 5, 9], [4, 7, 11], [5, 9, 8], + // [2, 7, 11], [1, 5, 9], [3, 9], [1,3,5] + ], inf), // Chord progression + // \degree, Pseq([], inf), // \degree, Pseq([2, 4, 11,], inf), - // \dur, 0.5, // Duration of each chord - \amp, 0.08, // Volume - // \cutoff, 1200, - \detune, 0, // Slight detune + \dur, 4, // Duration of each chord + \amp, 0.06, // Volume + \cutoff, 1200, + \rq, 0.6, + \detune, Pseq([4.1, 4], inf), // Slight detune \pan, Pwhite(-0.3, 0.3), // Random stereo width ).play; ) +( +MIDIClient.init; +MIDIIn.connectAll; +) + + ( ~notes = Array.newClear(128); @@ -69,21 +122,90 @@ Pbind( MIDIdef.noteOn(\noteOnTest, { arg vel, nn, chan, src; - [vel, nn].postln; + // [vel, nn].postln; ~notes[nn] = Synth.new( - \mellotronFlute, + \rhubarb, [ \freq, nn.midicps, \amp, vel.linexp(1,127,0.01,0.3), \gate, 1, + + + // \instrument, \rhubarb, + // \degree, Pseq([], inf), + // \degree, Pseq([2, 4, 11,], inf), + \dur, 2 , // Duration of each chord + \amp, 0.06, // Volume + \cutoff, 800, + \rq, 0.2, + \detune, Pseq([4.1, 4], inf), // Slight detune + \pan, Pwhite(-0.3, 0.3), // Random stereo width ] ); }); MIDIdef.noteOff(\noteOffTest, { arg vel, nn; - [vel, nn].postln; + // [vel, nn].postln; ~notes[nn].set(\gate, 0); ~notes[nn] = nil; }); -) \ No newline at end of file +) + + + + + +( +~notes = Array.newClear(128); + +// MIDI definitions +MIDIdef.noteOn(\noteOnTest, { + arg vel, nn, chan, src; + // [vel, nn].postln; // Uncomment to debug + + // Create the first instrument (rhubarb) + ~notes[nn] = Synth.new( + \rhubarb, + [ + \freq, nn.midicps, + \amp, vel.linexp(1, 127, 0.01, 0.3), + \gate, 1, + \dur, 2, // Duration of each chord + \amp, 0.06, // Volume + \cutoff, 800, + \rq, 0.8, + \detune, Pseq([4.1, 4], inf), // Slight detune + \pan, Pwhite(-0.3, 0.3), // Random stereo width + ] + ); + + // Create the second instrument (rhubarb2) with the same parameters + ~notes[nn] = Synth.new( + \rhubarb2, + [ + \freq, nn.midicps, + \amp, vel.linexp(1, 127, 0.01, 0.3), + \gate, 1, + \dur, 2, // Duration of each chord + \amp, 0.06, // Volume + \cutoff, 400, + \rq, 0.1, + \detune, Pseq([4.1, 4], inf), // Slight detune + \pan, Pwhite(-0.3, 0.3), // Random stereo width + ] + ); +}); + +MIDIdef.noteOff(\noteOffTest, { + arg vel, nn; + // [vel, nn].postln; // Uncomment to debug + + // Stop both instruments + ~notes[nn].set(\gate, 0); + ~notes[nn] = nil; + + // For the second instrument (rhubarb2), clear the reference as well + ~notes[nn] = nil; +}); +) diff --git a/saw pad.scd b/saw pad.scd new file mode 100644 index 0000000..a9fced1 --- /dev/null +++ b/saw pad.scd @@ -0,0 +1,76 @@ +( +SynthDef(\pad, { + arg amp = 0.3, freq = 440, octave = 0, gate = 0; + var sig, osc1, osc2, env, lfo, noise; + + freq = freq * (2 ** octave); + + osc1 = LFSaw.ar(freq + 1.01) * 2; + osc2 = SawDPW.ar(freq + 0.99) * 3; + noise = WhiteNoise.ar(2); + + lfo = SinOsc.kr(3.1).range(0.5, 1.5); + + sig = osc1 + osc2; + sig = RLPF.ar(sig, 800 * lfo); + // sig = BPF.ar(sig, 40 * lfo, 0.8); + + env = EnvGen.ar(Env.adsr(attackTime: 0.3, decayTime: 0.5, sustainLevel: 0.2, releaseTime: 0.05), gate, doneAction: 2); + // env = EnvGen.kr(Env.adsr(0.2, 3, 1, 1), gate, doneAction: 2); + + // sig = CombL.ar(sig, 0.2, 0.2, 1.0); + // sig = DiodeRingMod.ar(sig); + + // sig = sig.blend(GVerb.ar(sig, 299, 4), 0.15); + // sig = sig.blend(GVerb.ar(sig.sum, 299, 4), 0.15); + + sig = CombL.ar(sig, 0.5, 1/[36.7, 37.3], 1, 0.2); + + // sig = sig.blend(PF.ar(sig, 1500, 0.5), 0.9); + + // Ideas + // chorusing (through J Concepts arrays), reverb, spatialization, distortion. See: Presence by Basic Channel + // dub echo + // band pan -- what was that AFX demo rack effect? + // multi-band strum + + sig = sig!2 * amp * env; + + Out.ar(0, sig); +}).add; +) + +x = Synth(\pad, [\freq, 60.midicps]); + + +MIDIClient.init; +MIDIIn.connectAll; + + +( + +~notes = Array.newClear(128); + +// MIDI + +MIDIdef.noteOn(\noteOnTest, { + arg vel, nn, chan, src; + // [vel, nn].postln; + ~notes[nn] = Synth.new( + \pad, + [ + \freq, nn.midicps, + \amp, vel.linexp(1,127,0.01,0.3), + \gate, 1, + \octave, 0 + ] + ); +}); + +MIDIdef.noteOff(\noteOffTest, { + arg vel, nn; + // [vel, nn].postln; + ~notes[nn].set(\gate, 0); + ~notes[nn] = nil; +}); +)