Debian Codegraph @

examples/special/LiSa-track5.ck

raw
1 //--------------------------------------------------------------------
2 // name: LiSa-track5.ck
3 // desc: live sampling utilities for ChucK
4 // demonstrate using track == 2 mode with LiSa
5 // requires: chuck-1.5.5.6
6 //
7 // author: Dan Trueman, 2007
8 //--------------------------------------------------------------------
9
10 // patch
11 LiSa loopme => dac;
12 // load audio file into LiSa
13 loopme.read( "geetar.wav" );
14
15 //---------------- old method; pre-1.5.5.6 ------------------------
16 // use for loading audio file (also see example: LiSa-load.ck)
17 // SndBuf buf;
18 // change this path to your own sample
19 // me.dir() + "geetar.wav" => buf.read;
20 // set lisa buffer size to sample size
21 // buf.samples()::samp => loopme.duration;
22 // transfer values from SndBuf to LiSa
23 // for( 0 => int i; i < buf.samples(); i++ )
24 // { loopme.valueAt(buf.valueAt(i), i::samp); }
25 //---------------- old method; pre-1.5.5.6 ------------------------
26
27 // set sync/track mode to 2, where the input chooses playback
28 // position interpreted as a time value
29 // again, negative values are multiplied internally by -1
30 2 => loopme.sync;
31
32 // use an oscillator to set playback position
33 SinOsc tracker => loopme;
34 // step signal as offset
35 Step off => loopme;
36
37 // tracker parameters; will determine how far into the buffer
38 // to go (gain), with what offset (off) and with what speed (freq)
39 0.05 => tracker.freq;
40 // we'll loop over half of the buffer
41 loopme.duration() / 4::samp => tracker.gain;
42 //starting at the midpoint
43 loopme.duration() / 2::samp => off.next;
44
45 // set gain
46 0.5 => loopme.gain;
47 // play it back
48 1 => loopme.play;
49
50 // time loop
51 while( true )
52 {
53 // monitor where we're playing back from in the buffer
54 <<< ( off.last() + tracker.last() ) / 44100 >>>;
55 50::ms => now;
56 }