This program kills chuck 1.2.0.4 after u>30, when curbuf and nextbuf references are swapped. There is something blatantly wrong with this code?
// the patch
sndbuf buf => dac;
sndbuf buf2 => dac;
sndbuf @ curbuf;
sndbuf @ nextbuf;
2 => buf.interp;
2 => buf2.interp;
// load the file
"/home/charles/test.wav" => buf.read;
"/home/charles/test.wav" => buf2.read;
// set the playback rate (1.0 is default)
1.0 => buf.play;
1.0 => buf2.play;
buf @=> curbuf;
buf2 @=> nextbuf;
0 =>int u;
buf.samples() => int size;
std.rand2(0, size) =>int nextpos;
100::ms => dur stepping;
nextpos => nextbuf.pos;
0.0 => float mixer;
1.0 => curbuf.gain;
0.0 => nextbuf.gain;
// time loop
sndbuf @ swap;
while( true )
{
1 +=> u;
if ( u>30 )
{
5::ms => stepping;
0.05 +=> mixer;
1.0 - mixer => curbuf.gain;
mixer => nextbuf.gain;
if ( mixer > 0.95 )
{
std.rand2(0 , size) => nextpos;
curbuf => swap;
nextbuf => curbuf;
swap => nextbuf;
nextpos => nextbuf.pos;
0.0 => mixer;
0 => u;
100::ms => stepping;
}
}
stepping => now;
}
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
Abrí tu cuenta aquí