Multiple pdef plays

Currently I just enclose multiple Pdefs and play , and atm it seems that the overall timing sync of both Pdef is pretty o.k .
Playing a standard 4/4 kick (0.5sec=2hz ) against 16th notes (0.25sec , 4hz ) and no audible loss of sync
Much better compared to max scheduler
Anything I should be aware off ?

(
SynthDef(\twoop,
{
|fmamt=2,modoffset=24,moatt=0.001,modrel=0.500,ampatt=0.001,amprel=0.800,pitch=48,outt=0.3|
var mod,modenv,ampenv,carr;

		mod=SinOsc.ar((pitch+modoffset).midicps)*fmamt;
		modenv=EnvGen.ar(Env.perc(moatt,modrel),doneAction:0);
		ampenv=EnvGen.ar(Env.perc(ampatt,amprel),doneAction:2);
		carr=SinOsc.ar(pitch.midicps,(mod*modenv))*ampenv*outt!2;
		Out.ar(0,carr);
}).add
);
//////////

(
Pdef(
	\crt,
	Pbind(
		\instrument,
		\twoop,
		\pitch,Pseq([72,60,71,64,62,48,50,74,55,67,64],inf)-12,
		\dur,Pseq([0.25,  0.25,  0.5,  0.25,   0.25,   0.5],inf),
		\fmamt,Pseq([2,0.5,2,1,2,1,12,4],inf),
		\modrel,Prand([0.425,0.525,0.500,0.550,1,0.625,0.500,0.5,2.8],inf),
		\modoffset,Prand([-0.6,0.2,-12.2,0.3,0.6,0.3],inf),
	)
)
)
/////0.25,  0.25,  0.25,  0.25,  0.5,  0.25,  0.25,  0.12,  0.12,  0.5,  0.25,  0.50,  0.25,  0.25
(
SynthDef (\kick,
{
		arg pitch=50,patt=0.001,pdec=0.325,pcurve=(-50),pamt=100,att=0.001,dec=0.700,noisefreq=100,shamt=4,vol=0.3;
		var kick,penv,ampenv,noiseosc;
		penv=EnvGen.ar(Env([0,1,0],[patt,pdec],[0,pcurve]),doneAction:2);
		kick=SinOsc.ar(pitch+(penv*pamt))*0.9;
		noiseosc=LPF.ar(WhiteNoise.ar(0.1),noisefreq);
		kick=(noiseosc+kick)*EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]))!2;
		kick=SineShaper.ar(kick*shamt)*vol;
		Out.ar(0,kick);
}).add;
)
////////////
(
Pdef(\kik,
	Pbind(\instrument,\kick,
	\dur,Pseq([0.5,0.5],inf),
		\pitch,Pseq([40,42,39],inf),
		\pdec,0.8,
		\shamt,Pseq([4,2],inf),
		\vol,0.5,
))
)
///////////
(
Pdef(\crt).play;
Pdef(\kik).play;
)


(
Pdef(\crt).stop;
Pdef(\kik).stop;
)
1 Like

This is amazing , you can have multiple Pdefs for the same Synthdef , the spice is in the Pbinds for parameter automation .
I wrongfully assumed that there would be a parameter collision when multiple pdefs are targeted at the same synthdef .

I know I have an awfull lot to learn but at least I can now have fun having the absolute basics under my belt of creating synthdefs and Pdefs .
I haven’t touched my cirklon for the past 2 weeks , i think that says enough about how addicitve supercollider is :slight_smile:

1 Like

Check out the helpfile for Pdef’s play method. It features the ability to quantize the start time to the clock, at whatever division you specify.

Also, James Harkins’s pattern guide is essential I think!

Technically, each Pdef isn’t controlling the same Synth (basically kind of like a voice in this case). What’s happening is that multiple instances are being created, one for each Pdef, at each step (unless you have a rest). Each Pdef is able to communicate with its respective voice with no clashes in parameters or namespace.

Fun stuff for sure though!

If you go through the pattern guide, or eventually, you may find other \types (kind of like the mode of playback and control for which the pattern is calibrated, and you can add your own too). If it’s not specified, it’s the default, with all the conveniences of \degree, \scale, etc. Lot’s of other ones though that can also do very interesting things. Some for fx routing for example.

Is there any disadvantage to using multiple (project ) tabs ?
I find it much more convenient to have some synthdefs +pbinds in several tabs , and they still play in sync

I tried changing the Pbind to Pmono (when nested in Pseq, but I get errors and the console info doesn’t make it any more easier to debug .
Pmono needs odd number of arguments etc…
I’ve read James Harkinss but for some reason the manual is not clear at all .
To be honoust I didn’t get any wiser by reading the manual and I still do it on a daily basis , it’s the tutorials by Eli Fieldsteel that made it somehow click.
This is verry weird since I always loved learning by myself , but coding is not one of them :slight_smile:

Pmono is structured a bit differently than Pbind.

I’m not at a computer right now, so typing is a bit harder, but unlike with Pbind, in a Pmono, you don’t do ‘… \instrument, \synthName, …’
First info provided after entering the Pmono scope is just \synthName. After that give it pairs.

Thus Pmono needs an odd number of arguments, one is the synth and the rest are key value pairs.

...
Pmono(
    \twoop,
    \pitch, Pseq([....
1 Like

I find this an annoying design choice because it makes it non-trivial to toggle between Pbind and Pmono. In a Pbind I might write the instrument key 5th in the list etc. This is a good reminder to me to write a workaround…