Reply by Andor November 22, 20072007-11-22
On 22 Nov., 02:29, "gtek" <gtekp...@hotmail.com> wrote:
> Hi all, > > I'm playing around with an audio level compressor and calculate the RMS > value in a rectangular window. > I'm quite new to this ( also to dsp programming ), but my questions are: > > - Is there an optimum size for the averaging window? > The bigger the window the more true the average RMS will be, i think. > But a big averaging window takes too much load on the processing power of > my dsp. > > -Is there a better/faster way to do this, i heard of averaging with a 1 > pole lowpass. how is this done? just applying a 1 pole over the input and > sqrt it? What would be the cutoff for this lowpass?
No, square the input to the lowpass and take the square root of the output (the cutoff is a parameter that you can label "RMS time constant" - the higher the cutoff, the faster the "RMS" value reacts to signal changes). However, most compressors do level comparison in log-domain, so you don't really have to take the square root, it can be included in your level comparison constants. Regards, Andor
Reply by Darol Klawetter November 22, 20072007-11-22
On Nov 22, 12:21 am, Darol Klawetter <darol.klawet...@l-3com.com>
wrote:
> On Nov 21, 7:29 pm, "gtek" <gtekp...@hotmail.com> wrote: > > > > > > > Hi all, > > > I'm playing around with an audio level compressor and calculate the RMS > > value in a rectangular window. > > I'm quite new to this ( also to dsp programming ), but my questions are: > > > - Is there an optimum size for the averaging window? > > The bigger the window the more true the average RMS will be, i think. > > But a big averaging window takes too much load on the processing power of > > my dsp. > > > -Is there a better/faster way to do this, i heard of averaging with a 1 > > pole lowpass. how is this done? just applying a 1 pole over the input and > > sqrt it? What would be the cutoff for this lowpass? > > > I hope someone will take some time to provide my answer, i would be very > > thankfull. > > > Regards, > > > Evert > > If your processor requires many more cycles to do a divide than to do > a compare, then you can save cycles by accumulating 2^n samples and > shifting down by n to perform the divide. > > Darol Klawetter- Hide quoted text - > > - Show quoted text -
Correction: Above, I meant to say "shift" rather than "compare".
Reply by Darol Klawetter November 22, 20072007-11-22
On Nov 21, 7:29 pm, "gtek" <gtekp...@hotmail.com> wrote:
> Hi all, > > I'm playing around with an audio level compressor and calculate the RMS > value in a rectangular window. > I'm quite new to this ( also to dsp programming ), but my questions are: > > - Is there an optimum size for the averaging window? > The bigger the window the more true the average RMS will be, i think. > But a big averaging window takes too much load on the processing power of > my dsp. > > -Is there a better/faster way to do this, i heard of averaging with a 1 > pole lowpass. how is this done? just applying a 1 pole over the input and > sqrt it? What would be the cutoff for this lowpass? > > I hope someone will take some time to provide my answer, i would be very > thankfull. > > Regards, > > Evert
If your processor requires many more cycles to do a divide than to do a compare, then you can save cycles by accumulating 2^n samples and shifting down by n to perform the divide. Darol Klawetter
Reply by Jerry Avins November 22, 20072007-11-22
cincydsp@gmail.com wrote:
> On Nov 21, 8:29 pm, "gtek" <gtekp...@hotmail.com> wrote: >> Hi all, >> >> I'm playing around with an audio level compressor and calculate the RMS >> value in a rectangular window. >> I'm quite new to this ( also to dsp programming ), but my questions are: >> >> - Is there an optimum size for the averaging window? >> The bigger the window the more true the average RMS will be, i think. >> But a big averaging window takes too much load on the processing power of >> my dsp. >> > > If you're just doing simple averaging across a rectangular window, you > can implement it in an efficient way whose execution time complexity > doesn't grow with the window size. Instead of performing the whole > average calculation for each sample, just maintain an accumulator that > you use for the average, along with a delay buffer for previous > samples. For each new sample that you get in, add it to the > accumulator, then subtract the value from the delay buffer that just > slid out of your average window. Divide by the window length and you > have your average. > > One thing you'll want to keep in mind, though, is that roundoff error > can accumulate (no pun intended) over time, so you may need to > periodically recalculate the value of the accumulator based upon the > values in the delay buffer to preserve accuracy. The frequency with > which you might need to do this would vary depending upon the > precision of the datatype you're using.
There is no accumulation of error if all calculation is fixed point. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by November 22, 20072007-11-22
On Nov 21, 8:29 pm, "gtek" <gtekp...@hotmail.com> wrote:
> Hi all, > > I'm playing around with an audio level compressor and calculate the RMS > value in a rectangular window. > I'm quite new to this ( also to dsp programming ), but my questions are: > > - Is there an optimum size for the averaging window? > The bigger the window the more true the average RMS will be, i think. > But a big averaging window takes too much load on the processing power of > my dsp. >
If you're just doing simple averaging across a rectangular window, you can implement it in an efficient way whose execution time complexity doesn't grow with the window size. Instead of performing the whole average calculation for each sample, just maintain an accumulator that you use for the average, along with a delay buffer for previous samples. For each new sample that you get in, add it to the accumulator, then subtract the value from the delay buffer that just slid out of your average window. Divide by the window length and you have your average. One thing you'll want to keep in mind, though, is that roundoff error can accumulate (no pun intended) over time, so you may need to periodically recalculate the value of the accumulator based upon the values in the delay buffer to preserve accuracy. The frequency with which you might need to do this would vary depending upon the precision of the datatype you're using. Jason
Reply by gtek November 21, 20072007-11-21
Hi all,

I'm playing around with an audio level compressor and calculate the RMS
value in a rectangular window.
I'm quite new to this ( also to dsp programming ), but my questions are:

- Is there an optimum size for the averaging window?
The bigger the window the more true the average RMS will be, i think.
But a big averaging window takes too much load on the processing power of
my dsp.

-Is there a better/faster way to do this, i heard of averaging with a 1
pole lowpass. how is this done? just applying a 1 pole over the input and
sqrt it? What would be the cutoff for this lowpass?

I hope someone will take some time to provide my answer, i would be very
thankfull.

Regards,

Evert