[chuck-users] Looping Sample Playback
Adam Tindale
adamtindale at hotmail.com
Mon Feb 27 17:19:16 EST 2006
Hi,
This is part of the wonder of ChucK, you can define this yourself.
Most often .pos is given the 0 argument to start from the beginning
of the file. You can give it any int that will refer to an index in
your sample.
If you know the startpoint and endpoint of the looping for each file
then you can put in a function like this and then call it for every
instance of the sample. Then you can expand this to respond to
noteons and noteoffs and all those other musical things.
I hope this answers your question.
--art
fun void playsample(int startpoint, int endpoint, string filename){
sndbuf s => dac;
filename => s.read;
0 => s.pos;
endpoint::samp => now;
while(true){
startpoint => s.pos;
(endpoint - startpoint)::samp => now;
}
}
On 27-Feb-06, at 1:17 PM, Mike McGonagle wrote:
> Hello all,
>
> I was wondering if there is a ugen that will handle arbitrary looping
> points? I have some samples for various instruments (ie piano,
> mellotron strings, etc), and would like to hook them up in ChucK.
> Basically, if the sndbuf ugen is the starting point for this, then do
> I need to write my own "looping" function to ensure that it gets back
> to the proper points within the sample.
>
> Or has someone already implemented this functionality and would be
> interested in "sharing"?
>
>
> Thanks,
>
> Mike
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
More information about the chuck-users
mailing list