Two patterns in parralel manipulating the same synth?

Hello!
I would like to have a single Synth, which is manipulated by different Patterns. What would be the smartest way to do so?
Lets say I let 2 patterns (Pmono) run in parrallel, which change the pitch in a different manner and i want to select between them, then i could do this example:

(
SynthDef(\testme, {
	arg t_gate = 1;
	var e   = EnvGen.kr(Env.adr(),t_gate);
	var sig = SinOsc.ar(\freq.kr(440))!2;
	Out.ar(\bus.kr(0),sig*e*\amp.kr(1));
}).add;
)
(
~select = 0;
~a = Pmono(\testme,
	\degree,Pseq([0,1,2,3],inf),
	\gate, Pfunc{1-~select}
).play;
~b = Pmono(\testme,
	\degree,Pseq([0,-1,-2,-3],inf),
	\gate, Pfunc{~select}
).play;
)
~select = 1;
~select = 0;
~select = 1;
~select = 0;
~a.stop; ~b.stop;

However in this way, each of the Pmonos will run a Synth, and therefore i have 2 synths running, even though i would only need one.

I could theoretically also just run a synth like this:

(
~synth = Synth(\testme, [\t_gate,0]);
Pbind(
	\freq, Pseq([60,62,64,65],inf).midicps,
	\t_gate, 1,
	\amp, 0.2,
	\setter, Pfunc{|e| e.collect{|v,k|~synth.set(k,v)}},
	\amp, 0,
).play
)

Latter would solve kinda-ish my problem, but in a not so beautiful way. Because I need to use the \freq key and cannot use the \degree key. Also a synth is played from Pbind, which im Muting.

Is there a good solution for the problem that when i have a Synth playing, that multiple patterns could change it (they are rested)?

Thank you very much!

See the \set event type. Pattern Guide 08: Event Types and Parameters | SuperCollider 3.12.2 Help discusses it (page down a bit). Of the two ways to affect parameters, I think the argument list is easier.

hjh

1 Like

You could check out PmonoPar and PpolyPar from miSCellaneous_lib. PmonoPar addresses the task of several patterns setting one synth and PpolyPar that of several patterns setting several synths.

1 Like

Thank you very much, with this \set arg i could resolve the problem quite well!

For the archives and if anybody else wondering / is looking for the solution, i give here an example snipplet:


(
SynthDef(\testme, {
	arg t_gate = 1;
	var e   = EnvGen.kr(Env.adr(),t_gate);
	var sig = SinOsc.ar(\freq.kr(440))!2;
	Out.ar(\bus.kr(0),sig*e*\amp.kr(1));
}).add;
)
(
~s = Synth(\testme,[\gate,0]);
Pbind(
	\type, \set,
	\id, ~s,
	\instrument, \testme,
	\gate, 1,
	\degree, Pseq([0,12,24],inf),
	\amp, Pseq([0.1,0.4,0.1],inf),
	\dur, 0.5,
	\args, #[],
).play(quant:0);
Pbind(
	\type, \set,
	\id, ~s,
	\instrument, \testme,
	\gate, 1,
	\degree, Pseq([0,12,24],inf),
	\dur, 0.5/3,
	\args, #[],
).play(quant:0);
)
1 Like