RMS and peak limiters, latency/look ahead

Hi

It seems that the RMS limiter does not introduce any signal delay. Is that correct?

What window length is used when the RMS value is calculated/how is the RMS value calculated?

When adding the limiter output and the inverted input signal, the signals cancel when the input signal is far below the limiter threshold. As the signal gets closer to the threshold, the signals do not fully cancel but the limiter still has its "active flag" to zero. I.e. the limiter degrades the signal unless far below the set threshold even though the limiter is not "active". Is it because the limiter does a gradual transition? 

Is it also true that the Peak limiter does not delay the signal? I.e. that it has no lookahead? I think I can implement look ahead by using a delay block.

I am using Sigma Studio 4.5 and ADAU1442. The RMS limiter has the parameters: RMS TC (dB/s), Decay (dB/s), and Threshold (dB).

Best regards,

Kim



Info.
[edited by: HifiDSP at 7:03 PM (GMT 0) on 19 Jul 2020]
Parents
  • 0
    •  Analog Employees 
    on Jul 22, 2020 7:56 PM

    Hello Kim,

    There is no delay going through the limiters. The SigmaDSPs run the entire program during one sample period. So the current sample goes into the limiter, the sidechain is calculated to determine the gain factor to apply to the audio then the current sample is multiplied by the gain factor to produce the resulting sample. So it all happens during the current sample. 

    The peak compressors will react to a peak during the current sample so no need to add a delay to look-ahead. Now with the RMS compressor/limiters there is an attack time. For those dynamics cells you could do a look-ahead but in some ways the slow attack is the sound that is desired. You have the flexibility to do either. In the analog world you cannot do the instantaneous peak limiting. 

    The RMS time constant is derived with this formula:

    Tc = 1.0- (10^ (dBps / (10*fs) ) )

    dBps = dB per second that in entered in the GUI

    Tc = Time Constant that is entered into the DSP parameter memory location

    fs = sampling rate

    So the audio comes in, the absolute value is then taken and the peak will be tested against the current peak. If it is greater then this new one is now the peak, if it is less then the old peak remains. Then the Tc is applied to the current peak and then that result goes into finding the gain factor from the table to apply to the audio. There are more details but this is a quick explanation. 

    The Decay is calculated using this formula. 

    Release = dBps / (96*fs)

    Regarding the gradual gain change, Yes, some of the compressor/limiters have a soft knee point or have a button to choose this. 

    You may also be reaching the threshold earlier than you think. Also, keep in mind that the meters in SigmaStudio read 3dB lower. A 0dBFS signal will read as -3dB. 

    Threshold is done by changing the gain factors in the table of gain factors. Basically they are moved up or down the table to move the threshold point to a different input level. You can also implement this using a volume control for limiters with external detector inputs. It is simpler than writing all new compressor gain table. 

    Dave T

  • Hello Dave,
    Thanks for the explanation.

    Your formula for TC confuses me. I assume TC should be the window length in seconds. Inserting 50 dB/s I get:
    1.0-(10^(50/(10*fs))) = -2.3988e-04
    BrettG provided this formula:
    TC(ms) = 20/(dbps *ln(10))*10^3
    20/(50*ln(10)) = 0.1737 [seconds]

    I hope it is okay, if I tell about the problem I am trying to solve.
    I am working on an active surround system with DSP XO two-way speakers and multiple subwoofers. Given the combination of drivers, DACs and PAs ensures that for normal music (crest factor > 6 dB), I thought the speakers should not be able to overheat and worst-case displacement should be below XMax, not close to Xmech. Therefore, I had not yet added RMS and peak limiters for power and displacement limiting.
    However, someone played around with Parametric EQ in Sigma Studio and suddenly there was a very loud high frequency note. I believe a biquad became unstable (bad coefficient transfer) and caused the output to exceed full scale. In the Sigma DSP, the signal can go up to +24 dB but the DACs only output up to about +3-4 dB. It took the person perhaps 30-40 seconds to shut down the power amplifiers and that was too long. The front channel tweeters overheated and one of them was destroyed.
    This incident has made me aware of two things:
    1) For the Sigma DSP and DAC (AD1938) combination, the Voltage output can exceed full scale, it does not clip unless digital signals exceeds +3-4 dB.
    2) The tweeter power handling is 250W peak, 100W long term (1 minute on, 2 minutes off etc.), IEC-5 with a high pass Butterworth 2nd order filter at 2500 Hz. IEC-5 power handling is for a pink noise signal (6 dB crest factor) AND the high pass filter. For a sine wave the crest factor is only 3 dB. If a high frequency sine wave is reproduced at a high level, a lot of power is put into the tweeter. The tweeter will be able to handle far less than 100W for a sine wave (and way less DC power, ~5W I have read). Therefore a tweeter can easily be destroyed by playing a wave signal at a high level.

    I think the solution is to use limiters to protect drivers and our ears from high frequency waves. The limiters should turn all the output signals for all drivers in all speakers down simultaneously. This I can accomplish by creating a side chain with an RMS limiter for each driver, find the minimum limiter gain value and scale all driver signals by this value. In this case, I believe it is sufficient to monitor the tweeter signals only. However, it is vital that the audio quality is not degraded, hence all the questions about the limiters.

    Best regards,
    Kim

  • 0
    •  Analog Employees 
    on Aug 25, 2020 2:50 PM in reply to HifiDSP

    Hello Kim,

    I think the issue you are seeing is the fact that the IIR filter is being calculated as a 5.23 number. So your numbers are really small and it will get down into the noise floor much more quickly. 

    Usually it is best to calculate the power using an RMS envelope generator. This does two things. It squares the input and then gets a running average of the squares. So you can take the output and get the square root to obtain the average power over the length of time of the time constants. So by adjusting the TC and the Decay you can roughly model the heating curve of the voice coil over time. 

    I don't know if this is readable. 

    This project also increases the gain of the input signal by 18dB to bring it up out of the noise floor. 

    This example was from a program for the ADAU1452/1467 which has more headroom than the ADAU1442. 

    Are you committed to using the 1442? The ADAU452 would be a much better part to use for this application and costs less. 

    We also have a speaker protection algorithm but it only runs on the ADAU1452/1467 family of parts. Plus, it does require I/V feedback. 

    Dave T

  • 0
    •  Super User 
    on Aug 26, 2020 9:15 AM in reply to HifiDSP

         Hello Kim and Dave,

         The IIR filter's b1 coefficient works out to about 2^(-35).  This is way too small to represent in any SigmaDSP, which are 5.23 or 8.24 fixed point (double-precision refers to the calculations, not the coefficients).  I'm not familiar with MATLAB but it likely runs floating point math.

         Dave's graphic is quite readable if you click or tap it, opening a magnified view.  As he said, the ADAU1452 is more suitable for calculations like these.  In addition to more headroom and resolution it features far better square root and divide algorithms.  The ADAU1452's superior divide algorithm also permits use of an implicit RMS calculation, which is more accurate than the stock RMS block.  The AD636 RMS to DC chip used this clever math back in the 70s and it's still around today.  For an example of implicit calculation in a SigmaDSP, see this thread.

         Best regards,

         Bob

  • Hi Dave,

    I think the challenge is to model the heating of the voice coil sufficiently accurate. The biquad (thermal model) does that but then there is the finite precision issue. One way to reduce this issue is by running the biquad at a much lower sample rate but I do not see how that is possible in SigmaStudio (at least using ADAU1442).

    From the begining I considered two options:
    1) To use the biquad to predict the temperature and apply limitation based on the temperature estimate. A straight forward solution until I discovered the finite precision issue.
    2) To use Sigma DSP standard RMS and peak limiters. I then need to find the combination of RMS and peak limiters and time constants needed to provide a fair match to the thermal model.

    Because of the biquad finite precision issue I am looking at option 2), using Sigma DSP RMS and peak limiters. I started out with rather conservative settings for an RMS and a peak limiter based on the spreadsheet from Park Audio.
    I see two challenges by using limiters:
    1) The thermal model (biquad) tracks the current temperature taking into account both the voice coil and magnet. If the voice coil temperature is already 100 degrees C, the driver will not be able to handle much power for a very long duration. If the voice coil and magnet are cold, the voice coil will be able to handle much power for a longer duration. It takes very long to heat up the magnet. This behavior might be difficult to imitate by using RMS and peak limiters.
    2) By looking at the thermal model curve I can see that the driver can handle 8W for 100 seconds without raising the voice coil temperature by more than 100 degrees. However, the driver can only handle 2.5W power long term. So I will need two RMS limiters with different thresholds and different time constants to roughly imitate this.

    No matter the solution used, I need to check that the temperature stays within desired limits. My previous post was about testing the solution by monitoring the estimated voice coil temperature as different stimuli are applied. I just thought it would be practical to monitor the temperature directly in SigmaStudio. However, I will use SPDIF out to transfer the output signal to my PC so that I can do the analysis in Matlab.

    For this project I am committed to using ADAU1442 but for future projects I will look into newer DSPs.
    I have looked at eval-ssm3525z but I cannot find much information about how I can use it and which DSPs support the speaker protection algorithms.
    It would be great if you could send me some more information about how to use eval-ssm3525z and how I can combine it with other evaluation boards.
    Like, do you have a complete kit? And how can I get V/I data out from the eval-ssm3525z board? Do your algorithms support nonlinear compensation or only speaker protection?

    /Kim

  • Hi Bob,

    It is a bit embarrassing but sometimes I forget that the ADAU1442 is using fixed point and that the coefficients are only 28 bit. Matlab uses double precision float.

    Can you think of any way getting around the problem?

    If I could run the filter producing the temperature estimate at a very low sample rate, I think it could work, as the coefficients become larger.

    Would it help anything to scale up the b coefficients and scale the biquad input signal down? It does not matter if the input power signal loses some precision.

    Or what happens if I scale up the b coefficients, do not scale the biquad input down but scale the biquad output signal down? Would there be internal wrap around or saturation in the biquad?

    /Kim

  • 0
    •  Analog Employees 
    on Aug 26, 2020 6:00 PM in reply to HifiDSP

    Hello Kim,

    I will get someone else involved that did work on our speaker protection product. 

    One other thing, the ADAU1452 and similar products has the ability of having threads that run at a lower sample rate so you certainly could run a filter at a lower rate in the new processors. 

    You are correct that accurate measurements of the coil and magnet temperature is a difficult problem to solve. 

    Dave T

Reply
  • 0
    •  Analog Employees 
    on Aug 26, 2020 6:00 PM in reply to HifiDSP

    Hello Kim,

    I will get someone else involved that did work on our speaker protection product. 

    One other thing, the ADAU1452 and similar products has the ability of having threads that run at a lower sample rate so you certainly could run a filter at a lower rate in the new processors. 

    You are correct that accurate measurements of the coil and magnet temperature is a difficult problem to solve. 

    Dave T

Children
  • 0
    •  Super User 
    on Aug 27, 2020 12:51 PM in reply to DaveThib

    Dave, it's really a great idea to get your speaker protection engineer / programmer involved.  And the -1452's ability to run a lower sample rate subsystem can sure come in handy.  Someday I'll have to experiment with running a NLMS adaptive filter at 8 KHz -- I could never get it to work to my satisfaction at 48K.

         Kim's frequency and time graphs above both show essentially a first-order response -- a 6 dB/octave slope and a "RC" curve respectively.  Also the description of coil and magnet heating suggests that we could model the heating with the sum of two first-order filters -- a slow filter for the magnet and a faster one for the coil.  To do this we would need their scale factors and corner frequencies, four parameters total.  If the research can provide these, we're in business.

         Could such filters work with 5.23 fixed point?  Well, yes -- we can use the scheme shown below, which only works with first-order LP filters of unity DC gain (the filter's two coefficients must sum to one):

    The sine oscillator and Value-Cross blocks produce a 48 pulse per second clock.  This gates the filter's input -- which otherwise sees its own output, freezing time.  Thus the filter runs at Fs = 48 Hz!

         I attempted to duplicate the time graph's general shape, with a rise time of about 1100 seconds.  Using the formula f = 0.35 / T, this works out to f = 0.000318 Hz.  The coefficients shown are for a unity gain first-order filter of this corner frequency at Fs = 48 Hz.  I'm using a General Second-Order Filter with first-order coefficients because the stock First-Order Filter is single precision.

         Running this on a ADAU1701 because it also uses 5.23 math, here's the output time response with the constant one input -- obtained by manually taking readings and entering them in a spreadsheet:

        And one more crazy idea -- if you can actually estimate the thermal rise within your SigmaDSP, why not adapt this signal to modulate a compressor's external input for speaker protection?

         All this is audio in the fast lane -- as far as I can tell, this device just works fine:

         Best regards,

         Bob

  • Thanks Bob. I really appreciate your help.

    About your idea - is it not what I am already trying to do in 1)? Use a model to predict the temperature and use a limiter to lower the gain if the desired max temperature is reached?

    I like vintage speakers. What speaker is it that is shown in the picture?

    I need to consider that the trick only works for 1st order filters where b0-a1 = 1 and b1 = 0.
    The analog transfer function of the thermal model is second order but b0A is zero and a2A is 1:
    H(s) = (0 + b1A*s + b2A*s^2] / (a0A + a1A*s + 1*s^2)
    After bilinear transformation none of the coefficients are zero.
    As the second order filter has real poles, I can split it into two first order filters (cascaded). Unfortunately, in these filter b1 ~= 0, so I cannot apply the trick.

    You suggested that I could use the sum of two 1st order filters. If I sum two first order filters of the form b0_1/(a0_1+a1_1*z^-1) where b1_1 = 0, I end up with a 2nd order filter of the form (b0+b1*z^-1)/(a0+a1*z^-1+a2*z^-2). In this 2nd order filter, b2 = 0, which is not the case with the 2nd order filter I am trying to split into 1st order filters. So it seems that it is not possible to replace the 2nd order filter by the sum of only two 1st order filters in this case.

    Using partial-fraction expansion, I might be getting somewhere. I get a transfer function of the form:
    b0_1/(a0_1+a1_1*z^-1) + b0_2/(a0_2+a1_2*z^-1) + K
    I.e. a combination of two 1st order filters having b1 = 0 plus a constant. In the time domain, the total output will be the sum of the output of the two 1st order filters plus the input scaled by K.
    I will try to get it to work.

    /Kim

  • 0
    •  Super User 
    on Sep 1, 2020 8:57 PM in reply to HifiDSP

         Hello Kim,

         The vintage radio is a Regal Autodyne five-tube design, c. 1946 -- similar to later AC/DC radios of the 60s except for its wooden case, huge IF transformers and octal tubes.  I found it on eBay.  Its seller had restored it (basically replacing all the capacitors) so it appears to work as well as can be expected.  It doesn't get many stations where I live.

         Sorry it was my understanding that you were undertaking the filter calculations to test your limiters and such, as opposed to closing the loop with the estimated temperature rise.  The two first-order filters I mentioned would run in parallel from the same input, only their results suitably scaled and added together to obtain the final temperature rise.  I'm afraid that the math of combining the filters goes over my head, so it's unlikely I could be of additional help.

         Best regards,

         Bob

  • Hi everyone,

    I guess this thread ended up quite different from the original subject. A great thanks for all of your replies.

    I discovered a serious bug in the ADAU1442 Parametric EQ graphical user interface. You can set the center frequency for a filter higher than fs/2, and then you might get an unstable filter.

    I can confirm that a parallel combination of filters+gain worked for me, like this:

    However, the sample rate has to be very low, 48 Hz is suitable, in order to provide accurate output. I.e. the power input signal must only contain frequencies lower than 24 Hz. The RMS envelope from Bobs example takes care of this. Care also has to be taken to scale the power input down, so it is not clipped at the Q5.23 upper limit of ~16 (if the input signal exceeds fullscale). The input has to be scaled so much down that the output temperature is also not clipped. It is a good idea to do lots of testing.

    Another problem with the thermal model approach is that the initial temperature when turning on the DSP is unknown because we do not have VI-sensing. If the DSP is turned off when voice coil is very hot and then on again immediately, then the protection does not work.

    Best regards,
    Kim