// Octave-band Spectrum Analyzer and CPU Heater // by PRC, March 2008 BPF b[10]; gain g[10]; gain g2[10]; OnePole p[10]; ["20Hz","40Hz","80Hz","160Hz","320Hz", "640Hz","1280Hz","2.5kHz","5kHz","10kHz"] @=> string names[]; MAUI_View myWinder; myWinder.size(250.0,570.0); MAUI_Slider disp[10]; MAUI_Button exit; exit.size(250,80); exit.name("Exit"); exit.position(0,500); myWinder.addElement(exit); int i; 20.0 => float basefreq; 4.0 => adc.gain; for (0=>i;i<10;1+=>i) { adc => b[i] => g[i] => g2[i] => p[i] => blackhole; b[i] => g2[i]; // hack to get around 3 => g2[i].op; // multi-patch "feature" 0.9995 => p[i].pole; // smoothing 2.0 => b[i].Q; basefreq => b[i].freq; <<< "Band 1 = ", basefreq >>>; 2.0 * basefreq => basefreq; disp[i].position(0.0,50.0*i); disp[i].range(0.0,1.0); disp[i].precision(1); disp[i].name(names[i]); myWinder.addElement(disp[i]); } myWinder.display(); while (!exit.state()) { 0.100 :: second => now; for (0=>i;i<10;1+=>i) // (Math.log(p[i].last() + 0.01) + 2.0) * 0.5 => disp[i].value; 0.5 * (Math.log10(p[i].last() + 0.01) + 2.0) => disp[i].value; // p[i].last() => disp[i].value; } myWinder.destroy();