This library reads data from an ADC pin and returns the RMS value of the input simply using RMS avarage.
The root mean square (abbreviated RMS or rms), also known as the quadratic mean, is a statistical measure of the magnitude of a varying quantity.
Here is simply implemented by getting samples, for each of them making the root, then the mean for all the collected samples, and finally square the result.
This library is a derivation of the work you can find here: http://davidegironi.blogspot.it/2013/05/avr-atmega-audio-input-root-mean-square.html
So for more information about RMS, you can read the post above.
Code
Notes
- read risk disclaimer
- excuse my bad english
hmmm... what do you get on console on your side, here it seems quite scrambled...
ReplyDeleteYou have to use the processing.org display tool provided. Value are printed out not as ascii, so a uart terminal will not work as expected.
DeleteSeems I saw that ;-) can I use it as a SPL meter this way ?
ReplyDeleteI guess I can do this:
soundDbl = (double)audioGet.getSpl(voltageRms, AUDIO_VOLTREF, AUDIO_DBREF);
Spark.publish("librato_bc2_dbl", String((int)soundDbl));
Yes you can, but an FFT library like the one used here it will be better: http://davidegironi.blogspot.it/2014/02/a-simple-sound-pressure-level-meter-spl.html
Deletehere it is stuck at 72 all the time, what can I do to make it more reactive ?
ReplyDeletealso do you think the fft radix would work on a spark as is ?
That could be due to pre board noise. You could try disable the dynamicbias and set the biaszeroraw value according to your adc reading with no noise. To make it more reactive you have to set the smooth filter. You also could set an rms correction (offset) value. But the very first thing to do, is check you pre board noise with a scope or a frequency analyzer.
Delete