Post Go back to editing

Compressor input level appears to be displayed/calculated incorrectly

Thread Summary

The user encountered inconsistent input level readings on the compressor block (Dynamic Processors/Peak/Standard/Full Range/Standard Peak) in SigmaStudio, affecting compression calculations. The support engineer explained that the compressor's level meter is not an absolute reference and is influenced by the absolute value of the audio and time constants. A workaround involves using external meters for more accurate level monitoring. The issue is also related to the compressor's gain factor calculation, which can be adjusted using a sidechain input with a volume control for threshold changes.
AI Generated Content
Category: Software
Product Number: ADAU1452
Software Version: SS 4.6, 4.7

During some recent work, I have been using one of the compressor blocks (Dynamic Processors/Peak/Standard/Full Range/Standard Peak). I noticed the "IN" Level displayed on the level indicators appears to be inconsistent with the level detector block (Level Detectors/Level Detectors/Single Band/Single Level Detector w Numerical Display). I am worried that this means that the amount of compression is being incorrectly calculated.

To isolate the problem, I have created a minimum working example, which is both attached and screenshotted below.

The input that the compressor displays appears to be negative half the absolute value (in dB) of the louder of the two inputs. (Sorry, that's a poor explanation)

e.g. Input 1 is -63dB, Input 2 is -56dB, compressor displays -28dB. This is because  -28 = - abs(-56)/2.

I don't know if this is exactly what is happening within the compressor, but I do know that the compressor is the issue, as increasing the linear gain value to 2 in the external gain block, which should lead to a 6dB increase, increases the compressor input level by 3dB.

For reference the ADAU1452 is on the Analog Devices EVAL-ADAU1452 REV BZ board. I have used the analog inputs to the board to test this, but the problem also appears with the noise floor of the ADCs, so no audio is needed. The included image was taken with only the noise of the ADC passing through the DSP. I have tried the same project on the two latest version of SigmaStudio (4.6, 4.7), with the same results in both cases.

Have I made a mistake in my setup, or is this a problem with the compressor?

Thanks,

Alex  

Edit Notes

Edit: The image and file that I attached appear to have been removed, and I cannot seem to add them back.
[edited by: AlexHolt at 12:14 PM (GMT -4) on 20 Oct 2022]
Parents
  • Hello Alex,

    For the picture issue, you might want to try to either copy and paste the picture file or drag and drop it into the window. 

    The compressor meter is certainly not perfect and is there to give you an idea of what is going on and not be an absolute reference level. 

    The compressor code will take the audio and it takes the absolute value of the audio and then it uses time constants to allow the level to build slowly and release slowly to get the attack and release times. So the result is a level that is used to lookup the gain factor to apply to the audio. So any non-symmetrical signals will get properly measured.

    As far as the level meters in the compressor. A couple of years ago I did look into the code that drives the meters and there are some issues with how it is displayed. It is not the actual audio output. Again, these meters are just to give you an idea of what the levels are. 

    Try to put a meter on the input and one on the output of the compressor. This should give you a better idea of the level in and out. 

    I had put together this document a few years back. It does not exactly explain what you are asking about but it does show how the parameters all work.

    Can you put together a small project that shows the issue you are seeing? 

    Dave T

    PDF 

     

  •  Hello, I also use this module. The following three times can be calculated according to the formula you give. Now there is no formula for calculating the threshold and ratio. Is there a formula for this? Calculation formula of compressor and expander.

    void SigmaDSP::compressorPeak(uint16_t startMemoryAddress, compressor_t &compressor)
    {
      uint8_t i;
      uint8_t count;
    
      float curve[33];
      float x[33];
      float y[33];
      float delta = 0.00;
      float coeff = 0.00;
    
      float dbps = 0.00;
      float hold_par = 0.00;
      float decay_par = 0.00;
      float postgain_par = 0.00;
    
      linspace(-90, 6, 33, x);
    
      count = 0;
    
      coeff = 1/compressor.ratio;
      for(i = 0; i < 33; i++) // This algorithm creates the curve with 1 1 1 1 1 1 1 0.9 0.8 0.72 0.64 and so on coefficients
      {
        if(x[i] >= compressor.threshold)
        {
          count++;
          if(count == 1)
            delta = x[i]*coeff-x[i]*1;
          y[i] = (x[i] * coeff)-delta;
        }
        else
          y[i] = x[i] * 1;
      }
    
      for(i = 0; i < 33; i++)  // Coefficients of the curve calculation
        curve[i] = (pow(10, y[i]/20)) / (pow(10, x[i]/20));  // Coefficients are the ratio between the linearized values of vect. y and x
    
      // Create buffer to store converted data
      uint8_t storeData[5];
    
      // Parameter load into Sigma DSP
      for(i = 0; i < 33; i++)
      {
        floatToFixed(curve[i], storeData);
        safeload_writeRegister(startMemoryAddress++, storeData, false);
      }

    I now have this calculation formula, but it is wrong, because I use the compressor ratio and expander ratio. The calculated array and software are incorrect. How do I calculate this?

  • Hello liangseaqiang,

    There really is not a formula for calculating the threshold. It is simply the point at which the gain factors in the table change from "1" to some other number thereby changing the gain. It stems from the table values. Where the table changes gain factors will be the threshold point. SigmaStudio changes the threshold by changing ALL the gain factors in the table. I personally like to use the external sidechain type of compressors and simply put in a volume control into the sidechain input. Then by changing this volume control it changes the threshold. Only one value to write from your controller. Far simpler. It has the same effect. 

    Ratio is a bit more complicated. Now you have to take one point where the gain is being changed. Let us say for the sake of an example, that we put in a -10dB signal and it is above the threshold so the gain is being changed. Then you raise the input signal by a known amount and see how much higher the output goes from the earlier input level. Then you take the ratio of input change verses the change in output.  

    On a work bench when I am testing analog compressors, (Digital ones as well,) I will make the math easy. I will pick a point that is past the knee point of the threshold by a few dB. Around five is a good place. Then I note the level coming out of the compressor. Then I raise the input by 10dB. So if the output goes up by 5dB then it is 10/5= 2:1 ratio. If it only went up by 2dB then it is 10/2= 5:1 ratio. 

    I have actually never thought about how to calculate the points of the table based on ratio. The points on the curve are usually every 3dB in most of our compressors. So the gain factor of the next point will need to go down by the ratio. So for 3dB steps if you wanted a 2:1 ratio, you would divide the 3dB difference by 2, so the next point needs to be 3dB-1.5dB=1.5dB less gain in the gain factor. If you want a ratio of 10:1 then it would be 3dB difference between the points divided by 10 so 3dB-0.3dB= 2.7dB less gain in the gain factor for the next point. Each point will be defined by the previous with the increase of the ratio. 

    Example of a ratio of 10:1 with a table point every 3dB. Once you get past the knee point (the threshold) the gain factors will be like this: (I will start with the point that is 3dB down)

    Input level --> Gain Factor:

    0dB -->-3dB

    3dB --> -5.7dB

    6dB --> -8.4dB

    9dB --> -11.1dB

    12dB --> -13.8dB

    15dB --> -16.5dB

    Each point is 2.7dB more attenuation than the last point giving you a 10/1 ratio. 

    If we check this over a larger span we should come up with a ratio of 10:1. 

    From the 0dB input level to the 12dB input level. the input gain changed by 12dB

    The output gain changed from -3dB to -13.8dB which is a change of 10.8dB

    12dB - 10.8dB = 1.2dB difference in level from when the signal was 0dB in level.

    12/1.2 = 10:1 ratio. So it works!

    So I am not certain if this will help you. 

    In your code I do not see you working with gain factors or doing any conversions. There is probably a clever way of doing this. Others on the forum might chime in to help. 

    There are web sites that show how to calculate gain factors in case you need that. 

    It is a simple concept but the details get a little complicated. 

    Dave T

Reply
  • Hello liangseaqiang,

    There really is not a formula for calculating the threshold. It is simply the point at which the gain factors in the table change from "1" to some other number thereby changing the gain. It stems from the table values. Where the table changes gain factors will be the threshold point. SigmaStudio changes the threshold by changing ALL the gain factors in the table. I personally like to use the external sidechain type of compressors and simply put in a volume control into the sidechain input. Then by changing this volume control it changes the threshold. Only one value to write from your controller. Far simpler. It has the same effect. 

    Ratio is a bit more complicated. Now you have to take one point where the gain is being changed. Let us say for the sake of an example, that we put in a -10dB signal and it is above the threshold so the gain is being changed. Then you raise the input signal by a known amount and see how much higher the output goes from the earlier input level. Then you take the ratio of input change verses the change in output.  

    On a work bench when I am testing analog compressors, (Digital ones as well,) I will make the math easy. I will pick a point that is past the knee point of the threshold by a few dB. Around five is a good place. Then I note the level coming out of the compressor. Then I raise the input by 10dB. So if the output goes up by 5dB then it is 10/5= 2:1 ratio. If it only went up by 2dB then it is 10/2= 5:1 ratio. 

    I have actually never thought about how to calculate the points of the table based on ratio. The points on the curve are usually every 3dB in most of our compressors. So the gain factor of the next point will need to go down by the ratio. So for 3dB steps if you wanted a 2:1 ratio, you would divide the 3dB difference by 2, so the next point needs to be 3dB-1.5dB=1.5dB less gain in the gain factor. If you want a ratio of 10:1 then it would be 3dB difference between the points divided by 10 so 3dB-0.3dB= 2.7dB less gain in the gain factor for the next point. Each point will be defined by the previous with the increase of the ratio. 

    Example of a ratio of 10:1 with a table point every 3dB. Once you get past the knee point (the threshold) the gain factors will be like this: (I will start with the point that is 3dB down)

    Input level --> Gain Factor:

    0dB -->-3dB

    3dB --> -5.7dB

    6dB --> -8.4dB

    9dB --> -11.1dB

    12dB --> -13.8dB

    15dB --> -16.5dB

    Each point is 2.7dB more attenuation than the last point giving you a 10/1 ratio. 

    If we check this over a larger span we should come up with a ratio of 10:1. 

    From the 0dB input level to the 12dB input level. the input gain changed by 12dB

    The output gain changed from -3dB to -13.8dB which is a change of 10.8dB

    12dB - 10.8dB = 1.2dB difference in level from when the signal was 0dB in level.

    12/1.2 = 10:1 ratio. So it works!

    So I am not certain if this will help you. 

    In your code I do not see you working with gain factors or doing any conversions. There is probably a clever way of doing this. Others on the forum might chime in to help. 

    There are web sites that show how to calculate gain factors in case you need that. 

    It is a simple concept but the details get a little complicated. 

    Dave T

Children
  • Hello, now there is a new problem. It is normal when I only control the mute. When I control the mute, there will be noise when I read the mute register immediately. The speaker will beep. It is normal not to read the register. It is also normal to read other registers, but the correct value can be read normally.

    As shown in the figure above, there is no noise when reading.

    When I control the matrix, phase and frequency division, I use SAFELOAD to control, and there will be a noise beep when I control, but when I control the mute, there will be no noise when I use SAFELOAD for gain, and there will be noise when I do not use SAFELOAD. How can I solve these problems?

  • I forgot to say that when the first value of the reading register is 0XFF, it can only be read as 0XF. For example, the correct reading value of the reading phase register should be ff 80000, and the actual reading data is f 80000. So is there a problem reading there?

  • Hello, I'm trying to use an external compressor as you said, but it can't be implemented as you said. I don't know if it's a mistake or something. Using the module of 1, if it is checked whether the data is the same as the input dB value, or if the compressor value needs to be modified to change the compression ratio, it can only be used for activation. Using the DC module, the input value is also used as an activation. You cannot modify the value in the compressor to change the compression ratio. Then it is still necessary to calculate the value of 136 of 1701 or 216 of 1452 to change the compression ratio.

  • Hello Dave Thib,

    I don't understand how to use the external sidechain type of compressors. Is there a specific example?

    Thanks & Regards

    Gavin