0

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?

David
  • 15,750
  • 22
  • 90
  • 150

1 Answers1

2

In your code, you don't instantiate the effects synth, therefore no sound goes to the output bus.

Dan Stowell
  • 4,618
  • 2
  • 20
  • 30
  • How do I instantiate it? – David Aug 08 '13 at 11:44
  • I instantiated the synth using `e = Synth(\effects);` after its `SynthDef`. – David Aug 08 '13 at 19:31
  • It does, peculiarly, seem to matter *how* I execute the code. I've asked another question about it here: http://stackoverflow.com/questions/18134636/why-does-it-matter-how-i-execute-this-code. – David Aug 08 '13 at 19:38