Search code examples
javascriptsignal-processingweb-audio-api

What does a dB represent in WebAudio's DynamicsCompressorNode


The DynamicsCompressorNode in WebAudio API allows control over attack and release speed in units of seconds per 10dB.

Does this dB represent the ratio between two arbitrary units used in the system, or does it represent the power ratio between two waveforms?


Solution

  • Decibels (dB) represent the ratio of two quantities on a logarithmic scale.

    In the specific case of the attack and release speed units of the DynamicsCompressorNode, it is used to represent the ratio of the DynamicsCompressorNode's gain at two moments.

    For example the default value of the release parameter is set to 0.25 seconds per 10dB. If we convert this 10dB into linear scale, we get 10^(10/20) or approximately 3.16. This then means that if the DynamicsCompressorNode's gain is initially set to 1, then 0.25 seconds later the gain could have increased to 3.16 (in response to a input signal with reduced power). Another 0.25 seconds later the gain could have changed to 3.16*3.16 = 10.

    Similarly, the default value of the attack parameter is set to 0.003 seconds per 10dB. This then means that if the DynamicsCompressorNode's gain is initially set to 1, then 0.003 seconds later the gain could have decreased to 1/3.16 (in response to a input signal with increased power). Another 0.003 seconds later the gain could have changed to (1/3.16)*(1/3.16) = 1/10 = 0.1.