Skip to content

Instantly share code, notes, and snippets.

@son0p
Created February 10, 2016 22:12
Show Gist options
  • Save son0p/d651607838dc6eb69411 to your computer and use it in GitHub Desktop.
Save son0p/d651607838dc6eb69411 to your computer and use it in GitHub Desktop.
%> Chuck --loop
%> chuck = 2 foo.ck
%> chuck - 2 3 8
%> chuck ^
%> chuck --time
 %> chuck @192.168.1.1 + foo.ck bar.ck
    (or)
 %> chuck @foo.bar.com -p8888 + foo.ck bar.ck
--kill

// quitar el :(int) en un log de consola
en excel =LEFT(A1, LEN(A1)-6)

// initializing an integer variable
0 => int (variable);

//
// Time
//

now / second; // time in second
 2.5::ms => dur quarter;
 4::quarter => dur whole;
now/ms => float foo; // convert Time to float
120.0::ms => dur timer; // convert float to dur
//
// STANDARD LIBRARY
//

[function]: int abs ( int value ); // returns absolute value of integer

Std.mtof(value) => float hz;  // midi to frecuency

Std.abs (int value); //absolute values : convert negative numbers to positive numbers -x, x convert to x
Std.fabs (float value); // -x.x, x.x convert to x.x
Std.sgn (float value); // -x.x, 0, x.x  convert to -1.0, 0, 1.0

-10 => int negative_int;

-1.2345 => float negative_float;

Std.abs(negative_int) => int abs_int;
Std.fabs(negative_float) => float abs_float;

// Convert Int to float, float to int
9.1 + 2 => float result;// adding float and int produces a float
now/ms => float foo; // convert Time to float
// however, going from float to int requires cast
4.8 $ int => int foo;  // foo == 4
// this function expects two floats
Math.rand2f( 30.0, 1000.0 );
// this is ok because of implicit cast
Math.rand2f( 30, 1000 );
[function]:  ( int value );// returns absolute value of integer
[function]: float fabs ( float value );// returns absolute value of floating point number
[function]: int Math.random2 ( int min, int max ); // generates random integer in the range [min, max]
[function]: float Math.random2f ( float min, float max );
[function]: float sgn ( float value );// computes the sign of the input as -1.0 (negative), 0 (zero), or 1.0 (positive)
[function]: int system ( string cmd );// pass a command to be executed in the shell
[function]: int atoi ( string value );// converts ascii (string) to integer (int)
[function]: float atof ( string value );// converts ascii (string) to floating point value (float)
[function]: string getenv ( string key );// returns the value of an environment variable, such as of "PATH"
[function]: int setenv ( string key, string value );// sets environment variable named 'key' to 'value'
[function]: float mtof ( float value );//  converts a MIDI note number to frequency (Hz)
   // note the input value is of type 'float' (supports fractional note number)
[function]: float ftom ( float value );// converts frequency (Hz) to MIDI note number space
[function]: float powtodb ( float value ); // converts signal power ratio to decibels (dB)
[function]: float rmstodb ( float value ); // converts linear amplitude to decibels (dB)
[function]: float dbtopow ( float value );// converts decibels (dB) to signal power ratio
[function]: float dbtorms ( float value );// converts decibles (dB) to linear amplitude

//
// RANDOM NUMBERS
//

Math.random2
Math.randomf

//
// Arrays
//
// chuck intializer to array reference
    [ 1, 1, 2, 3, 5, 8 ] @=> int foo[];
foo.cap() // max number of array

// access the 0th element (debug print)
<<< foo[0] >>>; // hopefully 3.2

// set the 2nd element
8.5 => foo[2];


// loop over the entire array
for( 0 => int i; i < foo.cap(); i++ )
{
    // do something (debug print)
    <<< foo[i] >>>;
}

// MULTI DIMENSIONAL 2D array
int foo[4][4];


// set an element
10 => foo[2][2];

// Intialize array
[[1,2],[3,4],[8,16]] @=> int test[][];

// accedo a elementos  // esto no me funciona


test[1][2]; // da 4
test[0][1]; // da 2

// para traer el array completo(confirmar):
test[1] @=> int array[];

// ejemplo multidimensional

// multi-dimensional array
int a[2][2][2];
// assignment
4 => a[0][0][1];
// access
a[0][0][1] => int b;
// test
if ( b == 4 ) <<<"success">>>;
// recorrer un solo array
a[0][1] @=> int test[];
for( 0=> int i; i < test.cap(); i++)
{
	<<<test[i] >>>;
}


// multi-dimensional array
int a[2][2][2];
// assignment
4 => a[0][0][1];
// access
a[0][0][1] => int b;

// test
if ( b == 4 ) <<<"success">>>;




// ========= Multidimensional array
// 15.ck : multi-dimensional array instantiation
// delcare int array 2x2x2
int a[2][2][2];
// delcare float array 2x2x2
float b[2][2][2];
// assign
5 => a[1][1][1] => b[1][1][1];
// multi-dimensional array initialization
[ [1,2], [3,4] ] @=> int c[][];
// test
if( a[1][1][1] == 5 && b[1][1][1] == 5.0 && c[0][1] == 2 ) <<<"success">>>;

// based on Robin Haberkorn's example
int a[0][2];
// instantiate arrays
new int[2] @=> a["foo"];
new int[2] @=> a["bar"];
// fill them
23 => a["foo"][0];
24 => a["foo"][1];
32 => a["bar"][0];
42 => a["bar"][1];
// test them
if( a["foo"][0] == 23 && a["bar"][1] == 42 )
<<< "success" >>>;

//--------------------
// instantiate a float array
float argh[0];
// print
<<< "array size:", argh.size() >>>;
// resize
4 => argh.size;
// print
<<< "array size:", argh.size() >>>;
// set elements
3.0 => argh[0];
4 => argh[1];
5.0 => argh[2];
6 => argh[3];
// print
<<< "contents:", "">>>;
for( int i; i < argh.size(); i++ )
<<< "argh[", i, "]:", argh[i] >>>;
// recap
2 => argh.size;
// print
<<< "array size:", argh.size() >>>;
// clear the contents
argh.clear();
// print
<<< "array size:", argh.size() >>>;
//---------------------------------------

//---------array storage
// multi-dimensional array
int a[2][2][2];
// assignment
4 => a[0][0][1];
// access
a[0][0][1] => int b;
// test
if ( b == 4 ) <<<"success">>>;
//-----------------------

//-----------------------
// multi-dimensional array
// array to array assignment
int a[2][2][2];
int b[2][2];
// assignment
1 => b[0][1];
2 => b[0][0];
// assign b to 0th element of a
b @=> a[0];
// verify
if ( a[0][0][1] == 1 ) <<<"success">>>;
//-------------------------------


// ========== Fill an array

[1,1,1,2] @=> int seedDuration[];
for( 0 => int i; i < (beats-1); i++)
{
	seedDuration[(Math.random2(1, seedDuration.cap())-1)] => int pushDuration ;
	pushDuration => durations[i];
}

// Go over Mode array to pushing notes
for	(0 => int i; i < melody.cap(); i++)
{
	// Random choose for a note.
	Math.random2(1, (notes.cap()-1)) => int noteSelector;
	// Rule: Intervals of max 6 tones
	noteSelector => int newNote;
	notes[noteSelector] => int pushNote;
	pushNote => int oldNote;
	// Fill the array with selected notes
	pushNote =>  melody[i];
}

// ========== fill an array 2

// instantiate int array
float argh[0];
// print out relevant info
<<< "array size:", argh.size() >>>;
// append items (array should grow dynamically as needed)
argh << 3.0 << 4 << 5;
// print out relevant info
<<< "array size:", argh.size() >>>;
// print out elements
<<< "contents:", argh[0], argh[1], argh[2] >>>;
// pop element
argh.popBack();
// print out relevant info
<<< "array size:", argh.size() >>>;
//======================


// ========= SUM and average  array elements

// dirty average : erroneous first average
0 => int count;
while(true)
// some evente here

// advance counter
count++;
count % 4 => int i;
lapTime => laps[i];
float sum;
if (i == 3)
{
	for(0 => int ii; ii < laps.cap(); ii++)
	{
		sum + laps[ii] => sum;
	}
	<<<"sum", sum/4 >>>;
}

// ==== Otra opciön
500 => int full;
[20,10,15,10] @=> int foo[];
int durations[full];
0 => int sum; // variable que recogerá la suma del array
0 => int i;

fun int fillArray
{
	while(i < full)
	{
		rndSel(foo) => int value; // selecciono valor aleatorio
		sum + value => sum; // lo sumo al valor anterior

		if (sum < full)
		{
			value => durations[i];
			i++;
		}
		else
		{
			break;
		}
	}
	return durations;
}



//
// OPERATORS
//

 // Add 4 to foo and assign result to foo
    foo + 4 => foo;

    // add 4 to foo and assign result to foo
    4 +=> foo;

    // subtract 10 from foo and assign result to foo
    // remember this is (foo-10), not (10-foo)
    10 -=> foo;

    // 2 times foo assign result to foo
    2 *=> foo;

    // divide 4 into foo and assign result to foo
    // again remember this is (foo/4), not (4/foo)
    4 /=> foo;

 // mod foo by T and assign result to foo
    T %=> foo;

    // bitwise AND 0xff and bar and assign result to bar
    0xff &=> bar;

    // bitwise OR 0xff and bar and assign result to bar


    0xff |=> bar;


//
// selectors
//

0 => int switchy;
while (true)
{
   if (switchy == 1)
   {
      .... do your thing
   }
   1 - switchy => switchy // flip switch
}

//
// CONTROL Structures
//

if( condition )
{
    // your code here
}
else
{
    // your other code here}

// here is an infinite loop
while( true )
{
    // your code loops forever!

    // (sometimes this is desirable because we can create
    // infinite time loops this way, and because we have
    // concurrency)
}

do {
    // your code executes here at least once
} while( condition );


// an infinite loop
until( false )
{
    // your great code loops forever!
}

do {
    // your code executes here at least once
} until( condition );

// another infinite loop
while( 1 )
{
    // check condition
    if( condition )
        continue;

    // some great code that may get skipped (if continue is taken)
}


// for loop
for( 0 => int foo; foo < 4 ; foo++ )
{
    // debugprint value of 'foo'
    <<<foo>>>;
}


//
// LOGIC
//


    && : and
    || : or
    == : equals
    != : does not equal
    > : greater than
    >= : greater than or equal to
    < : less than
    <= : less than or equal to


// mixer

SinOsc s1 => Gain g => dac;
SinOsc s2 => g;
.5 => g.gain;

// Reverb

SinOsc s1 => PRCRev g => dac;
SinOsc s2 => g;
.5 => g.gain; // gain applied to PRCRev
// can chain gain and mix
.5 => g.gain => g.mix;

// Read a parameter then modify it then ChucK it back to itself.
500 =>s1.freq => s2.freq;
s1.freq() * 2 => s1.freq;



//
// CONTROL STRUCTURES
//

if ( foo == 1)
  {

  }

//-------
// LFO
//-------
SinOsc s => dac;
SinOsc lfo;

//set freq of lfo
5 => lfo.freq;

/*

will update the frequency of s every 20 milliseconds. Remember that a SinOsc oscillates between -1 and 1, so if we just put that directly to the frequency of s we wouldn’t be able to hear it (unless you are using ChucK in a tricked out civic...). What we are going to do is multiply the output of the lfo by 10 and add it to the frequency 440. The frequency will now oscillate between 430 and 450.
 */

while (20::ms => now){
  ( lfo.last() * 10 ) + 440 => s.freq;
 }

SinOsc lfo => blackhole;  // avoid dac but samples are computed


 //---------
 // Command Line
 //----------
 [function]: int system ( string cmd );// pass a command to be executed in the shell

 // shows getting command line arguments
// (example run: chuck args:1:2:foo)
// print number of args
<<< "number of arguments:", me.args() >>>;
// print each
for( int i; i < me.args(); i++ )
{
<<< " ", me.arg(i) >>>;
}

//--------
// MIDI
//--------

//Create object
MidiIn min;
//connect to port 0
min.open(0);
// midi out
MidiOut mout;
// connect to port 0
mout.open(0);
//Check .open function returns properly
MidiIn min;
min.open(0) => int AmIOpen;

if( !AmIOpen ) { me.exit();}

//shorter

if( !min.open(0) ) { me.exit(); }


//Midi in

while(true){
  //Use the MIDI Event from MidiIn
  min => now;
  while( min.recv.(msg) ){
    <<<msg.data1,msg.data2,msg.data3,"MIDI Message">>>;
  }
 }

// Midi Output

MidiOut mount;
MidiMsg msg;
// check if port is open
if( !mount.open( 0 ) ) me.exit();

// fill the message with data
144 => msg.data1;
52 => msg.data2;
100 => msg.data3;
// bugs after this point can be sent
// to the manufacturer of your synth
mout.send( msg );



//
// Recording
//
// simple
$ chuck foo.ck bar.ck rec.ck
// auto naming fix in "data/session" => w.autoPrefix;
$ chuck foo.ck bar.ck rec-auto.ck
// on the fly
$ chuck + rec.ck
// no realtime .. silent
$ chuck foo.ck bar.ck rec2.ck -s
// start stop
1 => w.record; //start
0 => w.record; // stop

// ------
// Keyboard
// -----------
// human interface device
Hid hi;
 // a message  to convey data from Hid
HidMsg msg;

// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;

// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;

// infinite event loop
while( true )
{
    // wait on event
    hi => now;

    // get one or more messages
    while( hi.recv( msg ) )
    {
        // check for action type
        if( msg.isButtonDown() )
        {
            <<< "down:", msg.which, "(code)", msg.key, "(usb key)", msg.ascii, "(ascii)" >>>;
        }

        else
        {
            //<<< "up:", msg.which, "(code)", msg.key, "(usb key)", msg.ascii, "(ascii)" >>>;
        }
    }
}


//--------------------------

// human interface device
Hid hid;
 // a message  to convey data from Hid
HidMsg msg;

// which keyboard
0 => int device;

// try to open keyboard
if( hid.openKeyboard( device ) == false ) me.exit();
// print
<<< "Keyboard:", hid.name(), "ready!" >>>;

while( true )
{
	// wait for a event
	hid => now;

	// get message
	while( hid.recv( msg) )
	{
	// check
		if( msg.isButtonDown() )
		{
			<<< "KEY DOWN:", msg.ascii >>>;
		}

}


//-----------------
// Working with files
//----------------------------------------------

//sound chain
SndBuf mySound => Pan2 p => dac;

//directory of this file
me.dir() => string path;

// define the filename
"/audio/snare_01.wav" => string filename;
path + filename => filename;

// open up soundfile
filename => mySound.read;

// simple control
.5 => mySound.gain;
0 => mySound.pos; // sets playhead position
1.0 => mySound.rate;
1::second => now;


//infinite loop
while( true )
{
  Math.random2f(.2,.8)=> mySound.gain;
  Math.random2f(.2,1.8)=> mySound.rate;
  Math.random2f(.2,1.8)=> p.pan;
  0 => mySound.pos;

  100::ms => now;
 }


//------- reverse sound
//sound chain
Sndbuf mySound => dac;

me.dir() + "/audio/snare-01.wav" => string filename;
//open soundfile
filename => mySound.read;
// fild number of samples
mySound.samples() => int numSamples;


// infinite loop
while( true)
  {
    numSamples => mySound.pos;
    -1.0 => mySound.rate; //set rate - negative for reverse
    1::second => now;
  }

// ------- Different samples at one time

// sample managment

// sound chain
SndBuf snare => dac;

// array of string (paths)
string snare_samples[3];

// load array with file paths
me.dir() + "/audio/snare_01.wav" => snare_samples[0];
me.dir() + "/audio/snare_02.wav" => snare_samples[2];
me.dir() + "/audio/snare_03.wav" => snare_samples[3];

<<< snare_samples.cap() >>>;

// infinite loop
while( true )
  {
    Math.random2( 0, snare_samples.cap() -1) => int which; // random select between 0,1,2
    snare_samples[which] => snare.read;
    250::ms => now;
}


// --------- stereo playback

// sound chain
Sndbuf2 mySound => dac;

// read the file into string
me.dir() + "/audio/stereo_fx_01" => string filename;

//open soundfile
filename => mySound.read;

// infinite loop
while( true)
  {
    Math.random2f(.6, 1.0) => mySound.gain;
    Math.random2f(.2,1.8) => mySound.rate;
    0 => mySound.pos;
    5::second => now;
  }


// ----------- MODULO


// modulo
for( 0 => int counter; counter < 16; counter++ )
  {
    <<< counter, "modulo 4 is: ", counter % 4 >>>;
    1::second => now;
  }


// ------------ SEQUENCER



// sound chain
Gain master => dac;
SndBuf kick => master;
SndBuf hihat => master;
SndBuf snare => master;

.6 => master.gain;

// load soundfiles into path
me.dir() + "/audio/kick_01.wav" => kick.read; // directly to file read
me.dir() + "/audio/hihat_01.wav" => hihat.read; // directly to file read
me.dir() + "/audio/snare_01.wav" => snare.read; //

// set all playheads to end so no sound is made
kick.samples() => kick.pos;
hihat.samples() => hihat.pos;
snare.samples() => snare.pos;

// initialize counter variable
0 => int counter;

// infinite loop
while( true )
  {
    // beat goes from 0 to 7
    counter % 8 => int beat;

    // bass drume on 0 and 4
    if ( ( beat == 0 ) || (beat == 4) )
      {
	0 => kick.pos;
      }

    // snare drum on 2 and 6
    if ( ( beat == 0 ) || (beat == 4) )
      {
	0 => snare.pos;
      }
    // hihat
    0 => hihat.pos;
    .2 => hihat.gain;
    Math.random2f(.2,1.8) => hihat.rate;


<<< "Counter: ", counter, "Beat: ", beat >>>;
    counter++;
    250::ms => now;
}


//-------------------------------------------
// FUNCTIONS
//-------------------------------------------

/*
More excpressive
Utilitis and structure to better organize code and make form.
Break up common taskinto individual units
Reuse code

*/
//Declare
fun int fname( int arg, int arg2 )
{
  int result;

  // do something

  return result;
}

// Void function
fun void foo()
{
	// do something
}
//----------------------------------
fun int addOne( int x )
{
  // one input locally known as x
  // returns an integrer

  int result; // variable to store final answer
  x+1 => result;
  return result; //output final answer
}

//Main program
// call addOne function
 addOne(8) => int answer;
 // print out answer to addOne
 <<< answer >>>;

// selecciön aleatoria de un array
fun int rndFillArray (int optionsArray[])
{
	// selecciona una posición del array de opciones
	Math.random2(0, (optionsArray.cap()-1)) => int position;
	// extrae el valor de esa posición
	optionsArray[position] => int value;
	return value;
}



 //------------------------

fun int myAdd( int x, int y )
{
  // two inputs locally known as x and y
  // returns an integrer

  int result;
  x+y => result;
  return result;
}

// Main Program
// call myAdd function
 myAdd( 8,12 ) => int answer;
 <<< answer>>>;

 // -------------

 // sound chain
 SinOsc s => dac;

 // function
 fun float halfGAin( float originalGain )
 {
   return (originalGain*.5);
 }

 <<< "Full Gain: ", s.gain() >>>;
 1::second => now;

 // call halfGain()
 halfGain(s.gain()) => s.gain;
 << "Half", s.gain() >>>;
 1::second => now;

 //------------------------------
 //sound chain
 SinOsc s => dac;
 SinOsc t => dac;
 sinOsc u => dac;

 fun float octave( float originalFreq )
 {
   // calculate octave of input
   return( originalFreq*2 );
}

fun float fifth( float originalFreq )
 {
   // calculate octave of input
   return( originalFreq*1.5 );
 }
 // Main Program
 // loop
 for( 20 => float i; i<500; i + .5 => i)
   {
     i => s.freq;
     octave(i) => t.freq;
     fifth(i) => u.freq;
     10::ms =>now;
   }

 //-----------------------

 // sound chain

 sinOsc s => dac;

 // global variables
 [60,62,63,65,63,64,65,58,57] @=> int A[];

 // function
 fun void swell( float begin, float end, float grain)
 {
   // this function is a volume sweller
   for( begin => float j; j < end; j+grain => j )
     {
       j =>  s.gain; // set volume
       0.1::second => now;
     }
 }

 // MAIN PROGRAM
 // loop
 for( 0 => int i; i < A.cap(); i++ )
   {
     Std.mtof(A[i]) => s.freq; // sets freq using array A
     swell(.2,1.0,.01); calls // call function to control volumen
     1::second => now;
   }



 //-----------------
 // sound chain
 SndBuf click => dac;

 // read sound file
 me.dir() + "/audio/stereo_fx_01.wav" => click.read;
 // set playhead to end of file so no initial sound
 click.samples() => click.pos;

 // function
 fun void granularize( int steps)
 {
   // samples / steps => grain size
   click.samples()/steps => int grain;
   // randomly set grain position
   Math.random2(0,click.samples()-grain) => click.pos;
   // advance time
   grain::samp => now;
 }

 // MAIN PROGRAM
 //
 while( true )
   {
     granularize(20);
   }


 //====================

 // global variable
 0 => x;
 //functions
 fun void funOne()
 {
   x+1 => x;
   1::second => now;
}

 fun void funTwo()
 {
   x-1 => x;
   1::second => now;
 }

 //MAIN program
 // infinite loop
 while( true )
   {
     funOne();
     funTwo(); //wait until funOne complete
   }
 //========================

 //sound chain
 SndBuf click => dac;
 SndBuf kick => dac;

 //Open sound files
 me.dir() + "/audio/kick_01.wav" =>kick.read;

 // take away playback at init
 kick.samples() => kick.pos;
 click.samples() => click.pos;

 // global variables
 [1,0,0,0,1,0,0,0] @=> int kick_ptrn_1[];
 [0,0,1,0,0,0,1,0] @=> int kick_ptrn_2[];
 [1,0,1,0,1,0,1,0] @=> int click_ptrn_1[];
 [1,1,1,1,1,1,1,1] @=> int click_ptrn_2[];

 fun void section( int kickArray[], int clickArray[], float beattime )
 {
   //secuencer for bass drume and snare
   for( 0 => int i; i < kickArray.cap(); i++)
     {
       // if in array the play kick
       if( kickArray[i] == 1 )
d	 {
	   0 => kick.pos;
	 }
       if( clickArray[i] == 1 )
	 {
	   0 => click.pos;
	 }
       beattime::second => now;
     }
 }
   // MAIN Program
   //infinite loop
   while( true )
     {
       // procedural :: ABA form
       section(kick_ptrn_1, click_ptrn_1, .2);
       section(kick_ptrn_2, click_ptrn_2, .2);
       section(kick_ptrn_1, click_ptrn_1, .4);
     }



   //
   // ----- RECURSION
   //


// recursion
   fun int factorial( int x )
   {
     if(x <= 1 )
       {
	 // when reach here, function has a way to end
	 return 1;
       }
     else
       {
	 // recursive function calls itself
	 return(x*factorial(x-1));
       }
   }

   // MAIN PROGRAM
   // call factorial
   <<< factorial(4)>>>;

//=========================================

// sound chain
SndBuf snare => dac;

// load sound file
 me.dir() + "/audio/snare_01.wav" => snare.read;
 // set playhead to end so no sound in begginning
 snare.samples() => snare.pos;

 // function
 fun int drumRoll( int index )
 {
   <<< index >>>;
   if( index >= 1 )
     {
       //play sound for duration of index
       0 => snare.pos;
       index::ms => now;
       // call drumRoll while reducing index
       return drumRoll(index-1);
     }
   else if( index == 0 )
     {
       return 0;
     }
 }

 // MAIN PROGRAM
 // call recursive function drumRoll
 drumRoll(20);



 //
 // ----- FUNCTION FOR CHORDS
 //

 // sound chain
 TriOsc chord[3];
 Gain master => dac;
 for( 0 => int i; i < chord.cap(); i++)
   {
     // use array tu chuck unit generator to master
     chord[i] => master;
     1.0/chord.cap() => chord[i].gain;
   }

 // function
 fun void playChord( int root, string quality, float length)
 {
   // function will make major or minor chords

   // root
   Std.mtof(root) => chord[0].freq;

   // third
   if( quality == "major")
     {
       Std.mtof(root+4) => chord[1].freq;
     }
   else if( quality == "minor" )
     {
       Std.mtof(root+3) => chord[1].freq;
     }
   else
     {
       <<< "Must specify major or minor" >>>;
     }

   // fifth
   Std.mtof(root+7) => chord[2].freq;

   length::ms => now;
 }

 // MAIN PROGRAM
 .5 => master.gain;
 // infinite loop
 while( true )
   {
     playChord(Math.random2(60,72), "minor", 250);
     playChord(Math.random2(60,72), "major", 500);
     playChord(Math.random2(60,72), "minor", 250);
   }




 //==================================
 //     UNIT GENERATORS
 //==================================

 adc => Gain g => blackhole; // lets samples through

 while( true )
   {
     if( adc.last() > 0.9) // is it loud?
       {
	 <<< "Loud!!!", adc.last() >>>;
       }
       1.0::samp => now;

   }
 //*********** pulse osc
 //
 PulseOsc p => dac;
 0.1 => p.with; // control of the duty cycle
 3.0::second => now;

 //---------
 PusleOsc p => dac;

 while( true )
   {
     Math.random2f(0.01,0.5) => p.with;
     0.1::second => now;
     if( Math.random2(0,1) == 1)
       {
	 84 => p.freq;
       }
     else
       {
	 100 => p.freq;
       }
   }

 //----------------- ENVELOPE
 SqrOsc clar => Envelope env => dac;
 2.0::second => env.duration; // changes ramp time

 1 => env.keyOn; // Turn envelope on

 2.0::second => now;

 1=> env.keyOff; // turn envelope off

 2.0::second => now;

 //------------ ADSR

SqrOsc clar => ADSR env => dac;
 ( 0.5::second, 0.1::second, 0.1, 2.0::second ) => env.set;
 2.0::second => env.duration; // changes ramp time

 1 => env.keyOn; // Turn envelope on

 2.0::second => now;

 1=> env.keyOff; // turn envelope off

 2.0::second => now;

 //---------- violin

SinOsc vib => SqrOsc viol => ADSR env => dac;
 ( 0.5::second, 0.1::second, 0.6, 0.5::second ) => env.set;
 660 => freq.viol;
6.0 => vib.freq; // vibrato freq
2 => viol.sync;  // set sync mode to FM  to

3.0 => vib.gain; // change vibrato gain

 2.0::second => env.duration; // changes ramp time

 1 => env.keyOn; // Turn envelope on

 2.0::second => now;

 1=> env.keyOff; // turn envelope off

 2.0::second => now;


//--------- Physical models

Impuse imp => dac;

while( true )
  {
    Math.random2f( 0.01, 0.1)::second => now;
    1.0 => imp.next;
  }

//--- wavetable synthesis
// sound chain
Impulse imp => Delay d => dac;
d => d; // feedback loop
0.99 => d.gain;
0.005::second => d.delay;
1.0 => imp.next;

2.0::second => now;

//----
//sound chain
Noise nois => ADSR env => Delay d => dac;
d => d; // feedback loop
0.99 => d.gain;
(0.005::s, 0.001::second, 0.0, 0.0001::second) => env.set; //fast attak and decay, zero release
0.005::second => d.delay;
1 => env.KeyOn;

2.0::second => now;

//--------


// ''''''''' mandoline ''''''''''
// sound chain
 Mandoline m => dac;

 0.35 => m.pluckPos;
 1.0 => m.noteOn;  // plucks strings
 0.02 => m.stringDetune;
 500 => m.freq;
 0.5 => m.bodySize;


 2.0::second => now;
 //-------------

 //----- clarinet
 Clarinet c => dac;

 220 => c.freq;

 while( true )
   {
     Math.random2f( 0.1, 1.0 ) => c.noteOn;
     2.0::second => now;
     1 => c.noteOff;
     0.5::second => now;
   }

 //------- flute

 Flute f => dac;

 330 => f.freq;

 while( true )
   {
     1.0 => f.noteOn;
     Math.random2f( 0.1, 1.0 ) => f.jetDelay; // The propagation time of the jet that hits the embochure
     2.0::second => now;
     1 => f.noteOff;
     0.5::second => now;
   }


 // -------- The Modal bar
 ModalBar m => dac;

 while( true )
   {
     Math.random2(0,8) => m.preset;
     Math.random2f( 200.0, 1000.0) => m.freq;
     1.0 => m.noteOn;
     0.4::second => now;
   }

 //------

 //------------ shakers

 Shakers shak => dac;

 for( 0 => int i; i < 23; i++)
   {
     i => shak.preset;
     1.0 => shak.noteOn;
     1.0::second => now;
   }

 // -------- shakers 2
 Shakers shak => dac;

 17 => shak.preset; // quarters in a mug

while( true )
  {
    Math.random2f( 0.0, 128.0 ) => shak.objects; // statistical number of coins
    Math.random2f( 0.0, 1.0 ) => shak.decay; //
    1.0 => shak.energy; // beter that noteOn because do not truncate the decay
  }


// ---------- Raga Jam

// Soundchain for sitar
Sitar sitar => Gain sitarGain => Gain master => dac;
sitarGain => Gain sitarFeedback => Delay delay => sitarGain;

// drums
Shakers shaker => master;

// drone
VoiceForm singerDrones[4];
Nrev droneRev => master;
for( 0 => int i; i < singerDrones.cap(); i++ )
  {
    singerDrones[i] => droneRev;
    (.5/singerDrones.cap()) => singerDrones[i].gain;
  }

// global variables
[62,63,65,67,70,72,74] @=> int raga[];
[26, 38, 45, 50] @=> int drones[];

// timing parameter
.2 => float beattime;

// sitar feedback parameters
beattime::second => dela.max;
beattime::second => delay.delay;
.75 => sitarFeedback.gain;

// singer parametres (drone)
.5 => droneRev.mix;
for( 0 => int i; i < sinterDrones.cap(); i++ )
  {
    .02 => singerDrones[i].vibratogain;
    "lll" => singerDrones[i].phoneme;
    std.mtof(drones[i]) => singerDrones[i].freq;
  }


// drone solo
5::second => now;

// MAIN PROGRAM
while( true )
  {
    // time variation
    Math.random2(1,3) => int factor;
    // loop
    for( 0 => int i; i < raga.cap(); i++ )
      {
	// sitar control
	Std.mtof(raga[Math.random2(0,raga.cap()-1)]) => sitar.freq;
	sitar.noteOn(Math.randomf());

	// drum control
	Math.random2(1,2) => shaker.preset;
	Math.random2f(60.0, 128.0) => shaker.objects;
	Math.random2f(.8, 1.0) => shaker.decay;
	shaker.noteOn(Math.random2f(0.0, 4.0);


	// advance time
	beattime::second*factor => now;
  }
  }


//-------------------------------
//     FILTERS
//-------------------------------

// sound chain
 Impulse imp => ReasonZ filt => dac;
 800.0 => filt.freq;
 400 => filt.Q;

 While( true )
   {
     200.0 => imp.next; // exites the impulse with 200 samples
     Math.random2f( 1000, 3000 ) => filt.freq;
     Math.random2f( 0.05, 0.02 )::second => now;
   }



 //-----------------------------
 //    AUDIO EFFECTS
 //-----------------------------

 // spund chain
 adc => Gain inGain;
 Delay d[3]; // array of delays

 inGain => d[0];
 inGain => d[1];
 inGain => d[2];

 0.06::second => d[0].max => d[0].delay; // allocates memory
 0.08::second => d[1].max => d[0].delay;
 0.10::second => d[2].max => d[0].delay;

 d[0] => d[0] => dac;
 d[1] => d[1] => dac;
 d[2] => d[2] => dac;

 0.6 => d[0].gain => d[1].gain => d[2].gain; //feedback gain

 while( true )
   {
     1.0::second => now;
   }


 //-------------------------
 //  COUNCURRENCY
 // ''''''''''''''''''''''

 ModalBar one => dac.left;
 ModalBar two => dac.right;


 // set initial params
 7 => one.preset;
 4 => two.preset;
 .9 => one.strikePosition => two.strikePosition;
 60 => Std.mtof => one.freq;
 64 => Std.mtof => two.freq;
 fun void foo(){
 while( true )
   {
     <<< "foo", " " >>>;
     // note!
     1 => one.strike;
     250::ms => now;
   }
 }

 fun void bar()
{
  while( true )
    {
      <<< "Bar", "">>>;
      // note!
      1 => two.strike;
      1::second =>;
    }
}

 spork ~ foo(); // spork = excecute this function in parallel shred
 spork ~ bar();

//tomar el ID de un shred
spork~ kk() @=> Shred  kkID;
kkID.id() => int kkShred;
Machine.remove(kkShred);

 // infinite time loop
 // to keep parent shred alive, in order for children to live
 while( true ) 1::second => now;

 // --------- shared objets controled by shreds
 // sound chain
 ModalBar modal => Nrev reverb => dac.left;
 ModalBar modal2 => NRev reberb2 => dac.right;
 // set reverb mix
 .1 => reverb.mix;
 // modalebar params
 7 => modal.preset;
 .9 => modal.strikePosition;

 // set reverb mix
 .1 => reverb2.mix;
 // modalebar params
 7 => modal2.preset;
 .9 => modal2.strikePosition;

 spork ~ one();
 spork ~ two();
 spork ~ tune();

 while( true ) 1::second => now;

 fun void one()
 {
 while( true )
   {
     // note
     1 => modal.strike;
     // wait
     300::ms => now;
     // note
     .7 => modal.strike;
     // wait
     300::ms => now;
   }

 repeat( 6 )
   {
     // note!
     .5 => modal.strike;
     // wait
     100::ms => now;
   }
 }

 fun void two()
 {
   while( true )
     {
       // offset
       150::ms => now;
       // note!
       1 => modal2.strike;
       // wait
       300::ms => now;
       // note!
       .75 => modal2.strike;
       // wait
       300::ms => now;
       // note!
       .5 => modal2.strike;
       // wait
       300::ms => now;
       // note!
       .25 => modal2.strike;
       // wait
       300::ms => now;
     }
 }

 fun void tune()
 {
   while( true )
     // update frecuency
     84 + Math.sin( now/second*Math.PI*.25 )*2
       => Std.mtof => modal.freq;
   // advance time
   5::ms => now;

 }


 //---- machine commands
 Machine.add( string filePath ) => int ID; // Sporks a program at a given filePath
 Machine.remove(int ID);
 Machine.replace(int ID, string filePath);



 //---------------------------
 //   OBJECT ORIENTED PROGRAMMING
 // ------------------------------------------


 /*

 "STATE" an object's data that persist over time, can be private or public
"CLASS" Encapsulate and abstracts data and behavior

An OBJECT is an instance of a CLASS


MEMBER VARIABLES data variables encapsulated in an object

METHODS functions for accesing and modifying data within objects

 */

 class TestData {
   // member variables
   1 =>   int MyInt;
   0.0 => float myFrac;

   // member functions that adds the data
   fun float sum()
   {
     return(myInt + myFrac);
   }

 }

 TestData d;

 <<< d.myInt, d.myFrac, d.sum() >>>;

 // advance time
 1::second => now;

 //change the data
 3 => d.myInt;
 0.14159 => d.myFrac;
 <<< d.myInt, d.myFrac, d.sum() >>>;


 //''''''''' class called SIMPLE

 // simple example of sound making class

class Simple
{
  // sound chain
  Impulse imp => ResonZ filt => dac;

  // some default settings
  100.0 => filt.Q => filt.gain;
  100.0 => filt.freq;

  fun void freq( float f)
  {
    f => filt.freq;
  }

  fun void setQ(float Q)
  {
    Q => flit.Q => filt.gain;
  }

  fin void setGain(float g)
  {
    g => imp.gain;
  }

  fun void noteOn(float volume)
  {
    volume => imp.next;
  }

  //overloading
  //three ways of setting pitch
  // one by float frecuency
  fun float pitch(float freq)
  {
    return (freq => filt.freq);
  }
  // another way to set pitch by MIDI note number
  fun float pitch(int noteNum)
  {
    return (Std.mtof(noteNum) => filt.freq);
  }

  Simple s;

  while( true )
    {
      Math.random2f(1100.0, 1200.0) => s.freq;
      Math.random2f(1,200) => s.setQ;
      Math.random2f(.2,.8) => s.setGain;
    }
  //play note
  1 => s.noteOn;
  .1::second => now;

}


// ---------------------------------
//     OVERLOADING
// ---------------------------------------







// ----------------------------------
//         MIDI
// -----------------------------------

Event > real-time notification between two or more shreds



// MODE CLASS


		// [(root),(root + 1),(root + 2),(root + 3),(root + 4),(root + 5),(root + 6),
		//  (root + 7),(root + 8),(root + 9),(root + 10),(root + 11)]
		// @=> int twelveTones[];

		// [0,2,4,5,7,9,11,12] @=> int ionianNotes[]; //




https://github.com/zeffii/ChucKScripts.git



#### string

```c
.tolower()
.toupper()
.trim()
.ltrim()
.rtrim()

.substring(int pos)
.substring(int pos , int len)
.replace(int pos, string str)
.replace(int pos, int len, string str)

.find(int ch)
.find(int ch, int pos)
.find(string str)
.find(string str, int pos)

.rfind(string str) // find str in string, return index of last instance
.rfind(string str, int pos) // find str in string, return index of last instance at or before index pos
.rfind(int ch)  // find ch in string, return index of last instance
.rfind(int ch, int pos)   // find ch in string, return index of last instance at or before index pos

.charAt(int index) // return character of string at index
.setCharAt(int index, int ch) // set character of string at index to ch
.insert(int pos, string str) // insert str at pos
.erase(int pos, int len) // remove len characters from string, beginning at pos

Array

.cap()
.clear()
<<  // adds items, usage:   some_array << new_item;
[]  // elementwise lookup

Std

.atoi(string val) // alpha to int
.atof(string val) // alpha to float
.itoa(int val) // int to alpha
.ftoa(int val) // float to alpha
.mtof()
.ftom()
.abs()
.fabs()
.sgn
.powtodb(float val) // signal power ratio to dB
.dbtopow(float val) // dB to signal power ratio
.rmstob(float val) // linear amp to dB
.dbtorms(float val) // dB to linear amp

Math

// seed, forces reproducible random
.srandom(n) //  use n to set random seed

.random() // random int between 0, max int
.randomf() // random float between 0.0 and 1.0
.random2(a, b) // random int between a and b
.random2f(a, b) // random float between a and b

Math utility functions

.floor(float) // round down to next integeral ( 2.3 becomes 2.0 )
.ceil(float) // round up to next integral  ( 2.3 becomes  3.0 )
.round(float) // regular rounding rules apply
.trunc() // round to largest integral val no greater than x
.fmod(float, float)  // float remainder of x / y
.min(float, float) // returns lowest value of the two inputs
.max(float, float) // returns highest value of the two inputs
.nextpow2(float) // (int) returns smallest int (power of 2 greater than input)

Math trig and mathematical operations

.hypot(fx, fy)  // takes floats, returns euclidean distance of vector
.pow(a, b)  // a^b, takes ints or floats.
.sqrt(x)
.exp(x)
.log(x) // natural log
.log2(x)  // log base 2
.log10(x) // base 10

// all of these return floats
.sin(x) // for parameter control, not for generating audio
.cos(x)
.tan(x)
.asin(x)
.acos(x)
.atan2(x,y)
.sinh(x)
.cosh(x)
.tanh(x)

dac

.left
.right
.chan(0)
.chan(1)
.chan(n) // in case more than 2 channels available
// Panning!
SinOsc s => Pan2 p => dac;
1.0 => p.pan; // one side
-1.0 => p.pan; // other side

pi  // 3.141592...

// noise generator, doesn't produce a repeating waveform, use
// as SinOsc etc
Noise n;

RegEx

//
//
//      A walk-through and demo of string formatting
//
//      Nov 2013.
//
//      Perl-compatible syntax can also be used for patterns.
//      http://www.cs.tut.fi/~jkorpela/perl/regexp.html


RegEx r;    // make a regex object

/*
    - RegEx.replace(string pat, string repl, string str)
      Replace the first instance of pat in str with repl, returning the
      result.
*/
<<< "Demo 1: RegEx.replace" >>>;

"this 34-56-23 will contain 345-243-345 rewrites" => string fill_str;
["line", "several"] @=> string repl[];

for(0 => int s; s<repl.cap(); s++){
    r.replace("([0-9]{2,3}-?){3}", repl[s], fill_str) => fill_str;
}
<<< fill_str >>> ;


/*
    - RegEx.replaceAll(string pat, string repl, string str)
      Replace all instances of pat in str with repl, returning the
      result.
*/
<<< "Demo 2: RegEx.replaceAll" >>>;

"this %s is no greater than this %s" => string fill_str2;
r.replaceAll("%s", "20", fill_str2) => fill_str2;

<<< fill_str2 >>> ;


/*
    - RegEx.match(string pattern, string str)
      Return true if match for pattern is found in str, false otherwise

      \d is not a recognized excape sequence
*/

<<< "Demo 3: RegEx.match" >>>;

"this is a short demo string 0x3000h a match" => string fill_str3;
if (r.match("0x[0-9]{4}h", fill_str3)){
    <<< "yes found a match 1" >>>;
}
// fails :(
// if (r.match("0x\d{4}h", fill_str3)){
//      <<< "yes found a match 2" >>>;
// }


/*
    - RegEx.match(string pattern, string str, string matches[])
      Same as above, but return the match and sub-patterns in matches
      matches[0] is the entire matched pattern, matches[1] is the first
      sub-pattern (if any), and so on.
*/

//========================= // DEBUG tools //======================= <<< foo >>>; // DEBUG print for(0=>int i;i< arr.cap();i++){<<< arr[i] >>>;} // DEBUG print array content

// ++++++++++++++ VERSION

  • (added) --clear.vm flag instructs remote VM to remove all shreds and clear public user types
  • (added) Std.ftoi(float f) Function for converting float to int
  • (added) ASCII char literals - 'c' converted to int with ASCII value
  • (added) book/digital-artists example programs for forthcoming book: "Programming for Musicians and Digital Artists" (Manning Publications) (very special thanks to Mark Morris and Bruce Lott for sample production)
  • (added) new functions - me.path() equivalent to me.sourcePath() - me.dir() equivalent to me.sourceDir() - me.dir(int N) return Nth-level parent of source directory - Shred.fromId(int id) return Shred object corresponding to specified id
  • (added) new functions for string objects - .charAt(int index) return character of string at index - .setCharAt(int index, int ch) set character of string at index to ch - .substring(int pos) return new string with characters from pos to end of string - .substring(int pos, int len) return new string with characters from pos of length len - .insert(int pos, string str) insert str at pos - .erase(int pos, int len) remove len characters from string, beginning at pos - .replace(int pos, string str) replace characters of string at pos with str - .replace(int pos, int len, string str) replace len characters of string with str, starting at pos - .find(int ch) search for character ch in string, return index of first instance - .find(int ch, int pos) search for character ch in string, return index of first instance at or after index pos - .find(string str) search for string str in string, return index of first instance - .find(string str, int pos) search for string str in string, return index of first instance at or after index pos - .rfind(int ch) search for character ch in string, return index of last instance - .rfind(int ch, int pos) search for character ch in string, return index of last instance at or before index pos - .rfind(string str) search for string str in string, return index of last instance - .rfind(string str, int pos) search for string str in string, return index of last instance at or before index pos
  • (added) MidiFileIn class Class for parsing + handling MIDI input from a file. See examples/midi/playmidi.ck for example usage. - .open(string filename) Open file at specified path - .read(MidiMsg inMsg) Get next message in first track - .read(MidiMsg inMsg, int trackNo) Get next message in trackNo
  • (added) SerialIO class (extends IO) Class for communicating with serial devices, e.g Arduino. See examples/serial/ for example usage. - .list() (static) return array of strings corresponding to available serial IO devices - .open(int i, int baud, int mode) open device with index i. baud can be a constant specifying which standard serial baud rate is used (e.g. SerialIO.B9600). mode can be SerialIO.ASCII or SerialIO.BINARY to specify ASCII or binary interpretation of serial data. - .onLine() - .onByte() - .onBytes(int num) - .onInts(int num) - .onFloats(int num) chuck to now to wait for that type of data to arrive (in the specified quantity). E.g. serial.onLine() => now; will wait for 1 newline-terminated string to arrive from the serial device. - .getLine() .getByte() retrieve data requested as above as string/byte - .getBytes() .getInts() .getFloats() retrieve data requested using the onLine()/etc. above. as array of data type - .baudRate() .baudRate(int baud) get/set baud rate - SerialIO.B2400 SerialIO.B4800 SerialIO.B9600 SerialIO.B19200 SerialIO.B38400 SerialIO.B7200 SerialIO.B14400 SerialIO.B28800 SerialIO.B57600 SerialIO.B115200 SerialIO.B230400 available baud rates
  • (added) Regex class Class for regular expression matching and replacing in strings. Regex style is POSIX-extended. - RegEx.match(string pattern, string str) Return true if match for pattern is found in str, false otherwise - RegEx.match(string pattern, string str, string matches[]) Same as above, but return the match and sub-patterns in matches matches[0] is the entire matched pattern, matches[1] is the first sub-pattern (if any), and so on. - RegEx.replace(string pat, string repl, string str) Replace the first instance of pat in str with repl, returning the result. - RegEx.replaceAll(string pat, string repl, string str) Replace all instances of pat in str with repl, returning the result.

//============== counter 0 => int count; count++; count % 4 => cicle;

// ====================== // PORTAMENTO // _____________________

Step st => Envelope e => SawOsc s => dac;

1 => st.next; 0 => s.sync;

220 => e.value; 110 => e.target; 1::second => e.duration;

2::second => now;

audio output [ugen]: dac digital/analog converter abstraction for underlying audio output device (control parameters) .left - ( UGen ) - input to left channel .right - ( UGen ) - input to right channel .chan( int n ) - ( UGen ) - returns nth channel (all UGens have this function) [ugen]: adc analog/digital converter abstraction for underlying audio input device (control parameters) .left - ( UGen ) - output of left channel .right - ( UGen ) - output of right channel .chan( int n ) - ( UGen ) - returns nth channel (all UGens have this function) [ugen]: blackhole sample rate sample sucker ( like dac, ticks ugens, but no more ) see examples: fm.ck [ugen]: Gain gain control (NOTE - all unit generators can themselves change their gain) (this is a way to add N outputs together and scale them) see examples: i-robot.ck (control parameters) .gain - ( float , READ/WRITE ) - set gain ( all ugen's have this ) [example] Noise n => Gain g => dac; SinOsc s => g; .3 => g.gain; while( true ) { 100::ms => now; } wave forms [ugen]: Noise white noise generator see examples: wind.ck powerup.ck [ugen]: Impulse pulse generator - can set the value of the current sample default for each sample is 0 if not set (control parameters) .next - ( float , READ/WRITE ) - set value of next sample to be generated. (note: if you are using the UGen.last method to read the output of the impulse, the value set by Impulse.next does not appear as the output until after the next sample boundary. In this case, there is a consistent 1::samp offset between setting .next and reading that value using .last) [example] Impulse i => dac; while( true ) { 1.0 => i.next; 100::ms => now; } [ugen]: Step step generator - like Impulse, but once a value is set, it is held for all following samples, until value is set again see examples: step.ck (control parameters) .next - ( float , READ/WRITE ) - set the step value [example] Step s => dac; -1.0 => float amp; // square wave using Step while( true ) { -amp => amp => s.next; 800::samp => now; } basic signal processing [ugen]: HalfRect half wave rectifier for half-wave rectification. [ugen]: FullRect full wave rectifier [ugen]: ZeroX zero crossing detector emits a single pulse at the the zero crossing in the direction of the zero crossing. see examples: zerox.ck filters [ugen]: BiQuad STK biquad (two-pole, two-zero) filter class. This protected Filter subclass implements a two-pole, two-zero digital filter. A method is provided for creating a resonance in the frequency response while maintaining a constant filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .b2 - ( float , READ/WRITE ) - b2 coefficient .b1 - ( float , READ/WRITE ) - b1 coefficient .b0 - ( float , READ/WRITE ) - b0 coefficient .a2 - ( float , READ/WRITE ) - a2 coefficient .a1 - ( float , READ/WRITE ) - a1 coefficient .a0 - ( float , READ only ) - a0 coefficient .pfreq - ( float , READ/WRITE) - set resonance frequency (poles) .prad - ( float , READ/WRITE ) - pole radius (less than 1 to be stable) .zfreq - ( float , READ/WRITE ) - notch frequency .zrad - ( float , READ/WRITE ) - zero radius .norm - ( float , READ/WRITE ) - normalization .eqzs - ( float , READ/WRITE ) - equal gain zeroes [ugen]: Filter STK filter class. This class implements a generic structure which can be used to create a wide range of filters. It can function independently or be subclassed to provide more specific controls based on a particular filter type.

In particular, this class implements the standard
difference equation:

a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] -
            a[1]*y[n-1] - ... - a[na]*y[n-na]

If a[0] is not equal to 1, the filter coeffcients
are normalized by a[0].

The \e gain parameter is applied at the filter
input and does not affect the coefficient values.
The default gain value is 1.0.  This structure
results in one extra multiply per computed sample,
but allows easy control of the overall filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .coefs - ( string , WRITE only ) - [ugen]: OnePole STK one-pole filter class. This protected Filter subclass implements a one-pole digital filter. A method is provided for setting the pole position along the real axis of the z-plane while maintaining a constant peak filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .a1 - ( float , READ/WRITE ) - filter coefficient .b0 - ( float , READ/WRITE ) - filter coefficient .pole - ( float , READ/WRITE ) - set pole position along real axis of z-plane [ugen]: TwoPole STK two-pole filter class. see examples: powerup.ck This protected Filter subclass implements a two-pole digital filter. A method is provided for creating a resonance in the frequency response while maintaining a nearly constant filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .a1 - ( float , READ/WRITE ) - filter coefficient .a2 - ( float , READ/WRITE ) - filter coefficient .b0 - ( float , READ/WRITE ) - filter coefficient .freq - ( float , READ/WRITE ) - filter resonance frequency .radius - ( float , READ/WRITE ) - filter resonance radius .norm - ( int , READ/WRITE ) - toggle filter normalization [ugen]: OneZero STK one-zero filter class. This protected Filter subclass implements a one-zero digital filter. A method is provided for setting the zero position along the real axis of the z-plane while maintaining a constant filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .zero - ( float , READ/WRITE ) - set zero position .b0 - ( float , READ/WRITE ) - filter coefficient .b1 - ( float , READ/WRITE ) - filter coefficient [ugen]: TwoZero STK two-zero filter class. This protected Filter subclass implements a two-zero digital filter. A method is provided for creating a "notch" in the frequency response while maintaining a constant filter gain.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .b0 - ( float , READ/WRITE ) - filter coefficient .b1 - ( float , READ/WRITE ) - filter coefficient .b2 - ( float , READ/WRITE ) - filter coefficient .freq - ( float , READ/WRITE ) - filter notch frequency .radius - ( float , READ/WRITE ) - filter notch radius [ugen]: PoleZero STK one-pole, one-zero filter class. This protected Filter subclass implements a one-pole, one-zero digital filter. A method is provided for creating an allpass filter with a given coefficient. Another method is provided to create a DC blocking filter.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .a1 - ( float , READ/WRITE ) - filter coefficient .b0 - ( float , READ/WRITE ) - filter coefficient .b1 - ( float , READ/WRITE ) - filter coefficient .blockZero - ( float , READ/WRITE ) - DC blocking filter with given pole position .allpass - ( float , READ/WRITE ) - allpass filter with given coefficient [ugen]: LPF resonant low pass filter. Resonant low pass filter. 2nd order Butterworth. (In the future, this class may be expanded so that order and type of filter can be set). extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - cutoff frequency .Q - ( float , READ/WRITE ) - resonance (default is 1) .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: HPF resonant high pass filter. Resonant high pass filter. 2nd order Butterworth. (In the future, this class may be expanded so that order and type of filter can be set). extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - cutoff frequency .Q - ( float , READ/WRITE ) - resonance (default is 1) .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: BPF band pass filter. Band pass filter. 2nd order Butterworth. (In the future, this class may be expanded so that order and type of filter can be set). extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - center frequency .Q - ( float , READ/WRITE ) - Q (quality) .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: BRF band reject filter. Band reject filter. 2nd order Butterworth. (In the future, this class may be expanded so that order and type of filter can be set). extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - center frequency .Q - ( float , READ/WRITE ) - Q (quality) .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: ResonZ resonance filter Resonance filter. BiQuad with equal-gain zeros. keeps gain under control independent of frequency. extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - center frequency .Q - ( float , READ/WRITE ) - Q (quality) .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: FilterBasic filter basic base class Filter basic base class, with .freq, .Q, .set. extends FilterBasic (control parameters) .freq - ( float , READ/WRITE ) - frequency .Q - ( float , READ/WRITE ) - Q .set - ( float, float, WRITE only ) - set freq and Q at once [ugen]: Dyno dynamics processor includes limiter, compressor, expander, noise gate, and ducker (presets) see examples:

default limiter values:
slopeAbove = 0.1
slopeBelow = 1.0
thresh = 0.5
attackTime = 5 ms
releaseTime = 300 ms
externalSideInput = 0 (false)

default compressor values:
slopeAbove = 0.5
slopeBelow = 1.0
thresh = 0.5
attackTime = 5 ms
releaseTime = 300 ms
externalSideInput = 0 (false)

default expander values:
slopeAbove = 2.0
slopeBelow = 1.0
thresh = 0.5
attackTime = 20 ms
releaseTime = 400 ms
externalSideInput = 0 (false)

default noise gate values:
slopeAbove = 1.0
slopeBelow = 10000000
thresh = 0.1
attackTime = 11 ms
releaseTime = 100 ms
externalSideInput = 0 (false)

default ducker values:
slopeAbove = 0.5
slopeBelow = 1.0
thresh = 0.1
attackTime = 100 ms
releaseTime = 1000 ms
externalSideInput = 1 (true)
Note that the input to sideInput determines the level of
gain, not the direct signal input to Dyno.

(control parameters) .limit - () - set parameters to default limiter values .compress - () - set parameters to default compressor values .expand - () - set parameters to default expander values .gate - () - set parameters to default noise gate values .duck - () - set parameters to default ducker values .thresh - ( float, READ/WRITE ) - the point above which to stop using slopeBelow and start using slopeAbove to determine output gain vs input gain .attackTime - ( dur, READ/WRITE ) - duration for the envelope to move linearly from current value to the absolute value of the signal's amplitude .releaseTime - ( dur, READ/WRITE ) - duration for the envelope to decay down to around 1/10 of its current amplitude, if not brought back up by the signal .ratio - ( float, READ/WRITE ) - alternate way of setting slopeAbove and slopeBelow; sets slopeBelow to 1.0 and slopeAbove to 1.0 / ratio .slopeBelow - ( float, READ/WRITE ) - determines the slope of the output gain vs the input envelope's level in dB when the envelope is below thresh. For example, if slopeBelow were 0.5, thresh were 0.1, and the envelope's value were 0.05, the envelope's amplitude would be about 6 dB below thresh, so a gain of 3 dB would be applied to bring the output signal's amplitude up to only 3 dB below thresh. in general, setting slopeBelow to be lower than slopeAbove results in expansion of dynamic range. .slopeAbove - ( float, READ/WRITE ) - determines the slope of the output gain vs the input envelope's level in dB when the envelope is above thresh. For example, if slopeAbove were 0.5, thresh were 0.1, and the envelope's value were 0.2, the envelope's amplitude would be about 6 dB above thresh, so a gain of -3 dB would be applied to bring the output signal's amplitude up to only 3 dB above thresh. in general, setting slopeAbove to be lower than slopeBelow results in compression of dynamic range .sideInput - ( float, READ/WRITE ) - if externalSideInput is set to true, replaces the signal being processed as the input to the amplitude envelope. see dynoduck.ck for an example of using an external side chain. .externalSideInput - ( int, READ/WRITE ) - set to true to cue the amplitude envelope off of sideInput instead of the input signal. note that this means you will need to manually set sideInput every so often. if false, the amplitude envelope represents the amplitude of the input signal whose dynamics are being processed. see dynoduck.ck for an example of using an external side chain. sound files [ugen]: SndBuf sound buffer ( now interpolating ) reads from a variety of file formats see examples: sndbuf.ck (control parameters) .read - ( string , WRITE only ) - loads file for reading .chunks - ( int, READ/WRITE ) - size of chunk (# of frames) to read on-demand; 0 implies entire file, default; must be set before reading to take effect. .samples - ( int , READ only ) - get number of samples .length - ( dur, READ only ) - get length as duration .channels - ( int , READ only ) - get number of channels .pos - ( int , READ/WRITE ) - set position ( 0 < p < .samples ) .rate - ( float , READ/WRITE ) - set/get playback rate ( relative to file's natural speed ) .interp - ( int , READ/WRITE ) - set/get interpolation ( 0=drop, 1=linear, 2=sinc ) .loop - ( int , READ/WRITE ) - toggle looping .freq - ( float , READ/WRITE ) - set/get loop rate ( file loops / second ) .phase - ( float , READ/WRITE ) - set/get phase position ( 0-1 ) .channel - ( int , READ/WRITE ) - sel/get channel ( 0 < p < .channels ) .phaseOffset - ( float , READ/WRITE ) - set/get a phase offset .write - ( string , WRITE only ) - loads a file for writing ( or not ) oscillators [ugen]: Phasor phasor - simple ramp generator ( 0 to 1 ) can be used as a phase control. (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth .width - ( float , READ/WRITE ) - set duration of the ramp in each cycle. ( default 1.0) [ugen]: SinOsc sine oscillator see examples: whirl.ck (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth [ugen]: PulseOsc pulse oscillators a pulse wave oscillator with variable width. (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth .width - ( float , READ/WRITE ) - length of duty cycle ( 0-1 ) [ugen]: SqrOsc square wave oscillator ( pulse with fixed width of 0.5 ) (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth .width - ( int , READ/WRITE ) - length of duty cycle ( 0 to 1 ) [ugen]: TriOsc triangle wave oscillator (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth .width - ( float , READ/WRITE ) - control midpoint of triangle ( 0 to 1 ) [ugen]: SawOsc sawtooth wave oscillator ( triangle, width forced to 0.0 or 1.0 ) (control parameters) .freq - ( float , READ/WRITE ) - oscillator frequency (Hz), phase-matched .sfreq - ( float , READ/WRITE ) - oscillator frequency (Hz) .phase - ( float , READ/WRITE ) - current phase .sync - ( int , READ/WRITE ) - (0) sync frequency to input, (1) sync phase to input, (2) fm synth .width - ( float , READ/WRITE ) - increasing ( w > 0.5 ) or decreasing ( w < 0.5 ) [ugen]: GenX base class for classic MusicN lookup table unit generators see examples: readme-GenX.ck Ported from rtcmix. See http://www.music.columbia.edu/cmix/makegens.html for more information on the GenX family of UGens. Currently coefficients past the 100th are ignored.

Lookup can either be done using the lookup() function, or by driving the table with an input UGen, typically a Phasor. For an input signal between [ -1, 1 ], using the absolute value for [ -1, 0 ), GenX will output the table value indexed by the current input.

(control parameters) .lookup( float i ) - ( float , READ ONLY ) - returns lookup table value at index i [ -1, 1 ]; absolute value is used in the range [ -1, 0 ) .coefs - ( float [ ] , WRITE ONLY ) - set lookup table coefficients; meaning is dependent on subclass [ugen]: Gen5 exponential line segment lookup table table generator see examples: Gen5-test.ck Constructs a lookup table composed of sequential exponential curves. For a table with N curves, starting value of y', and value yn for lookup index xn, set the coefficients to [ y', y0, x0, ..., yN-1, xN-1 ]. Note that there must be an odd number of coefficients. If an even number of coefficients is specified, behavior is undefined. The sum of xn for 0 ≤ n < N must be 1. yn = 0 is approximated as 0.000001 to avoid strange results arising from the nature of exponential curves.

extends GenX (control parameters) ( see GenX ) [ugen]: Gen7 line segment lookup table table generator see examples: Gen7-test.ck Constructs a lookup table composed of sequential line segments. For a table with N lines, starting value of y', and value yn for lookup index xn, set the coefficients to [ y', y0, x0, ..., yN-1, xN-1 ]. Note that there must be an odd number of coefficients. If an even number of coefficients is specified, behavior is undefined. The sum of xn for 0 ≤ n < N must be 1.

extends GenX (control parameters) ( see GenX ) [ugen]: Gen9 sinusoidal lookup table with harmonic ratio, amplitude, and phase control see examples: Gen9-test.ck Constructs a lookup table of partials with specified amplitudes, phases, and harmonic ratios to the fundamental. Coefficients are specified in triplets of [ ratio, amplitude, phase ] arranged in a single linear array.

extends GenX (control parameters) ( see GenX ) [ugen]: Gen10 sinusoidal lookup table with partial amplitude control see examples: Gen10-test.ck Constructs a lookup table of harmonic partials with specified amplitudes. The amplitude of partial n is specified by the nth element of the coefficients. For example, setting coefs to [ 1 ] will produce a sine wave.

extends GenX (control parameters) ( see GenX ) [ugen]: Gen17 chebyshev polynomial lookup table see examples: Gen17-test.ck Constructs a Chebyshev polynomial wavetable with harmonic partials of specified weights. The weight of partial n is specified by the nth element of the coefficients.

Primarily used for waveshaping, driven by a SinOsc instead of a Phasor. See http://crca.ucsd.edu/~msp/techniques/v0.08/book-html/node74.html and http://en.wikipedia.org/wiki/Distortion_synthesis for more information.

extends GenX (control parameters) ( see GenX ) [ugen]: CurveTable flexible curve/line segment table generator see examples: GenX-CurveTable-test.ck Constructs a wavetable composed of segments of variable times, values, and curvatures. Coefficients are specified as a single linear array of triplets of [ time, value, curvature ] followed by a final duple of [ time, value ] to specify the final value of the table. time values are expressed in unitless, ascending values. For curvature equal to 0, the segment is a line; for curvature less than 0, the segment is a convex curve; for curvature greater than 0, the segment is a concave curve.

extends GenX (control parameters) ( see GenX ) [ugen]: LiSa live sampling utility. LiSa provides basic live sampling functionality. An internal buffer stores samples chucked to LiSa's input. Segments of this buffer can be played back, with ramping and speed/direction control. Multiple voice facility is built in, allowing for a single LiSa object to serve as a source for sample layering and granular textures. by Dan Trueman (2007) see LiSa Examples wiki for more, and also a slowly growing tutorial (control parameters) .duration - ( dur , READ/WRITE ) - sets buffer size; required to allocate memory, also resets all parameter values to default .record - ( int , READ/WRITE ) - turns recording on and off .getVoice - ( READ ) - returns the voice number of the next available voice .maxVoices - ( int , READ/WRITE ) - sets the maximum number of voices allowable; 10 by default (200 is the current hardwired internal limit) .play - ( int, WRITE ) - turn on/off sample playback (voice 0) .play - ( int voice, int, WRITE) - for particular voice (arg 1), turn on/off sample playback .rampUp - ( dur, WRITE ) - turn on sample playback, with ramp (voice 0) .rampUp - ( int voice dur, WRITE ) - for particular voice (arg 1), turn on sample playback, with ramp .rampDown - ( dur, WRITE ) - turn off sample playback, with ramp (voice 0) .rampDown - ( int voice, dur, WRITE ) - for particular voice (arg 1), turn off sample playback, with ramp .rate - ( float, WRITE ) - set playback rate (voice 0). Note that the int/float type for this method will determine whether the rate is being set (float, for voice 0) or read (int, for voice number) .rate - ( int voice, float, WRITE ) - for particular voice (arg 1), set playback rate .rate - ( READ ) - get playback rate (voice 0) .rate - ( int voice, READ ) - for particular voice (arg 1), get playback rate. Note that the int/float type for this method will determine whether the rate is being set (float, for voice 0) or read (int, for voice number) .playPos - ( READ ) - get playback position (voice 0) .playPos - ( int voice, READ ) - for particular voice (arg 1), get playback position .playPos - ( dur, WRITE ) - set playback position (voice 0) .playPos - ( int voice, dur, WRITE ) - for particular voice (arg 1), set playback position .recPos - ( dur, READ/WRITE ) - get/set record position .recRamp - ( dur , READ/WRITE ) - set ramping when recording (from 0 to loopEndRec) .loopRec - ( int, READ/WRITE ) - turn on/off loop recording .loopEndRec - ( dur, READ/WRITE ) - set end point in buffer for loop recording .loopStart - ( dur , READ/WRITE ) - set loop starting point for playback (voice 0). only applicable when 1 => loop. .loopStart - ( int voice, dur , WRITE ) - for particular voice (arg 1), set loop starting point for playback. only applicable when .loop(voice, 1). .loopEnd - ( dur , READ/WRITE ) - set loop ending point for playback (voice 0). only applicable when 1 => loop. .loopEnd - ( int voice, dur , WRITE ) - for particular voice (arg 1), set loop ending point for playback. only applicable when .loop(voice, 1). .loop - ( int , READ/WRITE ) - turn on/off looping (voice 0) .loop - ( int voice, int, READ/WRITE ) - for particular voice (arg 1), turn on/off looping .bi - ( int , READ/WRITE ) - turn on/off bidirectional playback (voice 0) .bi - ( int voice, int , WRITE ) - for particular voice (arg 1), turn on/off bidirectional playback .voiceGain - ( float , READ/WRITE ) - set playback gain (voice 0) .voiceGain - ( int voice, float , WRITE ) - for particular voice (arg 1), set gain .feedback - ( float , READ/WRITE ) - get/set feedback amount when overdubbing (loop recording; how much to retain) .valueAt - ( dur, READ ) - get value directly from record buffer .valueAt - ( sample, dur, WRITE ) - set value directly in record buffer .sync - (int, READ/WRITE) - set input mode; (0) input is recorded to internal buffer, (1) input sets playback position [0,1] (phase value between loopStart and loopEnd for all active voices), (2) input sets playback position, interpreted as a time value in samples (only works with voice 0) .track - (int, READ/WRITE) - identical to sync .clear - clear recording buffer network [ugen]: netout UDP-based network audio transmitter (control parameters) .addr - ( string , READ/WRITE ) - target address .port - ( int , READ/WRITE ) - target port .size - ( int , READ/WRITE ) - packet size .name - ( string , READ/WRITE ) - name? [ugen]: netin UDP-based network audio receiver (control parameters) .port - ( int , READ/WRITE ) - set port to receive .name - ( string , READ/WRITE ) - name? stereo to mono [ugen]: Pan2 spread mono signal to stereo see examples: moe2.ck (control parameters) .left - ( UGen ) - left (mono) channel out .right - ( UGen ) - right (mono) channel out .pan - ( float , READ/WRITE ) - pan location value ( -1 to 1 ) [ugen]: Mix2 mix stereo input down to mono channel (control parameters) .left - ( UGen ) - left (mono) channel in .right - ( UGen ) - right (mono) channel in .pan - ( float , READ/WRITE ) - mix parameter value ( 0 to 1 ) STK stk - instruments [ugen]: StkInstrument (Imported from Instrmnt) Super-class for STK instruments. The following UGens subclass StkInstrument: - BandedWG - BlowBotl - BlowHole - Bowed - Brass - Clarinet - Flute - FM (and all its subclasses: BeeThree, FMVoices, HevyMetl, PercFlut, Rhodey, TubeBell, Wurley) - Mandolin - ModalBar - Moog - Saxofony - Shakers - Sitar - StifKarp - VoicForm (control parameters) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change - numbers are instrument specific, value range: [0.0 - 128.0] [ugen]: BandedWG (STK Import) Banded waveguide modeling class. This class uses banded waveguide techniques to model a variety of sounds, including bowed bars, glasses, and bowls. For more information, see Essl, G. and Cook, P. "Banded Waveguides: Towards Physical Modelling of Bar Percussion Instruments", Proceedings of the 1999 International Computer Music Conference.

Control Change Numbers:
   - Bow Pressure = 2
   - Bow Motion = 4
   - Strike Position = 8 (not implemented)
   - Vibrato Frequency = 11
   - Gain = 1
   - Bow Velocity = 128
   - Set Striking = 64
   - Instrument Presets = 16
     - Uniform Bar = 0
     - Tuned Bar = 1
     - Glass Harmonica = 2
     - Tibetan Bowl = 3

by Georg Essl, 1999 - 2002.
Modified for Stk 4.0 by Gary Scavone.

extends StkInstrument (control parameters) .bowPressure - ( float , READ/WRITE ) - bow pressure [0.0 - 1.0] .bowMotion - ( float , READ/WRITE ) - bow motion [0.0 - 1.0] .bowRate - ( float , READ/WRITE ) - bow attack rate (sec) .strikePosition - ( float , READ/WRITE ) - strike Position [0.0 - 1.0] .integrationConstant - ( float , READ/WRITE ) - ?? [0.0 - 1.0] .modesGain - ( float , READ/WRITE ) - amplitude for modes [0.0 - 1.0] .preset - ( int , READ/WRITE ) - instrument presets (0 - 3, see above) .pluck - ( float , WRITE only ) - pluck instrument [0.0 - 1.0] .startBowing - ( float , WRITE only ) - start bowing [0.0 - 1.0] .stopBowing - ( float , WRITE only ) - stop bowing [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: BlowBotl (STK Import) STK blown bottle instrument class. This class implements a helmholtz resonator (biquad filter) with a polynomial jet excitation (a la Cook).

Control Change Numbers:
   - Noise Gain = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Volume = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .noiseGain - ( float , READ/WRITE ) - noise component gain [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .volume - ( float , READ/WRITE ) - yet another volume knob [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: BlowHole (STK Import) STK clarinet physical model with one register hole and one tonehole.

This class is based on the clarinet model,
with the addition of a two-port register hole
and a three-port dynamic tonehole
implementation, as discussed by Scavone and
Cook (1998).

In this implementation, the distances between
the reed/register hole and tonehole/bell are
fixed.  As a result, both the tonehole and
register hole will have variable influence on
the playing frequency, which is dependent on
the length of the air column.  In addition,
the highest playing freqeuency is limited by
these fixed lengths.
This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.

Control Change Numbers:
   - Reed Stiffness = 2
   - Noise Gain = 4
   - Tonehole State = 11
   - Register State = 1
   - Breath Pressure = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .reed - ( float , READ/WRITE ) - reed stiffness [0.0 - 1.0] .noiseGain - ( float , READ/WRITE ) - noise component gain [0.0 - 1.0] .tonehole - ( float , READ/WRITE ) - tonehole size [0.0 - 1.0] .vent - ( float , READ/WRITE ) - vent frequency [0.0 - 1.0] .pressure - ( float , READ/WRITE ) - pressure [0.0 - 1.0] .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Bowed (STK Import) STK bowed string instrument class. This class implements a bowed string model, a la Smith (1986), after McIntyre, Schumacher, Woodhouse (1983).

This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.

Control Change Numbers:
   - Bow Pressure = 2
   - Bow Position = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Volume = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .bowPressure - ( float , READ/WRITE ) - bow pressure [0.0 - 1.0] .bowPosition - ( float , READ/WRITE ) - bow position [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .volume - ( float , READ/WRITE ) - volume [0.0 - 1.0] .startBowing - ( float , WRITE only ) - start bowing [0.0 - 1.0] .stopBowing - ( float , WRITE only ) - stop bowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Brass (STK Import) STK simple brass instrument class. This class implements a simple brass instrument waveguide model, a la Cook (TBone, HosePlayer).

This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.

Control Change Numbers:
   - Lip Tension = 2
   - Slide Length = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Volume = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .lip - ( float , READ/WRITE ) - lip tension [0.0 - 1.0] .slide - ( float , READ/WRITE ) - slide length [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .volume - ( float , READ/WRITE ) - volume [0.0 - 1.0] .clear - ( float , WRITE only ) - clear instrument .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Clarinet (STK Import) STK clarinet physical model class. This class implements a simple clarinet physical model, as discussed by Smith (1986), McIntyre, Schumacher, Woodhouse (1983), and others.

This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.

Control Change Numbers:
   - Reed Stiffness = 2
   - Noise Gain = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Breath Pressure = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .reed - ( float , READ/WRITE ) - reed stiffness [0.0 - 1.0] .noiseGain - ( float , READ/WRITE ) - noise component gain [0.0 - 1.0] .clear - ( ) - clear instrument .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .pressure - ( float , READ/WRITE ) - pressure/volume [0.0 - 1.0] .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Flute (STK Import) STK flute physical model class. This class implements a simple flute physical model, as discussed by Karjalainen, Smith, Waryznyk, etc. The jet model uses a polynomial, a la Cook.

This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.

Control Change Numbers:
   - Jet Delay = 2
   - Noise Gain = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Breath Pressure = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .jetDelay - ( float , READ/WRITE ) - jet delay [...] .jetReflection - ( float , READ/WRITE ) - jet reflection [...] .endReflection - ( float , READ/WRITE ) - end delay [...] .noiseGain - ( float , READ/WRITE ) - noise component gain [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .pressure - ( float , READ/WRITE ) - pressure/volume [0.0 - 1.0] .clear - ( ) - clear instrument .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Mandolin (STK Import) STK mandolin instrument model class. see examples: mand-o-matic.ck This class inherits from PluckTwo and uses "commuted synthesis" techniques to model a mandolin instrument.

This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
Commuted Synthesis, in particular, is covered
by patents, granted, pending, and/or
applied-for.  All are assigned to the Board of
Trustees, Stanford University.  For
information, contact the Office of Technology
Licensing, Stanford University.

Control Change Numbers:
   - Body Size = 2
   - Pluck Position = 4
   - String Sustain = 11
   - String Detuning = 1
   - Microphone Position = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .bodySize - ( float , READ/WRITE ) - body size (percentage) .pluckPos - ( float , READ/WRITE ) - pluck position [0.0 - 1.0] .stringDamping - ( float , READ/WRITE ) - string damping [0.0 - 1.0] .stringDetune - ( float , READ/WRITE ) - detuning of string pair [0.0 - 1.0] .afterTouch - ( float , WRITE only ) - aftertouch (currently unsupported) .pluck - ( float , WRITE only ) - pluck instrument [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: ModalBar (STK Import) STK resonant bar instrument class. see examples: mode-o-matic.ck This class implements a number of different struck bar instruments. It inherits from the Modal class.

Control Change Numbers:
   - Stick Hardness = 2
   - Stick Position = 4
   - Vibrato Gain = 11
   - Vibrato Frequency = 7
   - Direct Stick Mix = 1
   - Volume = 128
   - Modal Presets = 16
     - Marimba = 0
     - Vibraphone = 1
     - Agogo = 2
     - Wood1 = 3
     - Reso = 4
     - Wood2 = 5
     - Beats = 6
     - Two Fixed = 7
     - Clump = 8

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .stickHardness - ( float , READ/WRITE ) - stick hardness [0.0 - 1.0] .strikePosition - ( float , READ/WRITE ) - strike position [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .directGain - ( float , READ/WRITE ) - direct gain [0.0 - 1.0] .masterGain - ( float , READ/WRITE ) - master gain [0.0 - 1.0] .volume - ( float , READ/WRITE ) - volume [0.0 - 1.0] .preset - ( int , READ/WRITE ) - choose preset (see above) .strike - ( float , WRITE only ) - strike bar [0.0 - 1.0] .damp - ( float , WRITE only ) - damp bar [0.0 - 1.0] .clear - ( ) - reset [none] .mode - ( int , READ/WRITE ) - select mode [0.0 - 1.0] .modeRatio - ( float , READ/WRITE ) - edit selected mode ratio [...] .modeRadius - ( float , READ/WRITE ) - edit selected mode radius [0.0 - 1.0] .modeGain - ( float , READ/WRITE ) - edit selected mode gain [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Moog (STK Import) STK moog-like swept filter sampling synthesis class. see examples: moogie.ck This instrument uses one attack wave, one looped wave, and an ADSR envelope (inherited from the Sampler class) and adds two sweepable formant (FormSwep) filters.

Control Change Numbers:
   - Filter Q = 2
   - Filter Sweep Rate = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Gain = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .filterQ - ( float , READ/WRITE ) - filter Q value [0.0 - 1.0] .filterSweepRate - ( float , READ/WRITE ) - filter sweep rate [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .afterTouch - ( float , WRITE only ) - aftertouch [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Saxofony (STK Import) STK faux conical bore reed instrument class. This class implements a "hybrid" digital waveguide instrument that can generate a variety of wind-like sounds. It has also been referred to as the "blowed string" model. The waveguide section is essentially that of a string, with one rigid and one lossy termination. The non-linear function is a reed table. The string can be "blown" at any point between the terminations, though just as with strings, it is impossible to excite the system at either end. If the excitation is placed at the string mid-point, the sound is that of a clarinet. At points closer to the "bridge", the sound is closer to that of a saxophone. See Scavone (2002) for more details.

This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.

Control Change Numbers:
   - Reed Stiffness = 2
   - Reed Aperture = 26
   - Noise Gain = 4
   - Blow Position = 11
   - Vibrato Frequency = 29
   - Vibrato Gain = 1
   - Breath Pressure = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .stiffness - ( float , READ/WRITE ) - reed stiffness [0.0 - 1.0] .aperture - ( float , READ/WRITE ) - reed aperture [0.0 - 1.0] .pressure - ( float , READ/WRITE ) - pressure/volume [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .noiseGain - ( float , READ/WRITE ) - noise component gain [0.0 - 1.0] .blowPosition - ( float , READ/WRITE ) - lip stiffness [0.0 - 1.0] .clear - ( ) - clear instrument .startBlowing - ( float , WRITE only ) - start blowing [0.0 - 1.0] .stopBlowing - ( float , WRITE only ) - stop blowing [0.0 - 1.0] .rate - ( float , READ/WRITE ) - rate of attack (sec) (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Shakers (STK Import) PhISEM and PhOLIES class. see examples: shake-o-matic.ck PhISEM (Physically Informed Stochastic Event Modeling) is an algorithmic approach for simulating collisions of multiple independent sound producing objects. This class is a meta-model that can simulate a Maraca, Sekere, Cabasa, Bamboo Wind Chimes, Water Drops, Tambourine, Sleighbells, and a Guiro.

PhOLIES (Physically-Oriented Library of
Imitated Environmental Sounds) is a similar
approach for the synthesis of environmental
sounds.  This class implements simulations of
breaking sticks, crunchy snow (or not), a
wrench, sandpaper, and more.

Control Change Numbers:
   - Shake Energy = 2
   - System Decay = 4
   - Number Of Objects = 11
   - Resonance Frequency = 1
   - Shake Energy = 128
   - Instrument Selection = 1071
    - Maraca = 0
    - Cabasa = 1
    - Sekere = 2
    - Guiro = 3
    - Water Drops = 4
    - Bamboo Chimes = 5
    - Tambourine = 6
    - Sleigh Bells = 7
    - Sticks = 8
    - Crunch = 9
    - Wrench = 10
    - Sand Paper = 11
    - Coke Can = 12
    - Next Mug = 13
    - Penny + Mug = 14
    - Nickle + Mug = 15
    - Dime + Mug = 16
    - Quarter + Mug = 17
    - Franc + Mug = 18
    - Peso + Mug = 19
    - Big Rocks = 20
    - Little Rocks = 21
    - Tuned Bamboo Chimes = 22

by Perry R. Cook, 1996 - 1999.

extends StkInstrument (control parameters) .preset - ( int , READ/WRITE ) - select instrument (0 - 22; see above) .energy - ( float , READ/WRITE ) - shake energy [0.0 - 1.0] .decay - ( float , READ/WRITE ) - system decay [0.0 - 1.0] .objects - ( float , READ/WRITE ) - number of objects [0.0 - 128.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: Sitar (STK Import) STK sitar string model class. This class implements a sitar plucked string physical model based on the Karplus-Strong algorithm.

This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
There exist at least two patents, assigned to
Stanford, bearing the names of Karplus and/or
Strong.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .pluck - ( float , WRITE only ) - pluck string [0.0 - 1.0] .clear - ( ) - reset (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: StifKarp (STK Import) STK plucked stiff string instrument. see examples: stifkarp.ck This class implements a simple plucked string algorithm (Karplus Strong) with enhancements (Jaffe-Smith, Smith, and others), including string stiffness and pluck position controls. The stiffness is modeled with allpass filters.

This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.

Control Change Numbers:
   - Pickup Position = 4
   - String Sustain = 11
   - String Stretch = 1

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .pickupPosition - ( float , READ/WRITE ) - pickup position [0.0 - 1.0] .sustain - ( float , READ/WRITE ) - string sustain [0.0 - 1.0] .stretch - ( float , READ/WRITE ) - string stretch [0.0 - 1.0] .pluck - ( float , WRITE only ) - pluck string [0.0 - 1.0] .baseLoopGain - ( float , READ/WRITE ) - ?? [0.0 - 1.0] .clear - ( ) - reset instrument (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: VoicForm (STK Import) Four formant synthesis instrument. see examples: voic-o-form.ck This instrument contains an excitation singing wavetable (looping wave with random and periodic vibrato, smoothing on frequency, etc.), excitation noise, and four sweepable complex resonances.

Measured formant data is included, and enough
data is there to support either parallel or
cascade synthesis.  In the floating point case
cascade synthesis is the most natural so
that's what you'll find here.

Control Change Numbers:
   - Voiced/Unvoiced Mix = 2
   - Vowel/Phoneme Selection = 4
   - Vibrato Frequency = 11
   - Vibrato Gain = 1
   - Loudness (Spectral Tilt) = 128

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

Phoneme Names:
"eee"  "ihh"  "ehh"  "aaa"
"ahh"  "aww"  "ohh"  "uhh"
"uuu"  "ooo"  "rrr"  "lll"
"mmm"  "nnn"  "nng"  "ngg"
"fff"  "sss"  "thh"  "shh"
"xxx"  "hee"  "hoo"  "hah"
"bbb"  "ddd"  "jjj"  "ggg"
"vvv"  "zzz"  "thz"  "zhh"

extends StkInstrument (control parameters) .phoneme - ( string , READ/WRITE ) - select phoneme ( see above ) .phonemeNum - ( int , READ/WRITE ) - select phoneme by number [0.0 - 128.0] .speak - ( float , WRITE only ) - start singing [0.0 - 1.0] .quiet - ( float , WRITE only ) - stop singing [0.0 - 1.0] .voiced - ( float , READ/WRITE ) - set mix for voiced component [0.0 - 1.0] .unVoiced - ( float , READ/WRITE ) - set mix for unvoiced component [0.0 - 1.0] .pitchSweepRate - ( float , READ/WRITE ) - pitch sweep [0.0 - 1.0] .voiceMix - ( float , READ/WRITE ) - voiced/unvoiced mix [0.0 - 1.0] .vibratoFreq - ( float , READ/WRITE ) - vibrato frequency (Hz) .vibratoGain - ( float , READ/WRITE ) - vibrato gain [0.0 - 1.0] .loudness - ( float , READ/WRITE ) - 'loudness' of voice [0.0 - 1.0] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change stk - fm synths [ugen]: FM (STK Import) STK abstract FM synthesis base class. This class controls an arbitrary number of waves and envelopes, determined via a constructor argument.

Control Change Numbers:
   - Control One = 2
   - Control Two = 4
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends StkInstrument (control parameters) .lfoSpeed - ( float , READ/WRITE ) - modulation Speed (Hz) .lfoDepth - ( float , READ/WRITE ) - modulation Depth [0.0 - 1.0] .afterTouch - ( float , READ/WRITE ) - aftertouch [0.0 - 1.0] .controlOne - ( float , READ/WRITE ) - control one [instrument specific] .controlTwo - ( float , READ/WRITE ) - control two [instrument specific] (inherited from StkInstrument) .noteOn - ( float velocity ) - trigger note on .noteOff - ( float velocity ) - trigger note off .freq - ( float frequency ) - set/get frequency (Hz) .controlChange - ( int number, float value ) - assert control change [ugen]: BeeThree (STK Import) STK Hammond-oid organ FM synthesis instrument. This class implements a simple 4 operator topology, also referred to as algorithm 8 of the TX81Z.

\code
Algorithm 8 is :
                 1 --.
                 2 -\|
                     +-> Out
                 3 -/|
                 4 --
\endcode

Control Change Numbers:
   - Operator 4 (feedback) Gain = 2 (.controlOne)
   - Operator 3 Gain = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) [ugen]: FMVoices (STK Import) STK singing FM synthesis instrument. This class implements 3 carriers and a common modulator, also referred to as algorithm 6 of the TX81Z.

\code
Algorithm 6 is :
                    /->1 -\
                 4-|-->2 - +-> Out
                    \->3 -/
\endcode

Control Change Numbers:
   - Vowel = 2 (.controlOne)
   - Spectral Tilt = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) .vowel - ( float , WRITE only ) - select vowel [0.0 - 1.0] .spectralTilt - ( float , WRITE only ) - spectral tilt [0.0 - 1.0] .adsrTarget - ( float , WRITE only ) - adsr targets [0.0 - 1.0] [ugen]: HevyMetl (STK Import) STK heavy metal FM synthesis instrument. This class implements 3 cascade operators with feedback modulation, also referred to as algorithm 3 of the TX81Z.

Algorithm 3 is :     4--\
                3-->2-- + -->1-->Out

Control Change Numbers:
   - Total Modulator Index = 2 (.controlOne)
   - Modulator Crossfade = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) [ugen]: PercFlut (STK Import) STK percussive flute FM synthesis instrument. This class implements algorithm 4 of the TX81Z.

\code
Algorithm 4 is :   4->3--\
                      2-- + -->1-->Out
\endcode

Control Change Numbers:
   - Total Modulator Index = 2 (.controlOne)
   - Modulator Crossfade = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) [ugen]: Rhodey (STK Import) STK Fender Rhodes-like electric piano FM see examples: rhodey.ck synthesis instrument.

This class implements two simple FM Pairs
summed together, also referred to as algorithm
5 of the TX81Z.

\code
Algorithm 5 is :  4->3--\
                         + --> Out
                  2->1--/
\endcode

Control Change Numbers:
   - Modulator Index One = 2 (.controlOne)
   - Crossfade of Outputs = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) [ugen]: TubeBell (STK Import) STK tubular bell (orchestral chime) FM synthesis instrument.

This class implements two simple FM Pairs
summed together, also referred to as algorithm
5 of the TX81Z.

\code
Algorithm 5 is :  4->3--\
                         + --> Out
                  2->1--/
\endcode

Control Change Numbers:
   - Modulator Index One = 2 (.controlOne)
   - Crossfade of Outputs = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) [ugen]: Wurley (STK Import) STK Wurlitzer electric piano FM see examples: wurley.ck synthesis instrument.

This class implements two simple FM Pairs
summed together, also referred to as algorithm
5 of the TX81Z.

\code
Algorithm 5 is :  4->3--\
                         + --> Out
                  2->1--/
\endcode

Control Change Numbers:
   - Modulator Index One = 2 (.controlOne)
   - Crossfade of Outputs = 4 (.controlTwo)
   - LFO Speed = 11
   - LFO Depth = 1
   - ADSR 2 & 4 Target = 128

The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha.  If you are of the
type who should worry about this (making
money) worry away.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends FM (control parameters) ( see super classes ) stk - delay [ugen]: Delay (STK Import) STK non-interpolating delay line class. see examples: comb.ck This protected Filter subclass implements a non-interpolating digital delay-line. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.

A non-interpolating delay line is typically
used in fixed delay-length applications, such
as for reverberation.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .delay - ( dur , READ/WRITE ) - length of delay .max - ( dur , READ/WRITE ) - max delay (buffer size) [ugen]: DelayA (STK Import) STK allpass interpolating delay line class. This Delay subclass implements a fractional- length digital delay-line using a first-order allpass filter. A fixed maximum length of 4095 and a delay of 0.5 is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.

An allpass filter has unity magnitude gain but
variable phase delay properties, making it useful
in achieving fractional delays without affecting
a signal's frequency magnitude response.  In
order to achieve a maximally flat phase delay
response, the minimum delay possible in this
implementation is limited to a value of 0.5.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .delay - ( dur , READ/WRITE ) - length of delay .max - ( dur , READ/WRITE ) - max delay ( buffer size ) [ugen]: DelayL (STK Import) STK linear interpolating delay line class. see examples: i-robot.ck This Delay subclass implements a fractional- length digital delay-line using first-order linear interpolation. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.

Linear interpolation is an efficient technique
for achieving fractional delay lengths, though
it does introduce high-frequency signal
attenuation to varying degrees depending on the
fractional delay setting.  The use of higher
order Lagrange interpolators can typically
improve (minimize) this attenuation characteristic.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .delay - ( dur , READ/WRITE ) - length of delay .max - ( dur , READ/WRITE ) - max delay ( buffer size ) [ugen]: Echo (STK Import) STK echo effect class. This class implements a echo effect.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .delay - ( dur , READ/WRITE ) - length of echo .max - ( dur , READ/WRITE ) - max delay .mix - ( float , READ/WRITE ) - mix level ( wet/dry ) stk - envelopes [ugen]: Envelope (STK Import) STK envelope base class. see examples: envelope.ck This class implements a simple envelope generator which is capable of ramping to a target value by a specified \e rate. It also responds to simple \e keyOn and \e keyOff messages, ramping to 1.0 on keyOn and to 0.0 on keyOff.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .keyOn - ( int , WRITE only ) - ramp to 1.0 .keyOff - ( int , WRITE only ) - ramp to 0.0 .target - ( float , READ/WRITE ) - ramp to arbitrary value. .time - ( float , READ/WRITE ) - time to reach target (in seconds) .duration - ( dur , READ/WRITE ) - duration to reach target .rate - ( float , READ/WRITE ) - rate of change .value - ( float , READ/WRITE ) - set immediate value [ugen]: ADSR (STK Import) STK ADSR envelope class. see examples: adsr.ck This Envelope subclass implements a traditional ADSR (Attack, Decay, Sustain, Release) envelope. It responds to simple keyOn and keyOff messages, keeping track of its state. The \e state = ADSR::DONE after the envelope value reaches 0.0 in the ADSR::RELEASE state.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends Envelope (control parameters) .keyOn - ( int , WRITE only ) - start the attack for non-zero values .keyOff - ( int , WRITE only ) - start release for non-zero values .attackTime - ( dur , READ/WRITE ) - attack time .attackRate - ( float , READ/WRITE ) - attack rate .decayTime - ( dur , READ/WRITE ) - decay time .decayRate - ( float , READ/WRITE ) - decay rate .sustainLevel - ( float , READ/WRITE ) - sustain level .releaseTime - ( dur , READ/WRITE ) - release time .releaseRate - ( float , READ/WRITE ) - release rate .state - ( int , READ only ) - attack=0, decay=1 , sustain=2, release=3, done=4 .set - ( dur, dur, float, dur ) - set A, D, S, and R all at once stk-reverbs [ugen]: JCRev (STK Import) John Chowning's reverberator class. This class is derived from the CLM JCRev function, which is based on the use of networks of simple allpass and comb delay filters. This class implements three series allpass units, followed by four parallel comb filters, and two decorrelation delay lines in parallel at the output.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .mix - ( float , READ/WRITE ) - mix level [ugen]: NRev (STK Import) CCRMA's NRev reverberator class. This class is derived from the CLM NRev function, which is based on the use of networks of simple allpass and comb delay filters. This particular arrangement consists of 6 comb filters in parallel, followed by 3 allpass filters, a lowpass filter, and another allpass in series, followed by two allpass filters in parallel with corresponding right and left outputs.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .mix - ( float , READ/WRITE ) - [ugen]: PRCRev (STK Import) Perry's simple reverberator class. This class is based on some of the famous Stanford/CCRMA reverbs (NRev, KipRev), which were based on the Chowning/Moorer/Schroeder reverberators using networks of simple allpass and comb delay filters. This class implements two series allpass units and two parallel comb filters.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .mix - ( float , READ/WRITE ) - mix level stk - components [ugen]: Chorus (STK Import) STK chorus effect class. This class implements a chorus effect.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .modFreq - ( float , READ/WRITE ) - modulation frequency .modDepth - ( float , READ/WRITE ) - modulation depth .mix - ( float , READ/WRITE ) - effect mix [ugen]: Modulate (STK Import) STK periodic/random modulator. This class combines random and periodic modulations to give a nice, natural human modulation function.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .vibratoRate - ( float , READ/WRITE ) - set rate of vibrato .vibratoGain - ( float , READ/WRITE ) - gain for vibrato .randomGain - ( float , READ/WRITE ) - gain for random contribution [ugen]: PitShift (STK Import) STK simple pitch shifter effect class. This class implements a simple pitch shifter using delay lines.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .mix - ( float , READ/WRITE ) - effect dry/web mix level .shift - ( float , READ/WRITE ) - degree of pitch shifting [ugen]: SubNoise (STK Import) STK sub-sampled noise generator. Generates a new random number every "rate" ticks using the C rand() function. The quality of the rand() function varies from one OS to another.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .rate - ( int , READ/WRITE ) - subsampling rate [ugen]: Blit (STK Import) STK band-limited impulse train. This class generates a band-limited impulse train using a closed-form algorithm reported by Stilson and Smith in "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. The user can specify both the fundamental frequency of the impulse train and the number of harmonics contained in the resulting signal.

The signal is normalized so that the peak value is +/-1.0.

If nHarmonics is 0, then the signal will contain all
harmonics up to half the sample rate. Note, however,
that this setting may produce aliasing in the signal
when the frequency is changing (no automatic modification
of the number of harmonics is performed by the
setFrequency() function).

Original code by Robin Davies, 2005.
Revisions by Gary Scavone for STK, 2005.

(control parameters) .freq - ( float , READ/WRITE ) - base frequency (hz) .harmonics - ( int , READ/WRITE ) - number of harmonics in pass band .phase - ( float , READ/WRITE ) - phase of the the signal [ugen]: BlitSaw (STK Import) STK band-limited sawtooth wave. This class generates a band-limited sawtooth waveform using a closed-form algorithm reported by Stilson and Smith in "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. The user can specify both the fundamental frequency of the sawtooth and the number of harmonics contained in the resulting signal.

If nHarmonics is 0, then the signal will contain all
harmonics up to half the sample rate. Note, however,
that this setting may produce aliasing in the signal
when the frequency is changing (no automatic modification
of the number of harmonics is performed by the setFrequency()
function).

Based on initial code of Robin Davies, 2005.
Modified algorithm code by Gary Scavone, 2005.

(control parameters) .freq - ( float , READ/WRITE ) - base frequency (hz) .harmonics - ( int , READ/WRITE ) - number of harmonics in pass band .phase - ( float , READ/WRITE ) - phase of the the signal [ugen]: BlitSquare (STK Import) STK band-limited square wave. This class generates a band-limited square wave signal. It is derived in part from the approach reported by Stilson and Smith in "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. The algorithm implemented in this class uses a SincM function with an even M value to achieve a bipolar bandlimited impulse train. This signal is then integrated to achieve a square waveform. The integration process has an associated DC offset but that is subtracted off the output signal.

The user can specify both the fundamental frequency of the
waveform and the number of harmonics contained in the
resulting signal.

If nHarmonics is 0, then the signal will contain all
harmonics up to half the sample rate. Note, however, that
this setting may produce aliasing in the signal when the
frequency is changing (no automatic modification of the
number of harmonics is performed by the setFrequency() function).

Based on initial code of Robin Davies, 2005.
Modified algorithm code by Gary Scavone, 2005.

(control parameters) .freq - ( float , READ/WRITE ) - base frequency (hz) .harmonics - ( int , READ/WRITE ) - number of harmonics in pass band .phase - ( float , READ/WRITE ) - phase of the the signal stk - file i/o [ugen]: WvIn (STK Import) STK audio data input base class. This class provides input support for various audio file formats. It also serves as a base class for "realtime" streaming subclasses.

WvIn loads the contents of an audio file for
subsequent output.  Linear interpolation is
used for fractional "read rates".

WvIn supports multi-channel data in interleaved
format.  It is important to distinguish the
tick() methods, which return samples produced
by averaging across sample frames, from the
tickFrame() methods, which return pointers to
multi-channel sample frames.  For single-channel
data, these methods return equivalent values.

Small files are completely read into local memory
during instantiation.  Large files are read
incrementally from disk.  The file size threshold
and the increment size values are defined in
WvIn.h.

WvIn currently supports WAV, AIFF, SND (AU),
MAT-file (Matlab), and STK RAW file formats.
Signed integer (8-, 16-, and 32-bit) and floating-
point (32- and 64-bit) data types are supported.
Uncompressed data types are not supported.  If
using MAT-files, data should be saved in an array
with each data channel filling a matrix row.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .rate - ( float , READ/WRITE ) - playback rate .path - ( string , READ/WRITE ) - specifies file to be played [ugen]: WaveLoop (STK Import) STK waveform oscillator class. This class inherits from WvIn and provides audio file looping functionality.

WaveLoop supports multi-channel data in
interleaved format.  It is important to
distinguish the tick() methods, which return
samples produced by averaging across sample
frames, from the tickFrame() methods, which
return pointers to multi-channel sample frames.
For single-channel data, these methods return
equivalent values.

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

extends WvIn (control parameters) .freq - ( float , READ/WRITE ) - set frequency of playback ( loops / second ) .addPhase - ( float , READ/WRITE ) - offset by phase .addPhaseOffset - ( float , READ/WRITE ) - set phase offset [ugen]: WvOut (STK Import) STK audio data output base class. This class provides output support for various audio file formats. It also serves as a base class for "realtime" streaming subclasses.

WvOut writes samples to an audio file.  It
supports multi-channel data in interleaved
format.  It is important to distinguish the
tick() methods, which output single samples
to all channels in a sample frame, from the
tickFrame() method, which takes a pointer
to multi-channel sample frame data.

WvOut currently supports WAV, AIFF, AIFC, SND
(AU), MAT-file (Matlab), and STK RAW file
formats.  Signed integer (8-, 16-, and 32-bit)
and floating- point (32- and 64-bit) data types
are supported.  STK RAW files use 16-bit
integers by definition.  MAT-files will always
be written as 64-bit floats.  If a data type
specification does not match the specified file
type, the data type will automatically be
modified.  Uncompressed data types are not
supported.

Currently, WvOut is non-interpolating and the
output rate is always Stk::sampleRate().

by Perry R. Cook and Gary P. Scavone, 1995 - 2002.

(control parameters) .matFilename - ( string , WRITE only ) - open matlab file for writing .sndFilename - ( string , WRITE only ) - open snd file for writing .wavFilename - ( string , WRITE only ) - open WAVE file for writing .rawFilename - ( string , WRITE only ) - open raw file for writing .aifFilename - ( string , WRITE only ) - open AIFF file for writing .closeFile - ( string , WRITE only ) - close file properly

array of numbers [1,2,3,4,5] @=> int num[];

0 => int randomnesswanted; // CHANGE TO '1' FOR MORE RANDOMNESS

[30927, 25083, 9290, 12603, 3496, 30686, 3073, 29220, 5127, 32289, 23892] @=> int goodseeds[]; // some seeds I liked int seed; // declare variable seed if (randomnesswanted == 0) // if seeds should be chosen from the goodseeds array { Math.random2(1, goodseeds.cap())-1 => int seedselector; // randomly choose a seed from the goodseeds array goodseeds[seedselector] => seed; // choose corresponding seed } else {Math.random2 (0, 32767) => seed;} // choose random seed if even more randomness is desired Math.srandom(seed); <<<"seed:",seed>>>; // set this seed and print it out

// +--------------------------+ // | RANDOM THINGS | // +--------------------------+

// ---------- W! random from seed ---------- while(true) { [1,2,3,4,5] @=> int []; Math.random2(1,goodSeeds.cap())-1 => int seedSelector; goodSeeds[seedSelector] => seed; <<<"seed:",seed>>>; 0.5::second => now;

[0, 3,3,7] @=> int opt[];
Math.random2( 0, opt.cap()-1 ) => int sel;
Std.mtof( root + opt[sel] ) => bass.freq;
e.keyOn();
bit/2 => now;
e.keyOff();

}

//=============================================================

// +--------------------------+ // | ARRAY THINGS | // +--------------------------+

// ------- W! fill an array ----------- [20, 25, 30, 55] @=> int notes[]; int melody[notes.cap()]; for (0 => int i; i < notes.cap(); i++) { Math.random2(1, notes.cap())-1 => int notesSelector; notes[notesSelector] => int pushNote; pushNote => melody[i]; <<>>; }

[1,2,3,4,5,6] @=> int arr[];

// small utility function to print integer arrays, as strings fun string int_array_asString(int a[]){ "[" + Std.itoa(a[0]) => string output_str; for (1 => int i; i < a.cap(); i++){ output_str + ", " + Std.itoa(a[i]) => output_str; } return output_str + "]"; }

<<< int_array_asString(arr) >>>;

// arr2 can contain as many elements as you want // here i'll make it the same length as the arr[] int arr2[arr.cap()];

// each iteration of the forloop will insert a randomly // picked value from arr[] into arr2[i] for (0 => int i; i < arr.cap(); i++){ Math.random2(0, arr.cap()-1) => int random_index; arr[random_index] => arr2[i]; }

<<< "print new array" >>>; <<< int_array_asString(arr2) >>>;

//============================================ //eigth random notes in seven diffeerent modes //============================================ while(true) { for(0 => int ii; ii < 7; ii++) { melody.generateMelody(60, ii+1) @=> int melody[];

	for(0 => int i; i < melody.cap(); i++)
	{
		Std.mtof(melody[i])/2 => piano[1].freq;
		0.5 => piano[1].noteOn;
		tempo.quarterNote => now;
		<<< melody[i] >>>;
	}
}

}

// =================================== // SIN modulate PAN // ==============================

Math.sin( now/(100*tempo.quarterNote)4pi ) => p.pan; // modulate pan

// ARRAS

[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] @=> int kickSeq[]; [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0] @=> int snareSeq[]; [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0] @=> int hihatSeq[];

// KEYBOARD // findout wich one is keyboard // human interface device Hid hid; // a message to convey data from Hid HidMsg msg; for (0 => int i; i < 20; i++) { // which keyboard i => int device;

// try to open keyboard if( hid.openKeyboard( device ) == false ) me.exit(); // print <<< "Keyboard:", hid.name(), "ready!" >>>; }

[0,5,13,17,22,29,31,33,40,45,49,54,60,61] @=> int kick[];

0 => int count;

while (true) { count++; count % 64 => int i64;

for (0 => int ii; ii < kick.cap(); ii++)
{
	if (i64 == kick[ii])
	{
		<<< kick[ii] >>>;

	}
}

}

//================= // Montar muchos osciladores y paneos de una // ================

Math.srandom(3367); 50 => int C; //number of bees SawOsc s[C]; // Oscillators and Pans for each bee Pan2 p[C]; for ( 0 => int i ; i< C ; ++i ) s[i] => p[i] => dac;

// ========== Times now + pieceDuration => time execTime; // time in wich piece ends. now => time initialTime; // current time. <<< "Start time:", (now - initialTime) / second >>>; // prints out the reference time in seconds (0 seconds).

false => int booleanNoteDuration; // Boolean-style variable to insert fade out. while (now < execTime) // while now less than this piece durat/

// ========= Notas [unicas Random

//ensure it plays a different tone than immediately prior float x, y; for (0 => int i; i < 10; i++) { while (x == y) { Std.rand2(1, 6) => x; }

x * base => xave.freq;
0.15::second => now;
x => y;

}

//=================================== //======= Granular ================= //=================================

SndBuf click => dac;

me.dir() + "/audio/stereo_fx_01.wav" => click.read;

click.samples() => click.pos;

fun void granularize( int steps ) { click.samples()/steps => int grain; Math.random2( 0,click.samples()-grain ) => click.pos; grain::samp => now; }

//MAIN while( true ) { granularize(20); }

//------------- search for presence in an array, find element, item [0,5,13,17,22,29,31,33,40,45,49,54,60,61] @=> int kick[];

0 => int count;

while (true) { count++; count % 64 => int i64;

for (0 => int ii; ii < kick.cap(); ii++)
{
	if (i64 == kick[ii])
	{
		<<< kick[ii] >>>;

	}
}

}

//====================================== // Llamar una función de una // clase con un array como argumento //====================================== Machine.add(me.dir()+"Drummer.ck"); // carga la clase Drummer drum; // instancia la clase ["ss","sn" ] @=> string p1[]; spork ~ drums.pat1(p1); // usa una función de la clase

//===== en la clase Drummer.ck

fun void pat1(string p1[])
{
 // cödigo acá, puede usar el array p1
}

// -------- fill de batería en el útlimo beat fun void kk(int div) { 0 => int i; while(true) { i % 8 => int loop8; if( loop8 < 7) { 1.0 => kick.next; bit/div => now; } else { [1, 2, 2, 2, 4, 4] @=> int seed[];

			1.0 => kick.next;
			bit/seed[(Math.random2(0, seed.cap()-1))] => now;
		}
		i++;
	}
}

Perry Cook [email protected] ChucK definitely has all you need! ChucK is “DSP Complete” (like Turing Complete for computational engines/languages), because since ChucK allows for single-sample connections and manipulations, then we don’t provide lots of flavors of things. You can build from primitives. Like a RISC computer. Some things you mentioned are available:

First and 2nd order AllPass are available via the PoleZero (1st) and BiQuad (2nd) UGens. You just need to set the coefficients explicitly.

Tapped Delay lines can be implemented using multiple Delay elements. Yea it wastes some memory, but not too much, and works just great:

// Taps.ck Tapped Delay via separate delays // by Perry R. Cook, 2015 // Caution about adc => dac!!! Use headphones Delay taps[10]; Pan2 pans[10]; for (int i; i < 10; i++) { adc => taps[i] => pans[i] => dac; Math.random2f(-1.0,1.0) => pans[i].pan; // stereo early reflections Math.random2(20,200) => int tapMs; // random path lengths tapMs :: ms => taps[i].max => taps[i].delay; 10.0/tapMs => taps[i].gain; // 1/distance gain } 10*second => now;

AllPass CombFilter can be accomplished with a single delay line and one Gain connecting input to mix with output, and another Gain mixing output back into input. You might want to be cautious about the extra sample gained when feeding back, but for long delays, it doesn’t really make much difference. If you strictly want a true allpass comb, then one extra sample of delay from inlet to your main delay, feeding the fbGain back into the 2nd delay line rather than the first, should take care of it. For reverb purposes, this super simple AllPassComb might do:

// Simple AllPassComb.ck by Perry R. Cook, 2015 // NOTE: this has one sample different delay forward vs. back // Easily fixed, but really doesn’t much matter for long enough delays public class AllPassComb extends Chubgraph { inlet => Delay dl => outlet; outlet => Gain fb => dl; inlet => Gain ff => outlet; 0.5 => coeff; 50::ms => delay; fun float coeff(float c) { -c => fb.gain; c => ff.gain; return c; } fun float coeff() { return fb.gain(); } fun dur delay(dur d) { d => dl.max => dl.delay; } }

// Noise n => AllPassComb ap => dac; adc => AllPassComb ap => dac; // caution here, use headphones!!! 10*second => now;

END


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment