RMS value of audio signal - Page 1
Forum section: electronics / projects

author: rakeshm55
author_rank: Regular Contributor
timestamp: May 07, 2013, 06:54:31 am
content: Hi,I want to calculate the RMS value of an audio signal. The audio(mic) is connected to a codec chipset. The PCM value are captured by a DSP.Now I want to calculate the RMS value of the audio .How to do this?? I believe simple square and add may not work. What will be the suitable procedure or algorithm.Regards

author: Skimask
author_rank: Super Contributor
timestamp: May 07, 2013, 07:08:56 am
content: RMS what?Lettuce?

author: rakeshm55
author_rank: Regular Contributor
timestamp: May 07, 2013, 07:53:03 am
content: HiMy aim is to detect silence or there is a voice activity.For this purpose I would measure the energy level of the audio signal.If the level is above a threshold I would declare non silence mode.I will deduct the energy level of the signal by calculating the RMS value of the audio signal received. The question is how to calculate theroot mean square of a given audio signal whose raw PCM values I have. The PCM values of the audio sample is unsigned and wont this inherently add an offset thus upsetting the normal procedure for calculating the RMS value.

author: KJDS
author_rank: Super Contributor
timestamp: May 07, 2013, 08:08:22 am
content: Your issues is in squaring the unsigned number. Once you've worked out an algorithm for that, add them up, take the average and then the root.Personally, I'd just look for a few spikes within a given time period that were above the threshold and decide on that.

author: cyr
author_rank: Frequent Contributor
timestamp: May 07, 2013, 08:12:09 am
content: In theory you unsigned data has a DC level of 50%, just subtract that and you get "AC" data to operate on.In practice you may have another DC level because of offsets in the electronics, you may want to calculate an average level and subtract that instead...

author: michaelym
author_rank: Regular Contributor
timestamp: May 07, 2013, 08:35:38 am
content: I think you can calculate the energy mathematically using this:http://en.wikipedia.org/wiki/Energy_(signal_processing)Since your signal will be discrete you can use a sum instead of an integral.

author: hlavac
author_rank: Frequent Contributor
timestamp: May 07, 2013, 03:09:49 pm
content: First you need your samples to be signed integers with zero in the middle.If you have 16bit unsigned sample format your zero will be probably 32768. Just subtract 32768 from each sample. Offset should not be s problem, audio ADCs are usually AC coupled properly.Now you can square the samples to get their power.Average across several samples to get average power in corresponding time interval.You dont need to calculate RMS if you only want to test against threshold.If you really want RMS value (root of mean squares) just take square root of the average power.But as i said you can as well square your threshold and save computing power of the square root...

author: rakeshm55
author_rank: Regular Contributor
timestamp: May 09, 2013, 05:38:08 am
content: Quote from: hlavac on May 07, 2013, 03:09:49 pm

author: hlavac
author_rank: Frequent Contributor
timestamp: May 09, 2013, 09:43:27 am
content: If you have signed integer PCM samples on two's complement just proceed with averaging the squares (using signed int multiplication!)