// Octave-band Spectrum Analyzer and CPU Heater, // by Perry R. Cook, April 2008, updated Jan 2014 BPF b[10]; Gain g[10]; OnePole p[10]; MAUI_View myWinder; myWinder.size(330.0,180.0); MAUI_LED led[10]; MAUI_Button exit; exit.name("Exit"); exit.size(70,65); exit.position(0,115); myWinder.addElement(exit); MAUI_Slider vol; vol.position(60,110); vol.size(250,70); vol.name("Input Gain"); vol.range(0.0,50.0); 8.0 => vol.value; myWinder.addElement(vol); 1.0 => adc.gain; // global gain adjustments adc => Gain inGain; for (0=>int i;i<10;1+=>i) { inGain => b[i] => g[i] => p[i] => blackhole; b[i] => g[i]; // make a 3 => g[i].op; // squarer 0.999 => p[i].pole; // and smoothing filter 2.0 => b[i].Q; 20.0 * Math.pow(2.0,i) => b[i].freq; // octave bands led[i].position(30.0*i,80.0); led[i].color(3); myWinder.addElement(led[i]); led[i].light(); } myWinder.display(); 0.0 => float tempy; while (!exit.state()) { 0.10 :: second => now; vol.value() => inGain.gain; for (0=>int i;i<10;1+=>i) { 75.0 - 40.0 * (0.5 * (Math.log10(p[i].last() + 0.01) + 2.0)) => tempy; if (tempy < 0.0) 0.0 => tempy; led[i].position(30.0*i,tempy); led[i].unlight(); if (p[i].last() > 0.1) { led[i].color(1); if (p[i].last() > 10) led[i].color(0); led[i].light(); } myWinder.addElement(led[i]); } } myWinder.destroy();