Differentiable feedforward dynamic range compressor.
This processor implements a feedforward compressor with configurable knee curves and envelope following methods.
The compressor uses level detection, smoothing, and gain computation stages to reduce dynamic range.
Implementation is based on the following papers:
Processing Chain:
Level Detection: RMS energy → dB
Envelope Following: Attack/release smoothing
Gain Computation: Apply compression curve
Gain Application: Convert to linear gain and apply
The compressor implements the following gain computation:
Hard Knee:
\[\begin{split}g(x) = \begin{cases}
0, & \text{if } x \leq T \\
(T + \frac{x - T}{R}) - x, & \text{if } x > T
\end{cases}\end{split}\]
Quadratic Knee:
\[\begin{split}g(x) = \begin{cases}
0, & \text{if } x \leq T - W/2 \\
(\frac{1}{R} - 1)\frac{(x - T + W/2)^2}{4W}, & \text{if } T - W/2 < x \leq T + W/2 \\
(T + \frac{x - T}{R}) - x, & \text{if } x > T + W/2
\end{cases}\end{split}\]
x (torch.Tensor) – Input audio tensor. Shape: (batch, channels, samples)
norm_params (Dict[str, torch.Tensor]) – Normalized parameters (0 to 1)
Dictionary with keys:
- ‘threshold_db’: Level at which compression begins (-60 to 0 dB)
- ‘ratio’: Amount of gain reduction above threshold (1 to 20)
- ‘knee_db’: Width of transition region around threshold (0 to 12 dB)
- ‘attack_ms’: Time to react to level increases (0.1 to 100 ms)
- ‘release_ms’: Time to react to level decreases (10 to 1000 ms)
- ‘makeup_db’: Gain applied after compression (-12 to 12 dB)
Each value should be a tensor of shape (batch_size,)
Values will be mapped to their respective ranges
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify parameters as:
- float/int: Single value applied to entire batch
- 0D tensor: Single value applied to entire batch
- 1D tensor: Batch of values matching input batch size
Parameters will be automatically expanded to match batch size
and moved to input device if necessary.
If provided, norm_params must be None.
The gain computation depends on the knee_type:
- “hard”: Sharp transition at threshold
- “quadratic”: Smooth quadratic transition around threshold
- “exponential”: Continuous transition using softplus
Differentiable multi-band dynamic range compressor.
This processor splits the input signal into multiple frequency bands using
Linkwitz-Riley crossover filters and applies independent compression to each band.
The processed bands are then summed to produce the final output.
Implementation is based on the following references:
Processing Chain:
Band Splitting: Split input into frequency bands using Linkwitz-Riley filters
Per-band Processing:
Level Detection: Compute RMS energy and convert to dB
Envelope Following: Smooth level using attack/release ballistics
Gain Computation: Apply compression curve based on knee type
Gain Application: Convert to linear gain and apply to band
Band Summation: Sum all processed bands to create final output
Processing steps:
1. Compute RMS level in dB
2. Apply envelope following using attack/release
3. Compute gain using knee characteristic
4. Apply gain and makeup
Process input signal through the multi-band compressor.
Parameters:
x (torch.Tensor) – Input audio tensor. Shape: (batch, channels, samples)
norm_params (Dict[str, torch.Tensor]) – Normalized parameters (0 to 1)
Dictionary with keys for each band i (0 to num_bands-1):
- f’band{i}_threshold_db’: Level at which compression begins (-60 to 0 dB)
- f’band{i}_ratio’: Amount of gain reduction above threshold (1 to 20)
- f’band{i}_knee_db’: Width of transition region around threshold (0 to 12 dB)
- f’band{i}_attack_ms’: Time to react to level increases (1 to 500 ms)
- f’band{i}_release_ms’: Time to react to level decreases (10 to 2000 ms)
- f’band{i}_makeup_db’: Gain applied after compression (-24 to 24 dB)
And crossover frequencies between bands:
- f’crossover{i}_freq’: Split frequency between bands i and i+1
Each value should be a tensor of shape (batch_size,)
Values will be mapped to their respective ranges
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify parameters as:
- float/int: Single value applied to entire batch
- 0D tensor: Single value applied to entire batch
- 1D tensor: Batch of values matching input batch size
Parameters will be automatically expanded to match batch size
and moved to input device if necessary.
If provided, norm_params must be None.
A specialized compressor with high ratio and fast attack time to prevent audio signals from exceeding a specified threshold.
Parameters:
sample_rate (int) – Audio sample rate in Hz. Defaults to 44100.
param_range (Dict[str, EffectParam]) – Parameter ranges for the limiter.
threshold_db – Level at which limiting begins (-60 to 0 dB)
ratio – Amount of gain reduction above threshold (20 to 100)
knee_db – Width of the transition region (0 to 1 dB)
attack_ms – Time taken to react to increases in level (0.1 to 1.0 ms)
release_ms – Time taken to react to decreases in level (5 to 500 ms)
makeup_db – Gain applied after limiting (-24 to 24 dB)
Note
Uses hard-knee characteristic for precise limiting
Employs extremely fast attack times (< 1ms)
Uses very high ratios (>20:1) for “brick wall” limiting
Has very narrow knee width for sharp transitions
Optimized for peak control rather than dynamic range control
Warning
When using with neural networks:
- norm_params must be in range [0, 1]
- Parameters will be automatically mapped to their DSP ranges
- Parameter ranges are more extreme than standard compression
- Ensure network output dimension matches total parameters
- Parameter order must match _register_default_parameters()
A specialized compressor configured for limiting with fast attack times and high ratios.
Differentiable multi-band peak limiter with frequency-dependent threshold control.
A specialized limiter that splits the input signal into multiple frequency bands and applies limiting independently to each band.
Parameters:
sample_rate (int) – Audio sample rate in Hz. Defaults to 44100.
num_bands (int) – Number of frequency bands. Defaults to 4.
param_range (Dict[str, EffectParam]) – Parameter ranges for the limiter.
crossover_freqs – Crossover frequencies between bands in Hz
- Shape: (num_bands-1,)
- Range: 20 to 20000 Hz
threshold_db – Level at which limiting begins for each band
- Shape: (num_bands,)
- Range: -60 to 0 dB
ratio – Amount of gain reduction above threshold for each band
- Shape: (num_bands,)
- Range: 20 to 100
knee_db – Width of the transition region for each band
- Shape: (num_bands,)
- Range: 0 to 1 dB
attack_ms – Time taken to react to increases in level for each band
- Shape: (num_bands,)
- Range: 0.1 to 1.0 ms
release_ms – Time taken to react to decreases in level for each band
- Shape: (num_bands,)
- Range: 5 to 500 ms
makeup_db – Gain applied after limiting for each band
- Shape: (num_bands,)
- Range: -12 to 12 dB
Note
Uses hard-knee characteristic for precise limiting
Employs extremely fast attack times (< 1ms)
Uses very high ratios (>20:1) for “brick wall” limiting
Has very narrow knee width for sharp transitions
Optimized for peak control rather than dynamic range control
Each band can be controlled independently
Warning
When using with neural networks:
- norm_params must be in range [0, 1]
- Parameters will be automatically mapped to their DSP ranges
- Parameter ranges are more extreme than standard compression
- Ensure network output dimension matches total parameters
- Parameter order must match _register_default_parameters()
A multi-band limiter that applies independent limiting to different frequency bands.
Differentiable expander based on compressor implementation.
An expander increases the dynamic range of the signal by reducing the level
of signals that fall below the threshold. The amount of reduction is determined
by the ratio parameter.
A feedforward expander with three knee types (hard, quadratic, exponential)
and two smoothing options (ballistics, IIR).
x (torch.Tensor) – Input audio tensor. Shape: (batch, channels, samples)
norm_params (Dict[str, torch.Tensor]) – Normalized parameters (0 to 1)
Dictionary with keys:
- ‘threshold_db’: Level at which compression begins (-60 to 0 dB)
- ‘ratio’: Amount of gain reduction above threshold (1 to 20)
- ‘knee_db’: Width of transition region around threshold (0 to 12 dB)
- ‘attack_ms’: Time to react to level increases (0.1 to 100 ms)
- ‘release_ms’: Time to react to level decreases (10 to 1000 ms)
- ‘makeup_db’: Gain applied after compression (-12 to 12 dB)
Each value should be a tensor of shape (batch_size,)
Values will be mapped to their respective ranges
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify parameters as:
- float/int: Single value applied to entire batch
- 0D tensor: Single value applied to entire batch
- 1D tensor: Batch of values matching input batch size
Parameters will be automatically expanded to match batch size
and moved to input device if necessary.
If provided, norm_params must be None.
This processor implements a feedforward noise gate with configurable knee curves and envelope following methods.
The noise gate reduces the level of signals that fall below the threshold, effectively removing background noise
and unwanted low-level signals.
Implementation is based on the following papers:
Processing Chain:
Level Detection: RMS energy → dB
Envelope Following: Attack/release smoothing
Gain Computation: Apply gating curve
Gain Application: Convert to linear gain and apply
The noise gate implements the following gain computation:
Hard Knee:
\[\begin{split}g(x) = \begin{cases}
R, & \text{if } x \leq T \\
0, & \text{if } x > T
\end{cases}\end{split}\]
Variables:
x: input level in dB
T: threshold in dB
R: range in dB (negative value)
W: knee width in dB
Parameters:
sample_rate (int) – Audio sample rate in Hz. Defaults to 44100.
x (torch.Tensor) – Input audio tensor. Shape: (batch, channels, samples)
norm_params (Dict[str, torch.Tensor]) – Normalized parameters (0 to 1)
Dictionary with keys:
- ‘threshold_db’: Level at which compression begins (-60 to 0 dB)
- ‘ratio’: Amount of gain reduction above threshold (1 to 20)
- ‘knee_db’: Width of transition region around threshold (0 to 12 dB)
- ‘attack_ms’: Time to react to level increases (0.1 to 100 ms)
- ‘release_ms’: Time to react to level decreases (10 to 1000 ms)
- ‘makeup_db’: Gain applied after compression (-12 to 12 dB)
Each value should be a tensor of shape (batch_size,)
Values will be mapped to their respective ranges
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify parameters as:
- float/int: Single value applied to entire batch
- 0D tensor: Single value applied to entire batch
- 1D tensor: Batch of values matching input batch size
Parameters will be automatically expanded to match batch size
and moved to input device if necessary.
If provided, norm_params must be None.
This processor splits the input signal into multiple frequency bands using
Linkwitz-Riley crossover filters and applies independent noise gating to each band.
The processed bands are then summed to produce the final output.
Implementation is based on the following references:
Processing Chain:
Band Splitting: Split input into frequency bands using Linkwitz-Riley filters
Per-band Processing:
Level Detection: Compute RMS energy and convert to dB
Envelope Following: Smooth level using attack/release ballistics
Gain Computation: Apply gating curve based on knee type
Gain Application: Convert to linear gain and apply to band
Band Summation: Sum all processed bands to create final output