ΣSigmaStudio Ask AI Русский Log in

Different between peak and RMS envelope in readback

SigmaDSP & SigmaStudio Philip Mar 8, 2011 00:00 8 replies Original on forum ↗
Subscribe
Philip Question
Mar 8, 2011 00:00

I am using adau1701.

I use a MCU to do some audio level value read back.

I have follow the below thread which solve half of my problem

https://ez.analog.com/thread/2278?tstart=0

Another problem I found is the different between using a peak envelope and RMS envelope.

I do a sine wave source, with a gain control, follow by a envelope block and finially the reading block.

I can get the reading correct when I use the peak envelope.

But when I use the RMS envelope, with the same equation,

I get -6dB when i didn't apply any gain.

I get -26dB when i apply a -10db gain.

If I apply a gain of -20dB, the reading is -46dB

If I apply a gain of -15dB, the reading is -36 dB

It is I have a base of -6 without any gain, and then the resulted reading is -6+(2*whatever gain I apply)

Is there any equation to get the value from RMS envelope to be correct?

What is the different between the two?

Audio Signal Processors

SigmaDSP Audio Processors

adau1701

rong Reply
Mar 8, 2011 00:00

In the help file, look for Envelop RMS section, it clearly says,

"Mathematically speaking, RMS refers to the square root of the average of a set of values. This particular implementation of the algorithm however, outputs the "mean square" since it does not take the square root. If true RMS is required, connect and external Square root algorithm to find the RMS envelope of the signal"

Philip Reply
Mar 8, 2011 00:00

Correct me if I am wrong.

In Math, I usually do multiple/divide by root 2 to convert peak to peak value to RMS value

however I can not get the read back value correct here. Can you point me to the right direction?

ADIApproved Reply
Mar 8, 2011 00:00

Philip, which envelope are you using? There are several implementations in SigmaStudio, which you can see in this thread:

http://ez.analog.com/message/7669#7669

Envelope Implementations:

Envelope Peak : Outputs the peak level of a signal
This is very accurate for finding the peak level of a signal.

Signal Envelope : Outputs the mean-squared level of a signal (not root-mean-squared, but just mean-squared)
The accuracy of this cell can break down when the rmsTC is too fast or too slow. It's a bit of a tradeoff between responsiveness and accuracy that you have to play around with.
When the input signal level is very low, the accuracy of this algorithm can get bad, quickly. This is simply due to the implementation of the algorithm and the way signals are stored in the DSP.

Running Average : Outputs the average level of a signal (an approximation of RMS)
This is the best for reading back an approximate RMS level of a signal. The timing values need to be played with a bit, but overall you should get pretty accurate results.
When the input signal level is very low, the accuracy of this algorithm can get bad, quickly. This is simply due to the implementation of the algorithm and the way signals are stored in the DSP.

You're correct that mathematically you should expect the RMS level of a sine tone to be 3 dB lower than the peak level. You should get results close to this with the running average cell, but beware the fact that the accuracy will break down if the signal level gets too low. The workaround to that is to artifically boost the signal prior to the running average cell's input (up to +24 dB is allowed) and then gain it down by -24 dB on the output of the running average cell. That will reduce or remove the low-level accuracy problems, at the expense of a few extra DSP cycles.

Philip Reply
Mar 10, 2011 00:00

I am using the Envelope Peak and Signal Envelope

Two different setup as below:

(1) sinegenerate > gain control > envelope peak > readback

(2) sinegenerate > gain control > signal envelope > readback

And I use the equation below to canculate the dBFS value:

Amplitude in dBFS = 20 * log (Readback_Value / (2^19 - 1))

For (1)

with gain control equal 0dB, readback is 0dBFS

with gain control equal -10dB, readback is -10dBFS

For (2)

with gain control equal 0dB, readback is -6dBFS

with gain control equal -10dB, readback is -26dBFS

with gain control equal -15dB, readback is -36dBFS

Is it the same result if you do the same setup?

I understand (1) but don't understand the readback value of (2)

Thanks a lot.

rong Reply
Mar 10, 2011 00:00

In signastudio, 0db is 0x800000, so when you use the peak envlope, you get something very close to 0x800000 if no gain applifed to the signal. When you use the mean-square block, you get something close to 0x400000, which is 1/2 of the peak, as I mentioned eariler, you take root of it, you get sqrt(1/2), which in turn is 1/sqrt(2). is that what you are expecting? So apply root-2 before you convert the reading to the dB scale, it will then all make sense.

Philip Reply
Mar 10, 2011 00:00

It is not true, you can do the test , i will get 524287 which is (2^19-1) when apply no gain to the signal.

The method you suggest I tried as well, detail is as follow:

For the peak envelope with -10db gain:

Read back value is 165390

With the equation 20*log(165390/524287) = -10.02dBFS

For the signal envelope with -10db gain:

Read back value is 26153

With the equation 20*log(26153/524287) = -26.04dBFS

With your suggestion(If i did't missunderstand), I try multiple by sqrt(2)

20*log( (26153*sqrt(2))/524287 ) = -23.03dBFS

Still seem not correct. Any suggestion? Thanks

ADIApproved Reply
Mar 10, 2011 00:00

The Signal envelope does Mean-Square, not Root-Mean-Square.

Let's step through your example of a sine tone with -10 dB of gain.

If you're inputting a sine wave with -10 dB gain, you have a peak amplitude of 10^(-0.5) = 0.316, because peak = 10^log(x/20), where x is the gain.

You're reading back a peak level of 165390, and 165390 / 524287 = 0.316. That matches what we got above. So, this proves the peak detector is working fine.

To get the mean squared of this signal, first you square it, then you take the mean. That calculates out to be 0.5 for a full-scale sine wave, or -6 dB. When you apply -10 dB of gain to the sine wave, you should get -16 dB, right? Wrong! Actually, you need to square the amplitude of the sine wave as well.

So, for a sine wave, MS = (amplitude)^2 * 0.5

In the case of a -10 dB sine wave, amplitude = 0.316. So, MS = 0.316^2 * 0.5 = 0.05.

Convert to dB and you get 20*log(0.05) = -26 dB.

So, the math works out.

For root mean square, you simply multiply the peak value by 0.707 for a sine wave.

So, for a -10 dB sine wave, you get 0.316 * 0.707 = 0.2234

Convert to dB and you get 20*log(0.2234) = -13 dB.

In any case, why are you using the Mean-Square (Signal Envelope) cell? I think the Root-Mean-Square (Running Average) cell is easier to understand.

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin