PtimeClutch or PSPdiv \dur Offset

Hey, i would like to have one base pattern for \dur and to divide/multiply the durations for the different instruments to create polyrhytmic structures.
I was trying to use
1.) PtimeClutch from this thread Linking keys - patterns - #10 by scztt
and
2.) PSPDiv trom miSCellaneous_lib
I like the PSPDiv approach but im not sure how to add an offset so that not every instrument hits on the first beat.
With PtimeClutch I was trying to combine it with Ptpar but im not sure how to set the right amount for the offset, so its related to the multiplication/division of \dur for the specific instrument otherwise the rhythm changes after the first duration.
are there any better solutions especially when trying to relate \dur and \freq of different patterns or other parameters? thanks :slight_smile:

SynthDefs

(
SynthDef(\kick, {
	var sig;
	sig = SinOsc.ar(Env([300, 50, 40], [0.05, 0.1], \exp).ar);
	sig = sig + (BPF.ar(Hasher.ar(Sweep.ar), 8000) * Env.linen(0.001, 0.003, 0.001).ar);
	sig = sig + HPF.ar((sig * 2 * Env.perc(0, 3).ar).tanh, 300);
	sig = sig + (Saw.ar(XLine.kr(8000, 500, 0.003)) * Env.perc(0.001, 0.003).ar);
	sig = sig * Env.perc(0.001, 1).ar(Done.freeSelf);
	sig = sig ! 2;
	sig = sig * \amp.kr(-5.dbamp);
	OffsetOut.ar(\out.kr(0), sig);
}).add;

SynthDef(\snare, {
	var sig;
	sig = SinOsc.ar(Env([750, 210, 200], [0.01, 0.1], \exp).ar);
	sig = sig + ((sig * 3).clip2 * -20.dbamp);
	sig = sig + (SinOsc.ar(Env([350, 210, 200], [0.01, 0.1], \exp).ar * 2.6) * -10.dbamp);
	sig = sig + (BPF.ar(Hasher.ar(Sweep.ar), 2020, 0.3) * Env.perc(0.1, 0.2).ar);
	sig = sig + (BPF.ar(Hasher.ar(Sweep.ar), 3030, 0.3) * Env.perc(0.2, 0.2).ar * -10.dbamp);
	sig = sig + (sig * 1).clip2;
	sig = sig + (sig * 2).fold2;
	sig = sig * Env.perc(0.001, 0.2).ar(Done.freeSelf);
	sig = sig ! 2;
	sig = sig * \amp.kr(-5.dbamp);
	OffsetOut.ar(\out.kr(0), sig);
}).add;

SynthDef(\hat, {
	var sig;
	sig = BPF.ar(Hasher.ar(Sweep.ar), 8000, 0.1) * 10.dbamp;
	sig = sig * Env.perc(\attack.kr(0.01), 0.03).ar;
	sig = sig ! 2;
	sig = sig * \amp.kr(-5.dbamp);
	OffsetOut.ar(\out.kr(0), sig);
}).add;
)

1.) PtimeClutch

(
Pdef(\durs,
	PtimeClutch(
		Pseq([2], inf);
	)
);

Pdef(\kick,
	Pbind(
		\instrument, \kick,
		\dur, Pdef(\durs) / 3,
	)
);

Pdef(\sd,
	Pbind(
		\instrument, \snare,
		\dur, Pdef(\durs) / 2,
	)
);

Pdef(\hh,
	Pbind(
		\instrument, \hat,
		\dur, Pdef(\durs) / 5,
	)
);

Pdef(\rhythm,
	Ptpar([
		0, Pdef(\kick),
		2, Pdef(\sd),
		0, Pdef(\hh)
	]);
).play;
)

2.) PSPdiv

(
~pulse = PLseq([2, 1],inf);

~div_kick = 3;
~div_sd = PLshufn([1, 2]);
~div_hh = PLshufn([5, 7]);

~divBase = 1;
~divType = \seq;

Pdef(\rhythm,
	PSPdiv(
		PL(\pulse),
		[Pdef(\kick),Pdef(\sd), Pdef(\hh)],
		[PL(\div_kick), PL(\div_sd), PL(\div_hh)],
		PL(\divBase),
		PL(\divType),
	),
).play;
)
2 Likes

Probably best to define it with \lag or timingOffset


p = Pbind(\midinote, Pwhite(75, 90), \lag, 0.2);
q = Pbind(\midinote, Pwhite(60, 70));


x = PSPdiv(0.8, [p, q], [2, 1]).play;

thanks a lot @dkmayer slight_smile: