Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# Noise Suppressor Expander Stages

Noise suppressor and expander Stages control the behaviour of quiet signals, typically by tring to reduce the audibility of noise in the signal.

## NoiseSuppressorExpander

class audio_dsp.stages.NoiseSuppressorExpander(**kwargs)

  The Noise Suppressor (Expander) stage. A noise suppressor that reduces the level of an audio signal when it falls below a threshold. This is also known as an expander.

  When the signal envelope falls below the threshold, the gain applied to the signal is reduced relative to the expansion ratio over the release time. When the envelope returns above the threshold, the gain applied to the signal is increased to 1 over the attack time.

  The initial state of the noise suppressor is with the suppression off; this models a full scale signal having been present before t = 0.

  Attributes:
    dsp_block `audio_dsp.dsp.drc.expander.noise_suppressor_expander`

      The DSP block class; see Noise Suppressor/Expander for implementation details.

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

    Update noise suppressor (expander) configuration based on new parameters.

    All parameters are passed to the constructor of `audio_dsp.dsp.drc.noise_suppressor_expander`.

    Parameters:
      ratio float

        The expansion ratio applied to the signal when the envelope falls below the threshold.

      threshold_db float

        The threshold level in decibels below which the audio signal is attenuated.

      attack_t float

        Attack time of the noise suppressor in seconds.

      release_t float

        Release time of the noise suppressor in seconds.

  set_parameters(
    parameters: NoiseSuppressorExpanderParameters,
  )

    Update noise suppressor/expander configuration based on new parameters.

pydantic model audio_dsp.models.noise_suppressor_expander.NoiseSuppressorExpanderParameters

  Parameters for noise suppressor expander stage.

  field attack_t: float = 0.005

    Time in seconds for expander to start expanding

    Constraints:

      - gt = 0

      - le = 1

  field ratio: float = 3

    Expansion ratio applied when signal falls below threshold

    Constraints:

      - gt = 1

      - le = 100

  field release_t: float = 0.12

    Time in seconds for signal to return to original level

    Constraints:

      - gt = 0

      - le = 5

  field threshold_db: float = -35

    Level in dB below which expansion occurs

    Constraints:

      - ge = -162.55619765854985

      - le = 24.082399717833418

### NoiseSuppressorExpander Control

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

Control parameter | Payload length
--- | ---
CMD_NOISE_SUPPRESSOR_EXPANDER_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_NOISE_SUPPRESSOR_EXPANDER_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_NOISE_SUPPRESSOR_EXPANDER_ENVELOPE | `sizeof(int32_t)`
The current peak envelope of the signal in Q_SIG format. To read the `int32_t` control value, use the function `qxx_to_db()` in `control/helpers.h` with Q=Q_SIG. This command is read only. When sending a write control command, it will be ignored. |
CMD_NOISE_SUPPRESSOR_EXPANDER_THRESHOLD | `sizeof(int32_t)`
The threshold in Q_SIG format below which suppression will occur. To convert a threshold in dB to the `int32_t` control value, use the function `calculate_peak_threshold()` in `control/helpers.h`. |
CMD_NOISE_SUPPRESSOR_EXPANDER_GAIN | `sizeof(int32_t)`
The current gain applied by the noise suppressor 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_NOISE_SUPPRESSOR_EXPANDER_SLOPE | `sizeof(float)`
The expansion slope of the noise suppressor. This is calculated as (1 - ratio).To convert a ratio to a slope, use the function `peak_expander_slope_from_ratio()` in `control/helpers.h`. |