Pbind -- progression of duration

Hello,

I’m trying to write the code with the following ideas, but I’m stuck:

How can I write a code using Pbind to create a progression of sounds transitioning from very short to long sustains (or releases) within a 5-minute duration? Additionally, how can I code it to revert back to very short sounds once it reaches the longest sustain?

Can you do the same with any sampler?

Thank you so much for your help.


(
SynthDef(\pluck, {
	|amp=0.4, note=60, decay=4, coef=0.1, pan=0|
	var env, sig, pluck, delay;
	env = EnvGen.kr(Env.linen(0, decay, 0), doneAction:2);
	sig = WhiteNoise.ar(amp);
	delay = note.midicps.reciprocal;
	sig = Pluck.ar(in:sig, delaytime:delay, decaytime:decay, coef:coef);
	Out.ar(0, Pan2.ar(sig * 0.5, pan));
}).add;
)
(

var base, dur, step, times;

base = 60;
dur = 0.2;
step = 1;
times = 6;

Pbind(\instrument, \pluck,
	\note, Pseq([Pseries(base,step,times), Pseries(base,step.neg,times)], inf),
		\dur, dur,
		\amp, 0.5,
	).play
)






Are you trying to manipulate the durations (\dur)? It sounds like that from your description, but your code is manipulation the \note, eg. pitch. If you want a deterministic pattern (or at least deterministic durs) it might be easier to calculate everything first, stuff the durs in to a Pseq and then play the pattern, rather than having the pattern calculate next dur for every note.

Hello Thor,

Yes. I’m trying to manipulate the length. I think \dur is probably the right argument. Am I correct? I’m very new to Pbind and Patterns. If you could give me an example, that’d be great.

Bests,
V

Yes I can help out with an example, just to clarify, when you say length do you mean delta time, ie. spacing between notes? It is slightly confusing that the delta time is named ‘dur’ in the pattern language. The duration of a note is dur (delta) * sustain (sustain defaults to 0.8) + releaseTime, so if you have a delta time of 1 and a sustain value of 0.5, the note will sound for 0.5 beats. With a sustain value of 1 the pattern plays legato, sustain > 1 = notes will overlap.

hi Thor,

Yes. Spacing between notes. I aim to have short sounds and then extend to long sounds ( like long release ) and remain at the same frequency.

What I wrote previously about sustain only applies to sustaining envelopes, where a gate off will be sent after (\dur * \sustain) beats. You synthdef is a non-sustaining one, so the \sustain key does not apply.

Here is one way of doing it, but I am not totally sure I understand exactly what kind of behavior your are looking for so you might have to adjust a bit. I assumed you wanted to let the decays follow the durs, but of course you can do anything with the decay key independently of the dur key.

(
~durArray = (0.2, 0.3..2);

Pdef(\test, 
	Pbind(
		\instrument, \pluck,
		\note, 60,
		\dur, Pseq(~durArray.mirror, inf).trace,
		\decay, Pkey(\dur),
 		\amp, 0.5,
)).play
)

It is best not to use an arg named ‘note’ in a synthdef you want to use with a pattern. ‘note’ and ‘midinote’ (and a bunch of other key names) are to be considered reserved names. A note value of 0 will be translated to 262 Hz (midinote 60) and this frequency is sent to the synth as ‘freq’.

So a better way of getting the same result, which will cause less confusion down the road is this:

(
SynthDef(\pluck, { |amp = 0.4, freq = 220, decay = 4, coef = 0.1, pan = 0|
	var env, sig, pluck, delay;
	env = EnvGen.kr(Env.linen(0, decay, 0), doneAction:2);
	sig = WhiteNoise.ar(amp);
	delay = freq.reciprocal;
	sig = Pluck.ar(in: sig, delaytime: delay, decaytime: decay, coef: coef);
	Out.ar(0, Pan2.ar(sig * 0.5, pan));
}).add;
)

(
~durArray = (0.2, 0.3..2);

Pdef(\test, 
	Pbind(
		\instrument, \pluck,
		\note, 0,
		// \midinote, 60, // Another way to specify the same frequency
		\dur, Pseq(~durArray.mirror, inf).trace,
		\decay, Pkey(\dur),
 		\amp, 0.5,
)).play
)

Hi,

you need some meta control, and there are several ways to do this – a favorite one of mine is Pseg, a kind of dynamic envelope, but you could even use envelopes themselves in a Pbind, something like

Pbind(
...
// 2 x 5 min development
\release, Env([0.1, 3, 0.1], [300, 300]),
...

Sorry, no time to write a full example now, you might check miSCellaneous_lib’s tutorial “Event patterns and LFOs” which describes several options for this type of behaviour.

Best

Daniel

Thank you so much, Thor. I think this is what I anticipated—one question. What does the freq.reciprocal do in the synthdef?

Hi Daniel,

Thank you so much. This is so helpful. I’ll look into it.

Bests,
V

My freq arg replaces your note.midicps and you had note.midicps.reciprocal, so this is just the same without the midicps, 'cause we are supplying the freq in Hz rather than a midinote number.