« Return to Thread: play random samples with Pbind

Re: play random samples with Pbind

by stwbass :: Rate this Message:

Reply to Author | View in Thread

I think the problem may be in your SynthDef because you are multiplying the bufnum by the rate and BufRateScale. I also might be misunderstanding the problem.

sw

On Sat, Apr 18, 2009 at 2:01 PM, Jeroen van Rijzewijk <supercollidermailinglist@...> wrote:
Hi list, 

i'm trying to play random samples from a samplefolder on my computer, and adjust the playback rate, duration etcetera via Pbind.
But my code doesn't seem to work properly, i'm getting samples with same settings after a while, so no changes/randomness whatsoever...
What am i doing wrong, and is this the way to go?
Thanks in advance!

(
{
y = "~/Desktop/samplefolder/*.wav".pathMatch.collect({ |path|


var buf;
buf = Buffer.read(s, path);
s.sync;
buf;
});
"done".postln;
}.fork;
)

y.at(0).play;
y.postln;

(
SynthDef(\playsample, { |bufnum=0, rate=1, amp=1, pan=0;|

var sig, env;

sig = PlayBuf.ar(1, bufnum * rate * BufRateScale.kr(bufnum), loop:0, doneAction:2);

env = EnvGen.kr(Env([1, 0], [BufDur.kr(bufnum) * rate]));
sig = sig * env;
sig = Pan2.ar(sig, pan, amp);
Out.ar(0, sig);
}).store;
)

(
Pbind(\instrument, \playsample,
\bufnum, Pxrand(y, inf),
\amp, Pxrand( [0.1, 0.5, 1.0], inf),
\rate, Pxrand( [0.5, 1.0, 2.0], inf),
\pan, Pxrand( [-1, -0.5, 0, 0.5, 1], inf)
).play;
)




--
Scott Worthington
stwbass@...
www.scottworthington.com

 « Return to Thread: play random samples with Pbind