Compressor Sidechain Stages

Sidechain compressor Stages use the envelope of one input to control the level of a different input.

CompressorSidechain

class audio_dsp.stages.CompressorSidechain(**kwargs)

An sidechain compressor based on the RMS envelope of the detect signal.

This stage is limited to accepting 2 channels. The first is the channel that will be compressed. The second is the detect channel. The level of compression depends on the envelope of the second channel.

When the RMS envelope of the detect signal exceeds the threshold, the processed signal amplitude is reduced by the compression ratio.

The threshold sets the value above which compression occurs. The ratio sets how much the signal is compressed. A ratio of 1 results in no compression, while a ratio of infinity results in the same behaviour as a limiter. The attack time sets how fast the compressor starts compressing. The release time sets how long the signal takes to ramp up to its original level after the envelope is below the threshold.

Attributes:
dsp_blockaudio_dsp.dsp.drc.sidechain.compressor_rms_sidechain_mono

The DSP block class; see Sidechain RMS Compressor for implementation details.

make_compressor_sidechain(
ratio,
threshold_db,
attack_t,
release_t,
Q_sig=27,
)

Update compressor configuration based on new parameters.

Parameters:
ratiofloat

The compression ratio applied to the signal when the envelope exceeds the threshold.

threshold_dbfloat

The threshold level in decibels above which the audio signal is compressed.

attack_tfloat

Attack time of the compressor in seconds.

release_tfloat

Release time of the compressor in seconds.

set_parameters(
parameters: CompressorSidechainParameters,
)

Update the parameters of the CompressorSidechain stage.

pydantic model audio_dsp.models.compressor_sidechain.CompressorSidechainParameters

Parameters for sidechain compressor stage.

field attack_t: float = 0.01

Time in seconds for compressor to start compressing

Constraints:
  • gt = 0

  • le = 1

field ratio: float = 4.0

Compression ratio applied when detect signal exceeds threshold

Constraints:
  • gt = 1

  • le = 100

field release_t: float = 0.2

Time in seconds for signal to return to original level

Constraints:
  • gt = 0

  • le = 5

field threshold_db: float = 0.0

Level in dB above which compression occurs

Constraints:
  • ge = -81.27809882927492

  • le = 12.041199858916709

CompressorSidechain Control

The following runtime command ids are available for the CompressorSidechain Stage. For details on reading and writing these commands, see the Run-Time Control User Guide.

Control parameter

Payload length

CMD_COMPRESSOR_SIDECHAIN_ATTACK_ALPHA

sizeof(int32_t)

The attack alpha in Q0.31 format. To convert an attack time in seconds to an int32_t control value, use the function calc_alpha() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_RELEASE_ALPHA

sizeof(int32_t)

The release alpha in Q0.31 format. To convert a release time in seconds to an int32_t control value, use the function calc_alpha() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_ENVELOPE

sizeof(int32_t)

The current RMS² envelope of the signal in Q_SIG format. To read the int32_t control value, use the function qxx_to_db_pow() in control/helpers.h with Q=Q_SIG. This command is read only. When sending a write control command, it will be ignored.


CMD_COMPRESSOR_SIDECHAIN_THRESHOLD

sizeof(int32_t)

The threshold in Q_SIG format above which compression will occur. To convert a threshold in dB to the int32_t control value, use the function calculate_rms_threshold() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_GAIN

sizeof(int32_t)

The current gain applied by the compressor in Q0.31 format. To read the int32_t control value, use the function qxx_to_db() in control/helpers.h with Q=31. This command is read only. When sending a write control command, it will be ignored.


CMD_COMPRESSOR_SIDECHAIN_SLOPE

sizeof(float)

The compression slope of the compressor. This is calculated as (1 - 1 / ratio) / 2.0. To convert a ratio to a slope, use the function rms_compressor_slope_from_ratio() in control/helpers.h.

CompressorSidechainStereo

class audio_dsp.stages.CompressorSidechainStereo(**kwargs)

An stereo sidechain compressor based on the RMS envelope of the detect signal.

This stage is limited to accepting 4 channels. The first pair are the channels that will be compressed. The second pair are the detect channels. The level of compression depends on the maximum envelope of the detect channels.

When the maximum RMS envelope of the detect signal exceeds the threshold, the processed signal amplitudes are reduced by the compression ratio.

The threshold sets the value above which compression occurs. The ratio sets how much the signals are compressed. A ratio of 1 results in no compression, while a ratio of infinity results in the same behaviour as a limiter. The attack time sets how fast the compressor starts compressing. The release time sets how long the signal takes to ramp up to its original level after the envelope is below the threshold.

Attributes:
dsp_blockaudio_dsp.dsp.drc.sidechain.compressor_rms_sidechain_stereo

The DSP block class; see Stereo Sidechain RMS Compressor for implementation details.

make_compressor_sidechain(
ratio,
threshold_db,
attack_t,
release_t,
Q_sig=27,
)

Update compressor configuration based on new parameters.

Parameters:
ratiofloat

The compression ratio applied to the signal when the envelope exceeds the threshold.

threshold_dbfloat

The threshold level in decibels above which the audio signal is compressed.

attack_tfloat

Attack time of the compressor in seconds.

release_tfloat

Release time of the compressor in seconds.

set_parameters(
parameters: CompressorSidechainParameters,
)

Update the parameters of the CompressorSidechainStereo stage.

pydantic model audio_dsp.models.compressor_sidechain.CompressorSidechainParameters

Parameters for sidechain compressor stage.

field attack_t: float = 0.01

Time in seconds for compressor to start compressing

Constraints:
  • gt = 0

  • le = 1

field ratio: float = 4.0

Compression ratio applied when detect signal exceeds threshold

Constraints:
  • gt = 1

  • le = 100

field release_t: float = 0.2

Time in seconds for signal to return to original level

Constraints:
  • gt = 0

  • le = 5

field threshold_db: float = 0.0

Level in dB above which compression occurs

Constraints:
  • ge = -81.27809882927492

  • le = 12.041199858916709

CompressorSidechainStereo Control

The following runtime command ids are available for the CompressorSidechainStereo Stage. For details on reading and writing these commands, see the Run-Time Control User Guide.

Control parameter

Payload length

CMD_COMPRESSOR_SIDECHAIN_STEREO_ATTACK_ALPHA

sizeof(int32_t)

The attack alpha in Q0.31 format. To convert an attack time in seconds to an int32_t control value, use the function calc_alpha() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_STEREO_RELEASE_ALPHA

sizeof(int32_t)

The release alpha in Q0.31 format. To convert a release time in seconds to an int32_t control value, use the function calc_alpha() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_STEREO_ENVELOPE

sizeof(int32_t)

The current RMS² envelope of the signal in Q_SIG format. To read the int32_t control value, use the function qxx_to_db_pow() in control/helpers.h with Q=Q_SIG. This command is read only. When sending a write control command, it will be ignored.


CMD_COMPRESSOR_SIDECHAIN_STEREO_THRESHOLD

sizeof(int32_t)

The threshold in Q_SIG format above which compression will occur. To convert a threshold in dB to the int32_t control value, use the function calculate_rms_threshold() in control/helpers.h.


CMD_COMPRESSOR_SIDECHAIN_STEREO_GAIN

sizeof(int32_t)

The current gain applied by the compressor in Q0.31 format. To read the int32_t control value, use the function qxx_to_db() in control/helpers.h with Q=31. This command is read only. When sending a write control command, it will be ignored.


CMD_COMPRESSOR_SIDECHAIN_STEREO_SLOPE

sizeof(float)

The compression slope of the compressor. This is calculated as (1 - 1 / ratio) / 2.0. To convert a ratio to a slope, use the function rms_compressor_slope_from_ratio() in control/helpers.h.