Discussion:
Play a Sample with random start
wallace
2014-10-08 19:45:52 UTC
Permalink
Hi,

I am working on building a simple sampler that plays a samples with a
random starting point.

here is my SynthDef:

SynthDef(\randomSample, { |out = 0, bufnum, start = 0, time = 1, amp = 1|
var sig = PlayBuf.ar(1, bufnum, startPos: (start *
BufDur.kr(bufnum)).poll, loop: 0),
env = EnvGen.kr(Env.linen(0.01, time, 0.05, level: amp),
doneAction: 2);
Out.ar(out, (sig * env) ! 2)
}).add;

and here how i play it:
Synth(\oneLoop, [\bufnum, b, \time, 0.2, \start, rrand(0.0,1.0)];

The number I poll makes but the sample has always been played from the
beginning.
Can anyone explain me why?

Best,
Marcello

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Dan Zink
2014-10-08 19:54:12 UTC
Permalink
Hi Wallace

Please try BufFrames instead of BufDur - you want the frame position, not
the position in seconds
Post by wallace
Hi,
I am working on building a simple sampler that plays a samples with a
random starting point.
SynthDef(\randomSample, { |out = 0, bufnum, start = 0, time = 1, amp = 1|
var sig = PlayBuf.ar(1, bufnum, startPos: (start *
BufDur.kr(bufnum)).poll, loop: 0),
env = EnvGen.kr(Env.linen(0.01, time, 0.05, level: amp),
doneAction: 2);
Out.ar(out, (sig * env) ! 2)
}).add;
Synth(\oneLoop, [\bufnum, b, \time, 0.2, \start, rrand(0.0,1.0)];
The number I poll makes but the sample has always been played from the
beginning.
Can anyone explain me why?
Best,
Marcello
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
wallace
2014-10-08 20:25:19 UTC
Permalink
Post by Dan Zink
Hi Wallace
Please try BufFrames instead of BufDur - you want the frame position,
not the position in seconds
great, thanks!


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...