Last active
April 25, 2025 01:34
-
-
Save catfact/b81d4bb87a4ab6f697299c7f3246b0e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FxBusDemo2 { | |
var <synths; | |
var <busses; | |
var <g; | |
*new { arg server; | |
^super.new.init(server); | |
} | |
init { arg server; | |
synths = Dictionary.new; | |
busses = Dictionary.new; | |
Routine { | |
// in this demo, source bus is mono / fx are stereo | |
busses[\source] = Bus.audio(server, 1); | |
busses[\main_out] = Bus.audio(server, 2); | |
busses[\reverb_send] = Bus.audio(server, 2); | |
busses[\delay_send] = Bus.audio(server, 2); | |
SynthDef.new(\patch_pan, { | |
arg in, out, level=1, pan=0; | |
Out.ar(out, Pan2.ar(In.ar(in), pan, level)); | |
}).send(server); | |
SynthDef.new(\patch_stereo, { | |
arg in, out, level=1; | |
Out.ar(out, In.ar(in, 2)*level); | |
}).send(server); | |
g = Group.new(server); | |
synths[\source] = SynthDef.new(\pblip, { | |
arg out, level=0.5, hz=330; | |
var snd = LPF.ar(Saw.ar(hz), hz*4); | |
snd = snd * LagUD.ar(Impulse.ar(2), 0, 0.5); | |
Out.ar(out, snd * level); | |
}).play(target:g, addAction:\addToTail, args:[ | |
\out, busses[\source] | |
]); | |
// why are we syncing here? two reasons: | |
// 1.so the common SynthDefs above are present on the server when requested | |
// 2. because the send synths below use \addToTail, | |
// we need the server to finish creating the source synth before they are added | |
server.sync; | |
synths[\dry] = Synth.new(\patch_pan, target:g, addAction:\addToTail, args:[ | |
\in, busses[\source], | |
\out, busses[\main_out], | |
\level, 1.0 | |
]); | |
synths[\delay_send] = Synth.new(\patch_pan, target:g, addAction:\addToTail, args:[ | |
\in, busses[\source], | |
\out, busses[\delay_send], | |
\level, 0.0, | |
\pan, 0.5 | |
]); | |
synths[\reverb_send] = Synth.new(\patch_pan, | |
target:g, addAction:\addToTail, args:[ | |
\in, busses[\source], | |
\out, busses[\reverb_send], | |
\level, 0.0, | |
\pan, -0.5 | |
]); | |
synths[\delay] = SynthDef.new(\delay, { | |
arg in, out, level=1; | |
Out.ar(out, DelayC.ar(In.ar(in, 2), 1.0, 0.2, level)); | |
}).play(target:g, addAction:\addToTail, args:[ | |
\in, busses[\delay_send], \out, busses[\main_out] | |
]); | |
synths[\reverb] = SynthDef.new(\reverb, { | |
arg in, out, level=1; | |
Out.ar(out, level*FreeVerb.ar(In.ar(in, 2), 1.0, 0.9, 0.1, level)); | |
}).play(target:g, addAction:\addToTail, args:[ | |
\in, busses[\reverb_send], \out, busses[\main_out] | |
]); | |
// again, we want the next synth to really be added after all others | |
server.sync; | |
synths[\main_out] = Synth.new(\patch_stereo, | |
target:g, addAction:\addToTail, args: [ | |
\in, busses[\main_out], \out, 0 | |
]); | |
}.play; | |
} | |
setLevel { arg key, val; | |
synths[key].set(\level, val); | |
} | |
free { | |
g.free; | |
busses.do({arg bus; bus.free;}); | |
} | |
} | |
/* | |
f = FxBusDemo2.new(s); | |
s.queryAllNodes; | |
f.busses[\source].scope; | |
f.setLevel(\delay_send, 0.6); | |
f.setLevel(\reverb_send, 0.6); | |
f.setLevel(\dry, 0.0); | |
f.free; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment