Binaural4 b4; //remove for 4ch play class DBAP4 extends Chubgraph { // position of speakers: LF, RF, RR, LR [[-1.0, 1.0], [1.0, 1.0], [1.0, -1.0], [-1.0, -1.0]] @=> float _spks[][]; // position of source float _x, _y; // UGens Envelope _in; Envelope _out[4]; // initialization inlet => _in; 20::ms => _in.duration; 1.0 => _in.target; for (0 => int i; i < 4; ++i) { _in => _out[i] => dac.chan(i); 20::ms => _out[i].duration; 1.0 => _out[i].target; } // setPosition(): implements simple DBAP. the radius // of sound is set to 2.0 by default. fun void setPosition(float x, float y) { x => _x; y => _y; //for(0 => int i; i < 4; ++i) { for(0 => int i; i < 4; ++i) { _spks[i][0] - _x => float dx; _spks[i][1] - _y => float dy; dx * dx => dx; dy * dy => dy; Math.sqrt(dx + dy) => float dist; Math.max(0.0, 2.0 - dist) => dist; dist => _out[i].target; } } // setGain(): set overall gain fun void setGain(float gain) { gain => _in.target; } } class DBAP4Binaural4 extends Chubgraph { // position of speakers: LF, RF, RR, LR [[-1.0, 1.0], [1.0, 1.0], [1.0, -1.0], [-1.0, -1.0]] @=> float _spks[][]; // position of source float _x, _y; // UGens Envelope _in; Envelope _out[4]; // initialization inlet => _in; 20::ms => _in.duration; 1.0 => _in.target; for (0 => int i; i < 4; ++i) { _in => _out[i] => b4.pssp[i]; 20::ms => _out[i].duration; 1.0 => _out[i].target; } // setPosition(): implements simple DBAP. the radius // of sound is set to 2.0 by default. fun void setPosition(float x, float y) { x => _x; y => _y; for(0 => int i; i < 4; ++i) { // for(0 => int i; i < 2; ++i) { _spks[i][0] - _x => float dx; _spks[i][1] - _y => float dy; dx * dx => dx; dy * dy => dy; Math.sqrt(dx + dy) => float dist; Math.max(0.0, 2.0 - dist) => dist; dist => _out[i].target; } } // setGain(): set overall gain fun void setGain(float gain) { gain => _in.target; } } //---------------------------------------------------------------------------------------- SndBuf s[7]; //DBAP for 4ch play //DBAP4 d4; //DBAP4 d4a; //DBAP for binaural play DBAP4Binaural4 db4; DBAP4Binaural4 db4a; "/Users/Priyanka/Documents/Music 220A/HW2 - Radioplay/Boi/Boy Voices 3/" => string path; path + "Rocky.wav" => s[0].read; path + "Boy to Rocky.wav" => s[1].read; path + "SongPart1.wav" => s[2].read; path + "Boy Leaving.wav" => s[3].read; path + "Boy Outro.wav" => s[4].read; path + "SongPart2.wav" => s[5].read; path + "Claps.wav" => s[6].read; s[0].rate(0.0); s[1].rate(0.0); s[2].rate(0.0); s[3].rate(0.0); s[4].rate(0.0); s[5].rate(0.0); s[6].rate(0.0); //routing for 4ch play //s[0] => dac.chan(2); //LR //s[1] => dac.chan(3); //RR //s[2] => dac.chan(1); //LF //s[3] => d4; //RR to RF //s[4] => dac.chan(1); //LF //s[4] => dac.chan(0); //RF //s[5] => d4a; //LF to RR //s[6] => dac.chan(2); //LR //s[6] => dac.chan(3); //RR //routing for binaural play s[0] => b4.pssp[2]; //LR s[1] => b4.pssp[3]; //RR s[2] => b4.pssp[1]; //LF s[3] => db4; //RR to RF s[4] => b4.pssp[1]; //LF s[4] => b4.pssp[0]; //RF s[5] => db4a; //LF to RR s[6] => b4.pssp[2]; //LR s[6] => b4.pssp[3]; //RR //timing of events s[0].rate(1.0); s[1].rate(1.0); s[2].rate(1.0); 60.8::second => now; float pan3; 15.5 => float time3; //time x 0.04 => float step3; //40ms s[3].rate(1.0); while(pan3 <= pi/2) { (step3/time3)*pi/2 +=> pan3; //adjust gradation? db4.setPosition(Math.sin(pan3), -Math.cos(pan3)); //for binaural play //d4.setPosition(Math.sin(pan3), -Math.cos(pan3)); //for 4ch play step3::second => now; } s[4].rate(1.0); 39.6::second => now; float pan5; 20 => float time5; //time y 0.04 => float step5; s[5].rate(1.0); while(pan5 <= pi) { (step5/time5)*pi +=> pan5; //adjust gradation? db4.setPosition(Math.sin(pan5),Math.cos(pan5)); //for binaural play //d4.setPosition(Math.sin(pan5),Math.cos(pan5)); //for 4ch play step5::second => now; } s[6].rate(1.0); 5::second => now;