Is it possible to filter several pbinds with one single ‘control-pbind’ without duplicating the control-bind?
To exemplify:
// Two simple synthdefs, \a is panned left, \b is panned right
(
SynthDef(\a, {|freq = 220, gate = 1|
var sig = Pulse.ar(freq) * 0.2;
var env = Env.adsr.kr(2, gate);
Out.ar(0, Pan2.ar(sig, -1) * env)
}).add;
SynthDef(\b, {|freq = 220, gate = 1|
var sig = Saw.ar(freq) * 0.1;
var env = Env.adsr.kr(2, gate);
Out.ar(0, Pan2.ar(sig, 1) * env)
}).add
)
/// The below has the desired output except that the controlpb is running twice - see post window.
(
~controlpb = Pbind(
\dur, Pseq([0.5, 0.25, 0.5, 0.25], inf),
\midinote, Pseq([40, 52, 50, 54], inf),
\postWin, Pstep(Pfunc{"start of pattern".postln}, 2),
\atk, 0.1,
\rel, 0.1,
);
~a = Pbind(\instrument, \a);
~b = Pbind(\instrument, \b);
Pdef(\test, Ppar([
Pchain(~controlpb, ~a),
Pchain(~controlpb, ~b),
])).play;
)
/// I was hoping this would do the trick, but it does not work.
Pdef(\test, Pchain(~controlpb, Ppar([~a, ~b]))).play
Pdef(\test).stop
In the above case it doesn’t really matter that the controlpb is running twice but say you used the controlpb to update a counter or call a function without wanting it to be called more than once.