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

# Envelope Detector Stages

Envelope detector Stages measure how the average or peak amplitude of a signal varies over time.

## EnvelopeDetectorPeak

class audio_dsp.stages.EnvelopeDetectorPeak(**kwargs)

  A stage with no outputs that measures the signal peak envelope.

  The current envelope of the signal can be read out using this stage’s `envelope` control.

  Attributes:
    dsp_block `audio_dsp.dsp.drc.drc.envelope_detector_peak`

      The DSP block class; see Peak Envelope Detector for implementation details.

  make_env_det_peak(attack_t, release_t, Q_sig=27)

    Update envelope detector configuration based on new parameters.

    Parameters:
      attack_t float

        Attack time of the envelope detector in seconds.

      release_t float

        Release time of the envelope detector in seconds.

  set_parameters(
    parameters: EnvelopeDetectorParameters,
  )

    Update the parameters of the EnvelopeDetectorPeak stage.

pydantic model audio_dsp.models.envelope_detector.EnvelopeDetectorParameters

  Parameters for an EnvelopeDetector Stage.

  field attack_t: float = 0.01

    Attack time of the stage in seconds.

    Constraints:

      - gt = 0

      - le = 1

  field release_t: float = 0.2

    Release time of the stage in seconds.

    Constraints:

      - gt = 0

      - le = 5

### EnvelopeDetectorPeak Control

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

Control parameter | Payload length
--- | ---
CMD_ENVELOPE_DETECTOR_PEAK_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_ENVELOPE_DETECTOR_PEAK_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_ENVELOPE_DETECTOR_PEAK_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. |

## EnvelopeDetectorRMS

class audio_dsp.stages.EnvelopeDetectorRMS(**kwargs)

  A stage with no outputs that measures the signal RMS envelope.

  The current envelope of the signal can be read out using this stage’s `envelope` control.

  Attributes:
    dsp_block `audio_dsp.dsp.drc.drc.envelope_detector_rms`

      The DSP block class; see RMS Envelope Detector for implementation details.

  make_env_det_rms(attack_t, release_t, Q_sig=27)

    Update envelope detector configuration based on new parameters.

    Parameters:
      attack_t float

        Attack time of the envelope detector in seconds.

      release_t float

        Release time of the envelope detector in seconds.

  set_parameters(
    parameters: EnvelopeDetectorParameters,
  )

    Update the parameters of the EnvelopeDetectorRMS stage.

pydantic model audio_dsp.models.envelope_detector.EnvelopeDetectorParameters

  Parameters for an EnvelopeDetector Stage.

  field attack_t: float = 0.01

    Attack time of the stage in seconds.

    Constraints:

      - gt = 0

      - le = 1

  field release_t: float = 0.2

    Release time of the stage in seconds.

    Constraints:

      - gt = 0

      - le = 5

### EnvelopeDetectorRMS Control

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

Control parameter | Payload length
--- | ---
CMD_ENVELOPE_DETECTOR_RMS_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_ENVELOPE_DETECTOR_RMS_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_ENVELOPE_DETECTOR_RMS_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. |