// based off of dyn-notes.ck from 220a 2007 I believe // demo of dynamical system melodies // uses this iterated map, a second-order // polynomial function fun float mapTick( float x, float a0) { // set the constants in the polynomial -0.7 => float a1; 2.0 => float a2; // return the next value of the map return a0 + (a1 * x) + (a2 * x * x); // strange attractors -- Sprott // video feedback // heart rhythms are chaotic // can change some of the other coefficients too } // patch SndBuf buf[2]; Envelope e[2]; buf[0] => e[0] => dac; buf[1] => e[1] => dac; "../220b/hw2/soundfiles/coffee4.wav" => buf[0].read; "../220b/hw2/soundfiles/coffee4.wav" => buf[1].read; 0.5 => buf[0].rate; 0.5 => buf[1].rate; // counter to switch between buffers 0 => int theBuf; // how many phrases to play in the demo 25 => int numRiffs; for( int ctr; ctr < numRiffs; ctr++ ) { // calculate a ramp that increases from 0 to 1 over the phrases (((ctr)$float)/(numRiffs-1$float)) => float ramp; // set the initial condition the same for each phrase 0.1 => float x; // ramp the a0 coefficient and print it -0.3 + (ramp * (-0.7 - -0.3)) => float a0; for( 0 => int i; i < 2; i++ ) { // change some parameters here if( theBuf == 0 ) { mapTick(x, a0) => x; (x*1) => e[1].time; //.12 => e[1].time; e[1].keyOff( ); (Std.fabs(x)*buf[0].samples( )) $ int => buf[0].pos; x => buf[0].rate; (x*1) => e[0].time; //.12 => e[0].time; e[0].keyOn( ); 1 => theBuf; } else { (x*1) => e[0].time; //.12 => e[0].time; e[0].keyOff( ); (Std.fabs(x)*buf[1].samples( )) $ int => buf[1].pos; x => buf[1].rate; (x*1) => e[1].time; //.12 => e[1].time; e[1].keyOn( ); 0 => theBuf; } (Std.fabs(x)*2000)::ms => now; } (Std.fabs(x)*2000)::ms => now; } 50::second => now;