/usr/share/doc/chuck/examples/basic/chirp2.ck is in chuck 1.2.0.8.dfsg-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | // more chirping...
// patch with envelope and pan
SinOsc s => Envelope e => Pan2 p => dac;
// gain
.5 => s.gain;
// pan hard left
-1 => p.pan;
// call chirp
chirp( 127, 20, 1::second );
// wait for envelope to go down
10::ms => now;
// pan hard right
1 => p.pan;
// call chirp
chirp( 20, 120, 1::second, 100::ms );
// wait a second
1::second => now;
// randomize pan
Std.rand2f( -1, 1 ) => p.pan;
// call chirp
chirp( 30, 110, .5::second );
// wait for envelope to go down
10::ms => now;
// pan
Std.rand2f( -1, 1 ) => p.pan;
// call chirp
chirp( 110, 30, 1::second, 100::ms );
// wait a second
1::second => now;
// chirp function
fun void chirp( float src, float target, dur duration )
{
// just call the other one with default tinc
chirp( src, target, duration, 1::ms );
}
// chirp function (with tinc)
fun void chirp( float src, float target, dur duration, dur tinc )
{
// initialize freq
src => float freq;
// find the number of steps
duration / tinc => float steps;
// find the inc
( target - src ) / steps => float inc;
// counter
float count;
// set env
.01 * duration / second => e.time;
// open env
1 => e.keyOn;
// do the actual work over time
while( count < steps )
{
// increment the freq
freq + inc => freq;
// count
1 +=> count;
// set the freq
Std.mtof( freq ) => s.freq;
// advance time
tinc => now;
}
// close env
1 => e.keyOff;
}
|