ChucK+code+for+Cybernetic+Orchestra

__Other Places To Go For Help__ Chuck-A-Day site [|Link]

The code below has been collected in a chaotic way at different times and may not always work (some of it may need to be updated to work with the latest version of the EspGrid software).

__A Very Simple chuck/miniAudicle program for testing that audio works__

everything after two slashes is a comment comments are read by us only, not the computer SinOsc s => dac; make a sine generator, connect it to audio output 1::second => now; let the program run for 1 second, and thus hear something

__A Very Simple chuck/miniAudicle program for testing if espBeat is working__

Shakers s => dac; //make some Shakers called s, connect them to audio out// //Esp.e => now;// //1 => s.noteOn;// //1::second => now;//

__A Simple chuck/miniAudicle program that creates graphical slider to control fadeIn/Out of oscillator__ SinOsc s => Envelope e => dac ;MAUI_Slider slider;

slider.range( 0 . 0, 1 . 0 );[|slider.name]( "hey there" );slider.display;

while ( true ) { slider.value => e.target; 5 :: ms => e.duration => now ;}

//...//

//For some other examples... to be included and discussed here soon... see the examples folder of the cybernetic folder...//

//...//

//DrO's code from free jam on Feb 08//

//SqrOsc s => LPF f => Envelope e => PRCRev r// //=> dac ;// //SinOsc s2 => Envelope e2 => dac ;// // 75 => s2.freq; 0. 3 => s2.gain;// //[ 73, 75 , 78 , 77 ] @=> int ns[];// // [ 1000, 2000 , 3500 , 10000 ] @=> int fs[];  // //[ 1 :: ms, 15 :: ms , 150 :: ms , 625 :: ms ] @=> dur ds[];// // 0 . 1 => s.gain;// // 0 . 3 => r.mix;// // while ( true ) { // Esp.b(2) => now; g; Esp.b(4) => now ; g; //Esp.b(4.5) => now; g;// //}// // functionvoid g { // //ns[Std.rand2( 1, 1 )] => Std.mtof => s.freq;// //fs[Std.rand2( 1, 1 )] => f.freq;// // 1 =>e.target; 1 => e2.target;// // 5 :: ms =>e2.duration;// //ds[Std.rand2( 0, 0 )] =>e.duration=> now ;// fadein 0 =>e.target; 0 => e2.target; 5 :: ms =>e.duration=>e2.duration => now ; //fadeout// //}//

//__A Less Simple chuck/miniAudicle program that uses O.ck features to vary a filter cutoff over time__// //__(as discussed during 1 Feb 2012 rehearsal)__//

//SqrOsc s => LPF f => Envelope e => dac ;// //Envelope g => blackhole ;// // 30 => s.freq;// // 0 . 3 => s.gain;// // 1 . 0 =>e.target;// //O.ef(g,f);//

// 10 => g.value;// // 5000 =>g.target;// // 5000 :: ms => g.duration;// // 5000 :: ms => now ;// // 10 =>g.target;// // 5000 :: ms =>g.duration;// // 5000 :: ms => now ; //

//Here is some stuff!//

SndBuf b => Envelope e => Envelope e2 => LPF f => PRCRev r => dac ; "droid1.wav" => b.read; Envelope g => blackhole ;

2 => b.rate; 85 => Std.dbtorms => b.gain; 2 => f.Q; 0. 15 => r.mix;

10 => g.value; 1800 => g.target; 0 . 5 :: second => g.duration;

spork ~ someShred; spork ~ someShred2;

while ( true ) { Esp.e => now ; 1000 => b.pos; 1 => e.target; Esp.d => e.duration => now ; 0 => e.target; Esp.d => e.duration => now ; Esp.d * Esp.l =>e.duration=> now ; Esp.d * Esp.l => now; }

function void someShred2 { while ( true ){ g.value => f.freq; 1000 :: ms => now ; } }

function void someShred { while ( true ) { Esp.f1 => e2.target; 1 :: second => e2.duration => now ;

} } _ __**INTERFERENCE**__

__Textural shred utilizing two oscillators, slightly detuned and modulated by two LFOs of differing frequency. Recommend using the MIDI values to build up cross-spectrum chords, or play with the decimal values of the MIDI notes to create pulsating beating patterns from fourrier interference.__

__As a side note, the frequency of the beating between two tones played is equal to the difference in the tones' frequencies.__

TriOsc s => PRCRev r => dac ; TriOsc t => PRCRev u => dac ;

SinOsc lfo1 => blackhole ; SinOsc lfo2 => blackhole ;

0 . 01 => s.gain; 0 . 01 => t.gain;

2 . 9 => r.mix; 2 . 9 => u.mix;

. 2 => lfo1.freq; . 3 => lfo2.freq;

while ( 1 :: ms => now ){ (lfo1.last*. 4 )+ 65. 0 => Std.mtof => s.freq; (lfo2.last*. 2 )+ 65. 1 => Std.mtof => t.freq; }


 * __FOUR TO THE FLOOR__**

__Simple kick drum sound hitting on every beat. Most parameters can be played with, be it frequency, timing, and envelope to give a variety of rhythmic effects. A very versatile shred.__

SinOsc s => Envelope e => Gain g => dac ; 1 . 5 => s.gain; 71 => s.freq;

while ( true ) { Esp.e => now ; if (Esp.n == 1 || Esp.n == 2 || Esp.n == 3 || Esp.n == 4 ) { . 99 => e.target; 0 :: ms => e.duration => now ; 5 :: ms => e.duration => now ; 0 => e.target; 70 :: ms => e.duration => now ; } }


 * __SLOW ATTACK SNARE__**

__Similar in essence to the previous shred - a clipped noise oscillator makes a very effective snare noise. A quicker attack makes for a crisp snap.__

Noise s => Envelope e => Gain g => PRCRev r=> dac ; 0 . 2 => s.gain; 0 . 1 => r.mix;

while ( true ) { Esp.e => now ; if (Esp.n == || Esp.n == 12 ) { . 9 => e.target; 250 :: ms => e.duration => now ; 2 :: ms => e.duration => now ; 0 => e.target; 0 :: ms => e.duration => now ; } }


 * __CONSTRAINTS CODES__**

Noise n => Envelope e => dac ; . 5 => n.gain;

while ( true ) { Esp.beat => now ; if ( Esp.n == 4 || Esp.n == 7 || Esp.n== 8 || Esp.n== 12 ){ . 966 => e.target; 5 :: ms => e.duration => now ; 0 => e.target; 50 :: ms => e.duration => now ; } }

TriOsc s => Envelope e => PRCRev r => dac ; 48 => s.freq; 4 => s.gain; . 1 => r.mix;

while ( true ) { Esp.beat => now ; if (Esp.n == 6 || Esp.n == 7 || Esp.n == 8 ){ . 966 => e.target; 50 :: ms => e.duration => now ; 0 => e.target; 50 :: ms => e.duration => now ; } }

__FOR WINDOWS: Killing miniAudicle in an efficient way:__

__1) Open Notepad and enter two lines of text:__

__taskkill /F /IM miniAudicle.exe__ __exit__

__2) Save As... => All Files, "*.bat"__

__3) Running this batch file will kill miniAudicle.exe, without the need to close the window / open Task Manager. The command window will exit immediately upon completion.__

Dr. O's code from 13 June 2012 improv:

Comment: the code below demonstrates several things - (1) doing everything necessary to make a given sound, including composing the signal network (connecting ugens to each other with => ) inside a function (i.e. a b c etc) and (2) triggering those functions using spork~ so that they can all happen at the same time, mixed, overlapped, etc and (3) using a probability matrix (p) to control how likely it is that an event is going to happen on a certain beat.

0 => int i; [ 0. 01, 0 . 01 , 0 . 01 , 0 . 21 ,  0 . 01 , 0 . 01 , 0 . 01 , 0 . 11 ,   0 . 05 , 0 . 01 , 0 . 01 , 0 . 01 ,   0 . 01 , 0 . 01 , 0 . 11 , 0 . 05 ] @=> float p[];

while ( true ) { Esp.beat => now ; if (Std.rand2f( 0. 0, 1 . 0 ) Envelope e => dac ; [ 8, 20 , 32 , 20 ] @=> int ns[]; i++; if (i== 4 ) { 0 => i; } <<< i >>>; ns[i] => Std.mtof => s.freq;

82 => Std.dbtorms => s.gain; 1 => e.target; 50 :: ms => e.duration => now ; 0 => e.target; 50 :: ms => e.duration => now ; }

function void b { SawOsc s => Envelope e => dac ; [ 8, 20 , 32 , 20 ] @=> int ns[]; ns[Std.rand2( 0, 3 )] => Std.mtof => s.freq; 78 => Std.dbtorms => s.gain; 1 => e.target; Esp.beatD => e.duration => now ; 0 => e.target; Esp.beatD * 2 => e.duration => now ; }

function void c { Shakers s => dac ; 0 . 8 => s.gain; Std.rand2( 11, 13 ) => s.which; 1 => s.noteOn; 500 :: ms => now ; }

function void d { SqrOsc s => LPF f => Envelope e => dac ; 2000 => f.freq; 8 => Std.mtof => s.freq; 78 => Std.dbtorms => s.gain; 1 => e.target; Esp.cycleD/ 2 => e.duration => now ; 0 => e.target; Esp.cycleD/ 2 => e.duration => now ; }