Sorry it’s really simple but I don’t find the good syntax, I m feeding 100 buffers with a folder containing 100 wav files and then I would simply like to randomly play between thoses but my method doesn’t work as it’s not possible to seq the idx param… Thanks
(
~bells = Array.new;
~folder = PathName("mypath");
~folder.entries.do({ | path |
~bells = ~bells.add(Buffer.read(s, path.fullPath));
});
)
~bells.size.postln;
(
SynthDef(\RDM, { | idx |
var sig = PlayBuf.ar(2, ~bells[ idx ]); // not right
Out.ar(0, sig);
}).add;
)
(
Pbindef(\ZZZ,
\instrument, \RDM,
\idx, Prand( " all the buffers" , inf),
\dur, 1
).play;
)
The issue is indexing into a language side array on the server. You need to send the buffer number when the synth is made. This is done by keeping the array of buffers on the language side, i.e., in the pattern.
… I’m on mobile and haven’t tested this code, should work though. Also, that array thing is just a collect function.
Thank you Jordan it’s clear and now it works. Also, I would like to match the Pbind \dur arg to the duration of the wavefile which is currently playing to avoid overlap between them, any idea ? Thanks
Oft! Its nastier than it should be! If any one else has a nicer way, please chime in!
Essentially, you store the index in the event, then access inside each Pfunc, this will unwrap the index to its actual value. Pfunc, takes (implicitly) the pattern’s event as its first argument.
That’s great, thanks. And to finish, what is the way to allow the repetition of the buf index (with Prand or equivalent) only if all the other buffers of ~bells played before ?
(I’m telling you I’m on my phone now to explain why this msg is so harshly short and also to get enough characters in so this is accepted as an answer, cheers!)