From 33e6cc729e65bcbc8bbbb048a8526635f4f3a8c9 Mon Sep 17 00:00:00 2001 From: Leo Coogan Date: Sun, 16 Mar 2025 02:42:04 -0400 Subject: [PATCH] first sounds --- 808.scd | 45 ++++++++++++ ambient synth pads.scd | 73 ++++++++++++++++++ chordsr.scd | 70 ++++++++++++++++++ granular test.scd | 19 +++++ padsynth practice.scd | 163 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 370 insertions(+) create mode 100644 808.scd create mode 100644 ambient synth pads.scd create mode 100644 chordsr.scd create mode 100644 granular test.scd create mode 100644 padsynth practice.scd diff --git a/808.scd b/808.scd new file mode 100644 index 0000000..d45014d --- /dev/null +++ b/808.scd @@ -0,0 +1,45 @@ +MIDIClient.init; +MIDIClient.sources.do; + +MIDIIn.connect(0); + +MIDIIn.connectAll; + +( +~sampleDir = PathName("~/snd/samples/808/").fullPath; + +~samples = ( + 42: Buffer.read(s, ~sampleDir +/+ "Cls'dHihat.wav"), + 46: Buffer.read(s, ~sampleDir +/+ "OpenHiHat.wav"), + 49: Buffer.read(s, ~sampleDir +/+ "CYmbal.wav"), + 56: Buffer.read(s, ~sampleDir +/+ "CowBell.wav"), + 39: Buffer.read(s, ~sampleDir +/+ "handClaP.wav"), + 37: Buffer.read(s, ~sampleDir +/+ "RimShot.wav"), + 50: Buffer.read(s, ~sampleDir +/+ "HiTom.wav"), + 47: Buffer.read(s, ~sampleDir +/+ "MidTom.wav"), + 43: Buffer.read(s, ~sampleDir +/+ "LowTom.wav"), + 38: Buffer.read(s, ~sampleDir +/+ "SnareDrum.wav"), + 36: Buffer.read(s, ~sampleDir +/+ "BassDrum.wav"), + 70: Buffer.read(s, ~sampleDir +/+ "MAracas.wav"), + 75: Buffer.read(s, ~sampleDir +/+ "CLaves.wav"), + 62: Buffer.read(s, ~sampleDir +/+ "HiConga.wav"), + 63: Buffer.read(s, ~sampleDir +/+ "MidConga.wav"), + 64: Buffer.read(s, ~sampleDir +/+ "LowConga.wav") +); +); + +~playSample = { |note| + var buf = ~sample[note]; + if (buf.notNil) { + Synth(\samplePlayer, [\buf, buf]); + }; +}; + +MIDIdef.noteOn(\tr08Trigger, { |vel, note, chan, src| + ~playSample.(note); +}); + + +MIDIdef.cc[\cc_debug, { |val, num, chan, src| + [num, val].postln; +}); \ No newline at end of file diff --git a/ambient synth pads.scd b/ambient synth pads.scd new file mode 100644 index 0000000..d14d07e --- /dev/null +++ b/ambient synth pads.scd @@ -0,0 +1,73 @@ +// been listening to a lot of vangelis/wendy carlos recently +// largely modified from the cs80_mh in synthdefpool + +( +var scale,fund; + +scale = [0,3,7]; + +fork{ + loop{ + var t = [16,32].choose; + fund = 26+[0,3,7,10,14].choose; + fund.postln; + t.wait; + }; +}; + +fork{ + loop{ + var t = 1/2; + var a,d,s,r,fa,fd,fs,fr,ratio,dtune,freq, + ffreq,vibrate,vibdepth,cutoff,amp; + freq = (scale.choose+fund+(12*(0..3).choose)).midicps; + vibrate = t/(1..10).choose; + vibdepth = (90..500).choose.reciprocal; + dtune = 1e-3; LFNoise0.kr(t,0.02,1); + cutoff = freq * (1.1,1.2..4).choose; + ratio = (0.99,0.991..1.01).choose; + amp = 1/3; + + a = 3.0.rand/t; + s = 3.0.rand/t; + r = 3.0.rand/t; + fa = 3.0.rand/t; + fs = 3.0.rand/t; + fr = 3.0.rand/t; + + play{ + var env, fenv, sig, gate, vib; + gate = Line.kr(1,0,t); + env = EnvGen.kr(Env.linen(a,s,r),doneAction:2); + fenv = EnvGen.kr(Env.linen(fa,fs,fr)); + freq = Line.kr(freq,freq*ratio,t); + vib = SinOsc.kr(vibrate).range(vibdepth.neg,vibdepth)+1; + freq = vib*freq; + //freq = freq.lag(t); + sig = Select.ar(2.rand,[ + Pulse.ar([freq,freq*(1+dtune),freq*(1-dtune)], + LFNoise2.kr(t,0.5,0.5), 0.1).sum, + Saw.ar([freq,freq*(1+dtune),freq*(1-dtune)]).sum + ]); + sig = sig.tanh * env; + ffreq = max(fenv*freq*12,cutoff)+100; + sig = MoogFF.ar(sig,ffreq,LFNoise2.kr(1/t,1.4,1.5)).tanh; + sig = RLPF.ar(sig,1e4,0.9).tanh; + Pan2.ar(sig*amp,LFNoise2.kr(t.rand)); + }; + t.wait; + }; + }; + +// this was inspired by http://sccode.org/1-4EG +// good way to get the reverb out of the loop... +// thanks rukano ;) +{ + var in = In.ar(0,2); + in = in * 0.25; + in = Compander.ar(in,in,0.75,1,0.75,0.1,0.4); + in = (in*0.2) + GVerb.ar(HPF.ar(in,100), 20, 20, mul:0.6).tanh; + in = Limiter.ar(LeakDC.ar(in)); + ReplaceOut.ar(0, in) +}.play(addAction:\addToTail); +) \ No newline at end of file diff --git a/chordsr.scd b/chordsr.scd new file mode 100644 index 0000000..bac7366 --- /dev/null +++ b/chordsr.scd @@ -0,0 +1,70 @@ +MIDIClient.init; +MIDIIn.connectAll; + +( +SynthDef(\rhubarb, { + |freq = 440, gate = 1, cutoff = 1000, rq = 0.3, amp = 0.05, modDepth = 0.3, noiseLevel = 0.05| + var env, osc, filt, lfo, noise, sig; + + // Single Sawtooth Oscillator + osc = SinOsc.ar(freq); + + // Subtle Noise Layer + // noise = PinkNoise.ar(noiseLevel); + + // LFO to Modulate Filter + lfo = LFNoise0.kr(4).range(1 - modDepth, 1 + modDepth); // Triangle LFO at 2.94 Hz + + // Low-pass filter modulated by LFO + filt = RLPF.ar(osc, cutoff * lfo, rq); + + // ADSR Envelope with Long Attack & Release + env = EnvGen.kr(Env.adsr(0.0, 0.3, 0.8, 2.0), gate, doneAction: 2); + + sig = Pan2.ar(filt * env * amp, 0); + + // Output + Out.ar(0, sig); +}).add; +) + + +( +~midiNotes = Dictionary.new; // Store active notes + +MIDIdef.noteOn(\rhubarb_on, { |vel, num, chan, src| + var freq = num.midicps; // Convert MIDI note to frequency + var amp = vel / 127; // Normalize velocity (0 to 1) + + // Create the synth and store it in a dictionary + ~midiNotes[num] = Synth(\rhubarb, [ + \freq, freq, + \amp, amp * 0.1, // Adjust for a reasonable volume + \cutoff, 1200 + ]); +}); + +MIDIdef.noteOff(\rhubarb_off, { |vel, num, chan, src| + ~midiNotes[num].set(\gate, 0); // Release the synth + ~midiNotes.remove(num); // Remove from dictionary +}); +) + + + +( +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), + \dur, 0.5, // Duration of each chord + \amp, 0.08, // Volume + \cutoff, 1200, + //\cutoff, Pseq([400, 600, 800]), // Filter cutoff frequency + \detune, 12, // Slight detune + \pan, Pwhite(-0.3, 0.3), // Random stereo width +).play; +) + diff --git a/granular test.scd b/granular test.scd new file mode 100644 index 0000000..745f6f5 --- /dev/null +++ b/granular test.scd @@ -0,0 +1,19 @@ +b = Buffer.read(s, "/home/lcoogan/snd/samples/church hill tunnel/owoah.wav"); +b.play; + +( +{ + var sig; + sig = GrainBuf.ar( + 1, + Impulse.ar(10), + 0.09, + b, + 1, + 0.2, + 2, + 0, + 512, + ); +}.play +) \ No newline at end of file diff --git a/padsynth practice.scd b/padsynth practice.scd new file mode 100644 index 0000000..62e1c92 --- /dev/null +++ b/padsynth practice.scd @@ -0,0 +1,163 @@ +( +SynthDef(\junoPad, { + arg gate=1, freq=220, atk=4, sus=2, rel=6, amp=0.3; + var sig, env, freqs, lfo, chorus, modRate, modDepth; + + // Slightly detuned saw waves + freqs = freq * [1, 1.01, 0.99]; // Small detune + sig = Mix(Saw.ar(freqs)); // Stack saw waves + + // LFO to slowly move filter cutoff + lfo = SinOsc.kr(0.1).range(500, 2000); + sig = RLPF.ar(sig, lfo, 0.3); // Low-pass filter with modulation + + // Envelope for smooth rise + env = EnvGen.kr(Env.asr(atk, 1, rel), gate, doneAction:2); + sig = sig * env * amp; + + // Chorus effect (emulates Juno-chorus) + modRate = [0.3, 0.4]; // Two different modulation rates + modDepth = 0.01; // Small pitch variation + chorus = sig + DelayC.ar(sig, 0.02, SinOsc.kr(modRate).range(0, modDepth)); + + // Reverb for space + // sig = FreeVerb.ar(chorus, mix: 0.5, room: 0.8, damp: 0.5); + + sig = sig * chorus; + + Out.ar(0, sig); +}).play; +) + + +( + +x = { + + var sig = WhiteNoise.ar(1!2); + + sig = CombL.ar(sig, 0.05, 1/[36.7, 37.3], 1, 0.2); + + sig = sig.blend(BPF.ar(sig, 1500, 0.5), 0.9); + +}.play(fadeTime: 2); + +) + + +x.release; + + +MIDIClient.init; +MIDIClient.sources.do; + + +( +SynthDef(\rhubarb, { + |freq = 440, gate = 1, cutoff = 1000, rq = 0.3, amp = 0.05, modDepth = 1, noiseLevel = 0.05| + var env, osc, filt, lfo, noise, sig; + + // Single Sawtooth Oscillator + osc = SinOsc.ar(freq); + osc2 = SinOsc.ar(freq); + + // Subtle Noise Layer + // noise = PinkNoise.ar(noiseLevel); + + // LFO to Modulate Filter + lfo = LFNoise0.kr(4).range(1 - modDepth, 1 + modDepth); // Triangle LFO at 2.94 Hz + + // Low-pass filter modulated by LFO + filt = SVF.ar(osc, cutoff * lfo, rq);u + filt2 = BMoog.ar(osc, freq * lfo, rq); + + // ADSR Envelope with Long Attack & Release + env = EnvGen.kr(Env.adsr(0.0, 0.3, 0.8, 2.0), gate, doneAction: 2); + + sig = Pan2.ar(filt * env * amp, 0); + sig2 = Pan2.ar(filt * env * amp, 0); + + // Output + Out.ar(0, sig); +}).add; +) + +( +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; + + +~synths = Dictionary.new; // Store active notes + +MIDIFunc.noteOn({ |vel, num, chan, src| + var freq = num.midicps; // Convert MIDI note to Hz + var amp = vel.linexp(1, 127, 0.05, 0.5); // Velocity mapping + + ~synths[num] = Synth(\rhubarb, [\freq, freq, \amp, amp]); // Store synth instance +}); +) + + + +( +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; +) + + +( +SynthDef(\pad, { + var sig; + + sig = Mix( + + Out.ar(0, sig); +}).play; +) + +