I am experimenting with Pbindef and time based patterns to be able to make gestures of varying length, in such a way that multiple keys can share the same gesture length for their pattern’s duration.
I am working with a Pbindef that controls a sample grain SynthDef.
As a straight forward example I want to have a new Buffer selected for playback once the previous Buffer has played for its full buffer duration.
And at the same moment the new Buffer is selected I want the pattern for the buffer playback \index
key to start a ramp from 0.0 to 1.0 (start till end of sample in buffer) in the duration of the newly selected Buffer.
For the \buffer
key in the “\granola” Pbindef I came up with the following solution:
\buffer, Pn(
Plazy({
var theBuffer, sampleDuration;
theBuffer = ~sampleLibrary[rrand(0, 10)]; //select a new sample buffer
sampleDuration = theBuffer.duration; //get its duration
Pbindef(\granola, \index, Pseg([0.0, 1.0], sampleDuration)); //start a ramp for the duration of the newly selected sample buffer by changing the \index key in its own pbindef
Pstep( //provide the new \buffer pattern, holding the selected buffer for the buffer's duration
Pseq([theBuffer],1),
Pseq([sampleDuration],1),
1
);
}), inf
),
This solution works, but there must be other, maybe better ways of doing this.
One of the issues is that the pbindef’s .quant
value has to be 0.0 for the new \index
pattern to start immediately making it hard to change other keys using other .quant
values.
Perhaps someone can point me at other ways of dealing with this kind of problem, changing keys from within other keys or based on shared dynamic data.
Hope that made sense…
Thanks
David