Setting up Audio Channels using Routines?

Hello all,

I am recently trying to switch over from using Patterns to using Routines to generate music with a PlayBuf SynthDef. While I was using Patterns, I created a Channel mixer that fed audio to a Master output.

Please see below:

Setting up audio buses and grouping:

	~sources = Group.head;
	~mixer = Group.tail;

	~patch1 =, 2);
	~patch2 =, 2);
	~patch3 =, 2);
	~channel1 = Group.tail(~mixer);
	~channel2 = Group.tail(~mixer);
	~channel3 = Group.tail(~mixer);

	~patch5 =, 2);
	~master1 = Group.tail(~mixer);

SynthDefs for my buffer sampler and Channels. I am using the patch argument to route the audio to different channels and then all of the channels get outputted through the Master channel.

	//MAINBUF\mainbuf, {
		arg amp=1, pan=0, rate=1, pos=0, bank, atk=0.01, rel=1, loop=1, gate=1, fader=1, patch=22, bufrate=44100, smoothing=0.5;
		var sig, env, z;
		env =, rel), gate, doneAction: 2);
		sig =, bank, * rate, 1, pos, loop) * env;
		sig =, pan);
		sig =, sig * amp * fader);

	~channel1 = (
		SynthDef(\ch1mix, {
			arg moogcut=21000, gain=0, highcut=22, lowcut=22, fader=1, crossfader=1, maxdelaytime=0.2, delaytime=0.2, decaytime=1.0, mul=1, pitchRatio=1, pitchDispersion=0, timeDispersion=0;
			var sig;
			sig =, 2);
			sig =, moogcut, gain);
			sig =, maxdelaytime, delaytime, decaytime, mul);
			sig =, highcut);
			sig =, delaytime, pitchRatio, pitchDispersion, timeDispersion);
			sig =, sig * fader * crossfader);
	~master1 = (
		SynthDef(\mastermix, {
			arg moogcut=29000, gain=0, highcut=22, masterfader=1, mix=0.33, room=0.5, damp=0.5, delaytime=0, pitchRatio=1, pitchDispersion=0, fader=1;
			var sig;
			sig =, 2);
			sig =,mix,room,damp);
			sig =, delaytime, pitchRatio, pitchDispersion);
			sig =;
			sig =;
			sig =, sig * masterfader * fader);

This is working as expected with Patterns. If I run a pdef like this, I can route the audio based on the patch to specific channels and then the target would be ~sources.

		Pdef(\a10, Pbind(
			\instrument, \mainbuf, \group, ~sources,
			\patch, ~patch1,
			\amp, 1,
			\dur, 1/4,
			\atk, 0.1,
			\rel, 0.1,
			\rate, 1,
			\pos, 1,
			\bank, 1,
	Pdef(\a10).play(t, quant:4);

Here is the node tree:

My question is, how can I get this set up using Routines?

I am using the same audio buses / grouping and SynthDefs, however, when I try to apply the arguments / target using a Synth, I am not hearing any audio:

The Synth that is being created within the Routine.

							// Create the synth and wait for the tatum duration
							s.makeBundle(s.latency, {
								synth = Synth(\mainbuf, [
									patch: ~patch1,
									buffer: currentBuffer,
									rate: currentRate,
									rel: rel,
									mainbuf: mainbuf,
									amp: 0.6,
								], ~sources);
							s.makeBundle (s.latency, {
								synth.set(\gate, 0);

Am I missing something here? Does this look set up correctly?

Thank you for your time!

Apologies, I got this working after writing everything out. Typo on my end. The code is working as expected.

1 Like