// Space Music Controller // Copyright 2009 Les Hall class spacey { // the effects chain Gain input => LPF lpf => JCRev rev1 => Echo echo1 => NRev rev2 => Gain boost => dac; second => echo1.max; second / 16 => echo1.delay; 0.5 => echo1.mix; // guitar input adc.left => Gain guitarGain => input; 2 => guitarGain.gain; // banded wave guide instrument BandedWG band => input; 1 => band.preset; 3 => band.gain; // rhodey instrument Rhodey rhodey => input; Flute flute => echo1; 0.07 => flute.gain; // mandolin instrument Mandolin mandy => input; 0.8 => mandy.stringDamping; 0 => mandy.stringDetune; 0.6 => mandy.gain; // recording interface dac => Gain attenuate => WvOut wvout => blackhole; 0.5 => attenuate.gain; "SpaceMusic.wav" => wvout.wavFilename; 100 => int size; MAUI_View spacePort; spacePort.size(8*size, 4*size); spacePort.name("Space Port"); MAUI_Slider volume; volume.name("Volume"); volume.position(0, 0); volume.size(2*size, size); volume.range(0, 1); volume.value(0.8); spacePort.addElement(volume); MAUI_Slider lpfFreq; lpfFreq.name("LPF Freq"); lpfFreq.position(2*size, 0); lpfFreq.size(2*size, size); lpfFreq.range(100, 500); lpfFreq.value(300); spacePort.addElement(lpfFreq); MAUI_Slider revMix; revMix.name("Reverb Mix"); revMix.position(4*size, 0); revMix.size(2*size, size); revMix.range(0, 0.5); revMix.value(0.25); spacePort.addElement(revMix); spacePort.display(); fun void monitor_Volume() { 5 * volume.value() => boost.gain; while (true) { volume => now; 5 * volume.value() => boost.gain; } } spork ~ monitor_Volume(); fun void monitor_revMix() { revMix.value() => rev1.mix; revMix.value() => rev2.mix; while (true) { revMix => now; revMix.value() => rev1.mix; revMix.value() => rev2.mix; } } spork ~ monitor_revMix(); fun void monitor_lpfFreq() { lpfFreq.value() => lpf.freq; while (true) { lpfFreq => now; lpfFreq.value() => lpf.freq; } } spork ~ monitor_lpfFreq(); fun void bandPluck() { while (true) { 1 => band.pluck; Math.rand2f(10, 20) * second => now; } } spork ~ bandPluck(); fun void rhodeyPluck() { while (true) { 1 => rhodey.noteOn; Math.rand2f(5, 15) * second => now; } } spork ~ rhodeyPluck(); fun void flutePlay() { 1::minute => now; 1 => flute.noteOn; while (true) { Math.mtof(Math.rand2(50, 70)) => flute.freq; Math.rand2f(2, 10) * second => now; } } spork ~ flutePlay(); fun void mandyPlay() { 4::minute => now; 1 => mandy.noteOn; now => time tStart; while ((now-tStart) < 2::minute) { Math.mtof(Math.rand2(25, 40)) => mandy.freq; 1 => mandy.pluck; Math.rand2f(4, 11) * second => now; } } spork ~ mandyPlay(); 8::minute => now; "SpaceMusic.wav" => wvout.closeFile; spacePort.destroy(); } spacey Shane;