Skip to content

Limiter

Added in v0.26.0

The Limiter, based on cylimiter , is a straightforward audio transform that applies dynamic range compression. It is capable of limiting the audio signal based on certain parameters. Additionally, please note that this transform introduces a slight delay in the signal, equivalent to a fraction of the attack time.

  • The threshold determines the audio level above which the limiter kicks in.
  • The attack time is how quickly the limiter kicks in once the audio signal starts exceeding the threshold.
  • The release time determines how quickly the limiter stops working after the signal drops below the threshold.

Input-output example

In this example we apply the limiter with a threshold that is 10 dB lower than the signal peak

Input-output waveforms and spectrograms

Input sound Transformed sound

Usage examples

from audiomentations import Limiter

transform = Limiter(
    min_threshold_db=-16.0,
    max_threshold_db=-6.0,
    threshold_mode="relative_to_signal_peak",
    p=1.0,
)

augmented_sound = transform(my_waveform_ndarray, sample_rate=16000)
from audiomentations import Limiter

transform = Limiter(
    min_threshold_db=-16.0,
    max_threshold_db=-6.0,
    threshold_mode="absolute",
    p=1.0,
)

augmented_sound = transform(my_waveform_ndarray, sample_rate=16000)

Limiter API

min_threshold_db: float • unit: Decibel
Default: -24.0. Minimum threshold
max_threshold_db: float • unit: Decibel
Default: -2.0. Maximum threshold
min_attack: float • unit: seconds
Default: 0.0005. Minimum attack time
max_attack: float • unit: seconds
Default: 0.025. Maximum attack time
min_release: float • unit: seconds
Default: 0.05. Minimum release time
max_release: float • unit: seconds
Default: 0.7. Maximum release time
threshold_mode: str • choices: "relative_to_signal_peak", "absolute"

Default: relative_to_signal_peak. Specifies the mode for determining the threshold.

  • "relative_to_signal_peak" means the threshold is relative to peak of the signal.
  • "absolute" means the threshold is relative to 0 dBFS, so it doesn't depend on the peak of the signal.
p: float • range: [0.0, 1.0]
Default: 0.5. The probability of applying this transform.