From 0b589bc0928ea738844c9bf44a3bf86bd8d07c25 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 9 Apr 2023 11:42:17 +1000 Subject: [PATCH] Effects into separate files --- effects.scd | 73 +++++++++++++++++++++++++++++++++++++++++++++++ input_effects.scd | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 effects.scd create mode 100644 input_effects.scd diff --git a/effects.scd b/effects.scd new file mode 100644 index 0000000..85508cc --- /dev/null +++ b/effects.scd @@ -0,0 +1,73 @@ + + +( +// output effects mixing and effects + +~fxb = Bus.audio(s, 2); +~filterb = Bus.audio(s, 2); +~grainsb = Bus.audio(s, 2); +~delayb = Bus.audio(s, 2); +~reverbb = Bus.audio(s, 2); + + + +~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)); + } +).play(s, [\in, ~usbinput, \gbus, ~granulatorb, \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); + + + + + + +// delay always passes through 100% of its input + amp % of the delay + + +~delay = SynthDef( + \delay, { + arg in, out, maxdelay=1, delaytime=0.2, decaytime=0.1, amp=0.5; + var sig = In.ar(in, 2), del; + del = CombC.ar(sig, maxdelay, delaytime, decaytime, amp); + Out.ar(out, sig + del); + } + ).play(s, [ \in, ~filterb, \out, ~delayb ], \addToTail); + +// try taking out the reverb because I think it causes noises + + ~reverb = SynthDef( + \reverb, { + arg in, out, mix=0.33, room=0.5, damp=0.5, amp=0.25; + var input = In.ar(in, 2); + Out.ar(out, input + FreeVerb2.ar(input[0], input[1], mix, room, damp, amp)); + } + ).play(s, [ \in, ~delayb, \out, 0 ], \addToTail); + +) diff --git a/input_effects.scd b/input_effects.scd new file mode 100644 index 0000000..dcadd80 --- /dev/null +++ b/input_effects.scd @@ -0,0 +1,53 @@ +( + +~fuzzbox = SynthDef( + \fuzzbox, + { + arg in=2, out=4, distort=0.1, decay=0.999; + var raw, cross, pf; + raw = In.ar(in, 1).softclip; + cross = CrossoverDistortion.ar(raw, 0.5, 0.5); + pf = PeakFollower.ar(raw, decay); + Out.ar(out, ((1 - distort) * raw) + (distort * pf * cross)); + } +).play(s, [\in, ~usbinput, \out, ~recordb, \distort, 0 ]); + +// ~decimator = SynthDef( +// \decimator, +// { +// arg in=2, out=4, modb, rate=10000, smooth=0.5; +// var raw, mod, decimated; +// raw = In.ar(in, 1); +// mod = In.kr (modb, 1); +// decimated = SmoothDecimator.ar(raw, rate + (0.2 * rate * mod), smooth); +// Out.ar(out, decimated); +// } +// ).play(s, [\in, ~usbinput, \out, ~recordb, \modb, ~lfob, \rate, 10000 ]); +// + +// ~localmax = SynthDef( +// \localmax, +// { +// arg in=2, out=4, threshold=25; +// var chain; +// chain = FFT(LocalBuf(2048), In.ar(in, 1).distort); +// chain = PV_LocalMax(chain, threshold); +// Out.ar(out, IFFT.ar(chain)); +// } +// ).play(s, [\in, ~usbinput, \out, ~recordb, \threshold, 25 ]); +// + +// ~scramble = SynthDef( +// \scramble, +// { +// arg in=2, out=4, shift=1; +// var chain; +// chain = FFT(LocalBuf(2048), In.ar(in, 1).distort); +// chain = PV_BinScramble(chain, 0.5, 0.2, Impulse.kr(shift)); +// Out.ar(out, IFFT.ar(chain)); +// } +// ).play(s, [\in, ~usbinput, \out, ~recordb, \shift, 1 ]); +// + + +) \ No newline at end of file