From a83b8be362b44729d595ea3926d77e5d4acfd6ca Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Mon, 24 Apr 2023 16:49:36 +1000 Subject: [PATCH] Separated input from output effects --- control.scd | 37 +++++++++++++++++++++++++++++++------ effects.scd | 42 ++++++++---------------------------------- granulator.scd | 7 +++++-- main.scd | 10 +++++----- 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/control.scd b/control.scd index f130326..b0a62af 100644 --- a/control.scd +++ b/control.scd @@ -1,11 +1,10 @@ ( -// audio buses and other control stuff -// recordb = input to bufrecorder +//input mixing, effects and lfos - -~recordb = Bus.audio(s, 1); +~inputb = Bus.audio(s, 1); +~infxb = Bus.audio(s, 1); ~inmixer = SynthDef( \input_null, @@ -13,9 +12,8 @@ arg in1 = 2, in2 = 3, out = 4; Out.ar(out, In.ar(in1) + In.ar(in2)); } -).play(s, [\in1, ~usbinput1, \in2, ~usbinput2, \out, ~recordb]); +).play(s, [\in1, ~usbinput1, \in2, ~usbinput2, \out, ~inputb]); -~grb = Bus.audio(s, 2); // LFO buses and synths @@ -29,4 +27,31 @@ "LFOs running".postln; +// filter is now before grains + +~filtermodb = Bus.control(s, 1); + +~filtermod = SynthDef( + \filtermod, { + arg out, a = 1.0, b = 0.0, c = 0.0; + var siga, sigb, sigc; + siga = In.kr(~lfoab) * a; + sigb = In.kr(~lfobb) * b; + sigc = In.kr(~lfocb) * c; + Out.kr(out, Wrap.kr(siga + sigb + sigc, -1, 1)); + } +).play(s, [\out, ~filtermodb, \a, 1, \b, 0, \c, 0 ]); + + +~filter = SynthDef( + \filter, { + arg in, out, mod, freq=10000, res=0.3, amp=1.0; + var filt, lfo; + lfo = LinExp.kr(In.kr(mod, 1), -1, 1, freq * 0.5, freq * 2); + filt = RLPF.ar(In.ar(in, 2) * amp, lfo, res); + Out.ar(out, filt); + } +).play(s, [ \in, ~inputb, \out, ~infxb, \mod, ~filtermodb, \amp, 0.5], \addToTail); + + ) diff --git a/effects.scd b/effects.scd index 55a242c..9ddcfed 100644 --- a/effects.scd +++ b/effects.scd @@ -1,11 +1,10 @@ +// this is just output effects now ( -// output effects mixing and effects -~fxb = Bus.audio(s, 2); -~filterb = Bus.audio(s, 2); -~grainsb = Bus.audio(s, 2); + +~outfxb = Bus.audio(s, 2); ~delayb = Bus.audio(s, 2); ~reverbb = Bus.audio(s, 2); @@ -14,36 +13,10 @@ ~grainmixer = SynthDef( \grain_mixer, { - arg in=2, gbus=4, out=0, passthrough=0.75, grains=0.75; - Out.ar(out, (grains * In.ar(gbus, 2)) + (passthrough * In.ar(~recordb, 1) ! 2)); + arg in=2, grainb=4, out=0, passthrough=0.75, grains=1; + Out.ar(out, (grains * In.ar(grainb, 2)) + (passthrough * In.ar(in, 1) ! 2)); } -).play(s, [\in, ~usbinput, \gbus, ~grb, \out, ~fxb ], \addToTail); - -~filtermodb = Bus.control(s, 1); - -~filtermod = SynthDef( - \filtermod, { - arg out, a = 1.0, b = 0.0, c = 0.0; - var siga, sigb, sigc; - siga = In.kr(~lfoab) * a; - sigb = In.kr(~lfobb) * b; - sigc = In.kr(~lfocb) * c; - Out.kr(out, Wrap.kr(siga + sigb + sigc, -1, 1)); - } -).play(s, [\out, ~filtermodb, \a, 1, \b, 0, \c, 0 ]); - - -~filter = SynthDef( - \filter, { - arg in, out, mod, freq=10000, res=0.3, amp=1.0; - var filt, lfo; - lfo = LinExp.kr(In.kr(mod, 1), -1, 1, freq * 0.5, freq * 2); - filt = RLPF.ar(In.ar(in, 2) * amp, lfo, res); - Out.ar(out, filt); - } -).play(s, [ \in, ~fxb, \out, ~filterb, \mod, ~filtermodb, \amp, 0.5 ], \addToTail); - - +).play(s, [\in, ~infxb, \grainb, ~grainsb, \out, ~outfxb ], \addToTail); @@ -58,7 +31,7 @@ del = CombC.ar(sig, maxdelay, delaytime, decaytime, amp); Out.ar(out, sig + del); } - ).play(s, [ \in, ~filterb, \out, ~delayb ], \addToTail); + ).play(s, [ \in, ~outfxb, \out, ~delayb ], \addToTail); // try taking out the reverb because I think it causes noises @@ -72,3 +45,4 @@ "Effects running".postln; ) + diff --git a/granulator.scd b/granulator.scd index 7326b64..f10d263 100644 --- a/granulator.scd +++ b/granulator.scd @@ -8,6 +8,8 @@ [ "random", \pos_random ] ]; +~grainsb = Bus.audio(s, 2); + ~granulators = Array.new(4); ~posb = Array.new(4); ~possynths = Array.new(4); @@ -22,7 +24,7 @@ (0..3).do({ |i| var pb = ~posb.at(i); - ~granulators.add(Granulator.new(~buflen, ~recordb, ~fxb, pb, ~triggerb, ~pitchb)); + ~granulators.add(Granulator.new(~buflen, ~infxb, ~grainsb, pb, ~triggerb, ~pitchb)); }); ~setmode = { @@ -37,4 +39,5 @@ "Granulator running".postln; -) \ No newline at end of file +) + diff --git a/main.scd b/main.scd index 79ea333..47661a5 100644 --- a/main.scd +++ b/main.scd @@ -12,16 +12,16 @@ Routine.run({ ("./synths.scd").loadRelative; Granulator.init(s); - s.sync; - - "Synths loaded".postln; - ("./control.scd").loadRelative; - ("./effects.scd").loadRelative; + s.sync; ("./granulator.scd").loadRelative; s.sync; + ("./effects.scd").loadRelative; + s.sync; ("./interface.scd").loadRelative; }); ) + +