//CHUCK GRANULATOR //RANDOMIZE PARAMETERS 90 => int maxGr; //100 => int maxGr; SndBuf bufs[maxGr] => PitShift p0 => dac; ; SndBuf envs[maxGr]; //Create arrays to hold different sound-samples and envelopes for sound-effects string sound_samples[9]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/181897__supuhmagikarp__chimes.wav" => sound_samples[0]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/48796__itsallhappening__bell-outside.wav" => sound_samples[1]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/68261__juskiddink__bell4.wav" => sound_samples[2]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/62561__thanvannispen__ohm-singing-cool2-cut1.aiff" => sound_samples[3]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/62562__thanvannispen__ohm-singing-cool2-cut2.aiff" => sound_samples[4]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/411090__inspectorj__wind-chime-gamelan-gong-a.wav" => sound_samples[5]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/437475__camel7695__short-eerie-chorus.wav" => sound_samples[6]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/417116__dersinnsspace__tibetan-bowl-right-hit.wav" => sound_samples[7]; "/Users/hannahleechoi/Documents/hw3_final_submit/seedWav/400819__enhuber__singing-bowl.wav" => sound_samples[8]; string envelopes [10]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_blackman.aif" => envelopes[0]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_expodec.aif" => envelopes[1]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_gauss.aif" => envelopes[2]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_hamming.aif" => envelopes[3]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_hanning.aif" => envelopes[4]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_pulse.aif" => envelopes[5]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_quasiGauss.aif" => envelopes[6]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_rexpodec.aif" => envelopes[7]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_threeStageLinear.aif" => envelopes[8]; "/Users/hannahleechoi/Documents/hw3_final_submit/grainEnv/gEnv_tri.aif" => envelopes[9]; while (true) { for(0 => int i; i < maxGr; i++) { //Choose sample & envelope //samples[0] => bufs[i].read; //sound_samples[0] => bufs[i].read; //sound_samples[1] => bufs[i].read; sound_samples[2] => bufs[i].read; //YES //sound_samples[3] => bufs[i].read; //sound_samples[4] => bufs[i].read; //sound_samples[5] => bufs[i].read; //sound_samples[6] => bufs[i].read; //sound_samples[7] => bufs[i].read; //sound_samples[8] => bufs[i].read; // //envelopes[5] => envs[i].read; //NO //envelopes[7] => envs[i].read; //GOOD envelopes[7] => envs[i].read; //GOOD //spork ~ grain_control_effect_03( bufs[i], envs[i], newpos, grainDur, gRate ); Math.random2( 0, bufs[i].samples() ) => int newpos; //Math.random2( 100, 100 ) => int grainDur; //Math.random2( 100, 300 ) => int grainGap; //Math.random2f( 1.0, 1.0 ) => float gRate; 0.3 => p0.mix; //1000 => int grainDur; //300 => int grainGap; 900 => int grainDur; //GOOD 250 => int grainGap;//GOOD 0.7 => float grainGain;//GOOD 0.2 => float grainPan; //GOOD Math.random2f( 0.3, 1.0 ) => float gRate; //GOOD //0.7 => float gRate; // //900 => int grainDur; //250 => int grainGap; //0.5 => float gRate; //0.5 => float grainGain; //0.2 => float grainPan; //Math.random2( 0, bufs[i].samples() ) => int newpos; //Math.random2f( -0.5, 1.0 ) => p0.mix; //Math.random2( 100, 150 ) => int grainDur; //Math.random2( 100, 300 ) => int grainGap; //Math.random2f( -5.0, 2.0 ) => float grainGain; //Math.random2f( -1.0, 1.0 ) => float grainPan; //Math.random2f( 0.3, 0.7 ) => float gRate; // //0.4 => p0.mix; //150 => int grainDur; //150 => int grainGap; //0.5 => float grainGain; //0.2 => float grainPan; //1.0 => float gRate; //Choose read position // 8000 => int newpos; //use this for reading from the same position each time // Math.random2( 0, bufs[i].samples() ) => int newpos; //The Math.random2 function will choose a position between the beginning and end of the sample. //bufs[i].samples() gives length of the current sample in samples //int newpos creates a local variable to pass to the function below //Parameter control //Set mix to all pitch shift (no dry signal) // Math.random2f( -1.0, 1.0 ) => p0.mix; //Choose grain duration // Math.random2( 60, 150 ) => int grainDur; //300 => int grainDur; //use this for fixed grain duration //Choose gap duration // Math.random2( 80, 300 ) => int grainGap; //300 => int grainGap; //Choose amplitude // Math.random2f( -5.0, 2.0 ) => float grainGain; //1 => float grainGain; //Choose panning // Math.random2f( -1.0, 1.0 ) => float grainPan; //0 => float grainPan; //Playback Speed // Math.random2f( 6.0, 7.0 ) => float gRate; //1 => float gRate; //3 parameters //spork ~ grain_control_effect_03( SndBuf buf, SndBuf envbuf, int pos, int gdur, float grainRate ) //spork ~ grain_control_effect_03( bufs[i], envs[i], newpos, grainDur, gRate ); //5 parameters <<<("bufs[",i,"]","envs[",i,"]","newpos=",newpos,"grainDur=",grainDur,"grainGain=",grainGain,"grainPan=", grainPan,"gRate=",gRate, "grainGap",grainGap)>>>; spork ~ grain_control_effect_05( bufs[i], envs[i], newpos, grainDur, grainGain, grainPan, gRate ); grainGap::ms => now; //this is the space between grains } 15::ms => now; //100::ms => now; } fun void grain_control_effect_05( SndBuf buf, SndBuf envbuf, int pos, int gdur, float grainGain, float grainPan, float grainRate ) { Gain g; g => Pan2 p => dac; //added panning ugen buf => g; envbuf => g; 3 => g.op; grainGain => g.gain; //made gain a variable grainPan => p.pan; //for panning pos => buf.pos; grainRate => buf.rate; 1 => buf.loop; 0 => envbuf.pos; (envbuf.length() / (ms*gdur)) => envbuf.rate; gdur::ms => now; } fun void grain_control_effect_03( SndBuf buf, SndBuf envbuf, int pos, int gdur, float grainRate ) { Gain g; g => Pan2 p => dac; buf => g; envbuf => g; 5 => g.op; pos => buf.pos; grainRate => buf.rate; 1 => buf.loop; 0 => envbuf.pos; (envbuf.length() / (ms*gdur)) => envbuf.rate; gdur::ms => now; //1000::ms => now; }