Hi all!
I am trying to accomplish something with patterns but I cannot seem to get what I would like, and there must be some things I misunderstood on the way.
Let’s say that I have a SynthDef which has a buffer as argument and some other parameters (such as the rate):
SynthDef(\test {
arg out = 0, buf, rate;
});
I would like to create a pattern that alternatively plays buf1
and buf2
(possibly in a random fashion), while buf1
should be played with rate 0.5 and a timing before the next event of 0.5, and buf2
with rate 2 and a shorter time before the next event.
I was thinking of using Pbindf
or Pchain
like so, in order to “bind” together some key-value pairs to buf1
and buf2
, and then combine both patterns in one with Pseq
or Prand
:
Pdefn(\common, Pbind(
\instrument, \test,
\out, 0,
));
Pdefn(\buf1, Pbindf(
Pdefn(\common),
\buf, ~buf1.bufnum,
\rate, 0.5,
\dur, 0.5,
));
Pdefn(\buf2, Pbindf(
Pdefn(\common),
\buf, ~buf2.bufnum,
\rate, 2.0,
\dur, 0.2,
));
Pdef(\playing, Prand([Pdefn(\buf1), Pdefn(\buf2)], inf)).play;
But it does not seem to work. I have tried a few variants of the code above but it either does not play at all, or it plays only one of the two buffers.
Thanks in advance for your help!
EDIT: added \buf parameters.