I'm trying to route a synth into another synth (to provide effects) via a bus. Here is my code:
b = Bus.audio(numChannels: 2);
SynthDef(
"mySynth",
{
|freq, amp, gate = 1|
var audio = Pulse.ar(freq, 0.5);
var env = EnvGen.kr(Env.perc, doneAction:2);
audio = Pan2.ar(audio, MouseX.kr(-1, 1));
Out.ar(b, audio * env);
}
).add;
SynthDef(
"effects",
{
var audio = In.ar(b, 2);
//TODO: Implement some crazy, revolutionary effects
Out.ar(0, audio);
}
).add;
p = Pbind(*[
instrument: \mySynth,
scale: #[0, 2, 4, 5, 7, 9, 11],
degree: Pseq([3, 3, 9, 9, 2, 9, 9, 3, 5, 7], inf),
dur: Pseq([0.2, 0.2, 0.2, 0.1, 0.1, 0.2, 0.2, 0.2, 0.1, 0.1], inf),
amp: Pseq([1, 0.6, 0.9, 0.3, 0.4, 0.9, 0.6, 0.85, 0.3, 0.4], inf),
]);
p.play;
The code doesn't error (the output window reads 'an EventStreamPlayer'). But I don't get any sound.
If I change the Out.ar
line in \mySynth
to use channel 0
instead of bus b
, then I do get sound, albeit without any routing to the effects synth. So I'm guessing the problem is to do with busses and/or ordering of processing. But I don't know how to fix it. Can anyone help?
In your code, you don't instantiate the effects
synth, therefore no sound goes to the output bus.