I am developing an aplication for iPhone which records audio and saves that audio file. I need to create a UI similar to that in Voice Memo app with a VU meter. I implemented code to record audio, but I have no idea about VU meter implementation. Looking forward to a reply. Thanks in advance.
2 Answers
A VU meter just displays the short term amplitude of the signal on a logarithmic scale (dB). You need to continuously measure the amplitude (RMS) of the signal over a short time interval (e.g. 10 ms) and then convert the RMS magnitude to dB and update the meter display.
RMS_signal (V) = sqrt(sum(x^2) / N)
where N is the number of samples (e.g. N = 441 for a 10 ms sample at 44.1 kHz sample rate)
Magnitude (dB) = 20.0 * log10(RMS_signal) + K
where K is a calibration constant (dB offset).
You may also want to add a low pass filter to smooth out the displayed amplitude. See stackoverflow.com/questions/2167513.
You may use OpenGL based simple and easily extensible framework gl-data-visualization-view to display UV meter. You should just add GLDataVisualizationView, set visualization type as analog meter and set value to visualize.

- 254
- 1
- 11
-
Hi mike-dutka! Thanks for your gl-data-visualization-view code. It's great! How Can I add a low pass filter to your code? I'm using right now the code suggested by meaning-matters on this link: http://stackoverflow.com/questions/9247255/am-i-doing-the-right-thing-to-convert-decibel-from-120-0-to-0-120 is it good enough for a smooth niddle swing? Thanks for your time! – neowinston May 06 '13 at 19:51