// Hunter McCurry // Music 2201 - Homework 4 // // Sonifying Data: // Monthly sunspot numbers 1749-1983. Source: Andrews & Herzberg (1985). // (Data is sampled every three months instead of every month to reduce data points.) 4 => int nInsts; int chan[nInsts]; StkInstrument inst[nInsts]; DataReader data[nInsts]; [ 0, 1, 3 , 2] @=> chan; "/Users/phunter/CCRMA/220a/hw4/SunspotData/" => string dataDir; 0 => int i; for ( i; i < nInsts; 1 +=> i ) { BandedWG x @=> inst[i] => dac.chan(chan[i]); inst[i] => NRev rev => dac; data[i].setDataSource(dataDir + "sunspot_" + (i*3 + 1) + ".dat"); data[i].start(); rev.mix(.9); rev.gain(0.05 * i); } 180 => int firstSectionMax; 0 => int firstSection; 0 => int end; while (!data[0].isFinished() && !end) { 0 => int j; for ( j ; j < data.size() ; 1 +=> j) { data[j].scaledVal() => float f; if ( firstSection < firstSectionMax ) { Std.mtof( 70.0 + f*20.0 ) => inst[0].freq; ( firstSection * .7 * (1.0 / firstSectionMax) + .05) => inst[0].noteOn; Std.mtof( 70.2 + f*20.0 ) => inst[1].freq; ( firstSection * .7 * (1.0 / firstSectionMax) + .05) => inst[1].noteOn; ((f * -50) + 120)::ms => now; // wait //0.1 => inst[0].noteOff; // stop note 1 +=> firstSection; } else if ( firstSection == firstSectionMax ) { 1::second => now; 1 +=> firstSection; } else { Std.mtof( 35.0 + f*70.0 ) => inst[j].freq; 1.8 => inst[j].noteOn; // start note ((f * -70) + 105)::ms => now; // wait //0.1 => inst[j].noteOff; // stop note } } if (data[0].isFinished()) { 10::second => now; // Let reverb die... .. . . 1 => end; } }