int voices[ 10 ]; int loopID[ 10 ]; adc => LiSa lisa => dac; 10::second => lisa.duration; 100::ms => lisa.recRamp; int currentloop; 0 => int recordswitch => int playswitch; 0::samp => dur loopend => dur length; spork ~ checkbuttons(); while( true ) { runloops( currentloop ); } fun void runloops( int currentloop ) { if( recordswitch == 1 ) { spork ~ record( currentloop ); 2 => recordswitch; } if( playswitch == 1 ) { spork ~ play( currentloop, loopend, length ); 0 => playswitch; } else { 1::samp => now; } } fun void checkbuttons() { while( true ) { Hid hi; HidMsg msg; 0 => int deviceNum; if(!hi.openKeyboard( deviceNum ) ) me.exit(); hi => now; if( hi.recv( msg ) ) { if( msg.isButtonDown() ) { msg.which => int x; if( 29 < x ) { if( x < 40 ) { msg.which => currentloop; currentloop - 30 => currentloop; <<< "Current Loop:", ( currentloop + 1 ) >>>; } } if( x == 21 ) { if( recordswitch == 0 ) { 1 => recordswitch; <<< "Recording..." >>>; } else { 0 => recordswitch; <<< "Recording Off" >>>; } } } } else { 1::samp => now; } } } fun void record( int currentloop ) { dur position; lisa.getVoice() => voices[ currentloop ]; 1 => lisa.record; while( true ) { if( recordswitch == 0 ) { 0 => lisa.record; position - 1::samp => length; 1 => playswitch; <<< "Position =", position >>>; <<< "Loopend =", loopend >>>; <<< "Length =", length >>>; me.exit(); } lisa.recPos() => position; if( position > loopend ) { position => loopend; } 1::samp => now; } } fun void play( int currentloop, dur loopend, dur length ) { int playloop; currentloop => playloop; loopend - length => dur difference; lisa.loop( voices[ playloop ], 1 ); lisa.loopEnd( voices[ playloop ], (length + difference ) ); <<< "Here" >>>; while( true ) { lisa.play( voices[ playloop ], 1 ); 1::samp => now; } }