From CSWiki
Jump to: navigation, search
// name: LiSaBasic and LiSaMulti
// desc: Live sampling utilities for ChucK
// author: Dan Trueman, 2007
// to run (in command line chuck):
//     %> chuck LiSa_readme.c
//demonstrate using track=1 mode with LiSa
//when track == 1, the input is used to control playback position
//input [0,1] will control playback position within loop marks
//values less than zero are multiplied by -1, so it is possible to use
//audio signals [-1, 1] to control playback position, as in waveshaping

//signal chain; record a sine wave, play it back
SinOsc s => LiSa loopme => dac;
//s => dac;
440. => s.freq;
0.2 => s.gain;

//alloc memory
6::second => loopme.duration;
1000::ms => loopme.loopEndRec;
1000::ms => loopme.loopEnd;

//set recording ramp time

//start recording input

//1 sec later, stop recording
1000::ms => now;

//set track mode to 1, where the input chooses playback position
//note that you can still record this input
1 => loopme.track;
s =< loopme; //disconnect sinosc as input
Step i => Envelope e => loopme; //use envelope to control playback position
1. =>;

//play it forward twice speed
500::ms => e.duration;
500::ms => now;

//now backwards half speed
2000::ms => e.duration;
2000::ms => now;;

//bye bye