tags:

views:

209

answers:

1

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.

+1  A: 

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.

Paul R