// MUSIC 256a Homework 0/Design Etude 1: A ChucK Program That Makes Sound // Kim Kawczinski // 29.09.19 // initialize fundamental frequency for effect float f0; // create signal flows for three sine oscillators SinOsc m => Gain g => NRev r => dac; SinOsc n => Gain h => NRev s => dac; SinOsc o => Gain i => NRev t => dac; // set gains (not quite square wave...) 0.3 => g.gain; 0.15 => h.gain; 0.1 => i.gain; // set reverb mixes 0.5 => float rm; rm => r.mix; rm => s.mix; rm => t.mix; // function that varies a SinOsc frequency randomly fun void wiggle( SinOsc sine, float f, float win ) { // sine --> sine oscillator // f --> current frequency of sine // win --> interval for frequency variation Math.random2f( -win/2, win/2 ) => float wiggle; wiggle +=> f; f => sine.freq; } // function that plays the effect fun void play( float f0 ) { // f0 --> fundamental frequency of effect // initialize SinOsc frequencies [1*f0, 3*f0, 5*f0] @=> float freqs[]; // assign frequencies to objects freqs[0] => m.freq; freqs[1] => n.freq; freqs[2] => o.freq; // calculate window width 3 * Math.ceil( f0/100 ) => float win; // advance time, evolve oscillator frequencies while( true ) { 1::second => now; wiggle( m, freqs[0], win ); wiggle( n, freqs[1], win ); wiggle( o, freqs[2], win ); } } // utilize play function to auralize effect // modify f0 to change fundmental frequency 550.0 => f0; play( f0 );