[chuck-users] Beat Slicing

Jonathan Siemasko zombiecontrol at gmail.com
Thu Jun 5 09:01:01 EDT 2008


Hello ChucK people,
        Been following the list for a while now but this is my first
post.  I am trying to create a Random Chuck Beat slicer.  Basically
input any loops, set the rate and set the number of slices to use and
it will automatically create random breakbeats from it.  The problem
is when I set the playback rate to anything other then half, single,
double, etc. slices stop lining up properly.  Debugging messages in
the code produce the expected numbers but the audio is clearly not
lining up.   I have many other features planed but am unable to figure
out what is going on here.  Is my Math wrong?  Is the SndBuf object
twitchy?  I have only tested it on windows in the miniAudicle so far.

-Jonathan

1 => float rate;
8 => int NumOfSlices;

SndBuf s => dac;
"C:/breaks/amenst.wav" => s.read;
s.samples() => s.pos; //Don't Play on Start
0.5 => s.gain;
rate => s.rate;
(s.samples() / rate) / NumOfSlices => float SliceSize;
SliceSize::samp => dur SliceDur;

SliceDur - (now % SliceDur) => now; //Sync
while(true){
    (Std.rand2(0, NumOfSlices - 1) * SliceSize) $ int => int NewPos;
    NewPos => s.pos;
    SliceDur => now;
}


More information about the chuck-users mailing list