// @title binaural.ck // @author Myles Borins // @original by Chris Chafe (cc@ccrma), Hongchan Choi (hongchan@ccrma) // @desc binaural rendering for homework 3, Music220a-2012 // @version chuck-1.3.1.3 / ma-0.2.2c // for DBAP4e: note that Binaural4 class is required SndBuf sample => DBAP4e samplePan; me.sourceDir() + "/samp.wav" => string _sfile; _sfile => sample.read; cherr <= "[score] SndBuf: " <= _sfile <= IO.newline(); SndBuf physical => DBAP4e physicalPan; me.sourceDir() + "/phys.wav" => string _pfile; _pfile => physical.read; cherr <= "[score] SndBuf: " <= _pfile <= IO.newline(); // write signals to files dac.left => WvOut leftChan; dac.right => WvOut rightChan; me.sourceDir() + "/leftChan.wav" => string _captureL; me.sourceDir() + "/rightChan.wav" => string _captureR; _captureL => leftChan.wavFilename; _captureR => rightChan.wavFilename; // Don't forget to hit play sample.play; physical.play; // Intro of first instrument 0.0 => float t; 0 => int count; while(count <= 100) { 0.30 +=> t; physicalPan.setPosition(-1 * Math.sin(t), -1 * Math.cos(t)); 1 +=> count; 50::ms => now; } physicalPan.setPosition(1,1); // In comes number two, he is spinning around // Here comes numba two 0.0 => t; 0 => count; while(count <= 500) { 0.30 +=> t; samplePan.setPosition(Math.sin(t), Math.cos(t)); 1 +=> count; 10::ms => now; } samplePan.setPosition(-1,-1); 10::second => now; 0 => count; while(count <= 20) { 1 +=> count; samplePan.setPosition(Math.randomf(),-1); physicalPan.setPosition(Math.randomf(),1); 500::ms => now; } while(count <= 30) { 1 +=> count; samplePan.setPosition(Math.randomf(), Math.randomf()); physicalPan.setPosition(Math.randomf(), Math.randomf()); samplePan.setReverb(Math.random2f(0.0,0.4)); physicalPan.setReverb(Math.random2f(0.0,0.4)); 250::ms => now; } while(count <= 400) { 0.30 +=> t; samplePan.setPosition(Math.sin(t), Math.cos(t)); physicalPan.setPosition(Math.sin(-1 * t), Math.cos(-1 * t)); 1 +=> count; 10::ms => now; } while(count <= 60) { 1 +=> count; samplePan.setPosition(Math.randomf(), 1); physicalPan.setPosition(Math.randomf(), -1); samplePan.setReverb(Math.random2f(0.0,0.7)); physicalPan.setReverb(Math.random2f(0.0,0.2)); 250::ms => now; } while(count <= 300) { 1 +=> count; samplePan.setPosition(Math.randomf(), Math.randomf()); physicalPan.setPosition(Math.randomf(), Math.randomf()); samplePan.setReverb(Math.random2f(0.0,0.7)); physicalPan.setReverb(Math.random2f(0.0,0.2)); 50::ms => now; } samplePan.setPosition(0,1); physicalPan.setPosition(0,-1); samplePan.setReverb(0.7); physicalPan.setReverb(0.7); 5::second => now; samplePan.setPosition(0,.5); physicalPan.setPosition(0,-.5); 1::second => now; samplePan.setReverb(0.4); physicalPan.setReverb(0.4); 5::second => now; samplePan.setPosition(0,.25); physicalPan.setPosition(0,-.25); 1::second => now; samplePan.setReverb(0.6); physicalPan.setReverb(0.6); 2::second => now; samplePan.setPosition(0,0); physicalPan.setPosition(0,0); 10::second => now; // finish the show leftChan.closeFile(); rightChan.closeFile(); // print message in terminal for sox command cherr <= "[score] Finished. Merge two products with the command below.\n"; cherr <= "sox -M " <= _captureL <= " " <= _captureR <= " "; cherr <= me.sourceDir() + "/final.wav"; // So for some reason this file does not output proper files... it is actually quite strange // I ended up mixing down through sound flower.. but I just can't figure out why things were not // Rendering correctly