Differentiable implementation of a chorus audio effect.
Implementation is based on:
This processor implements a modulated delay line to create the chorus effect,
generating multiple detuned copies of the input signal using LFO-controlled
delay modulation.
Parameters will be automatically mapped to their ranges
Ensure your network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
Examples
Basic DSP Usage:
>>> # Create a chorus effect>>> chorus=Chorus(... sample_rate=44100... )>>> # Process with musical settings>>> output=chorus(input_audio,dsp_params={... 'delay_ms':20.0,# 20ms base delay... 'rate':2.0,# 2 Hz modulation... 'depth':0.15,# Moderate intensity... 'mix':0.5# Equal mix... })
Neural Network Control:
>>> # Simple parameter prediction>>> classChorusController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> chorus=Chorus(sample_rate=44100)>>> num_params=chorus.count_num_parameters()# 4 parameters>>> controller=ChorusController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=chorus(input_audio,norm_params=norm_params)
A chorus effect that creates a shimmering, thickening sound by adding slightly detuned
and delayed copies of the original signal. This processor adds depth and width to the
original sound by simulating multiple slightly out-of-tune instruments playing together.
Register default parameters for the chorus effect.
Sets up:
delay_ms: Base delay time (5.0 to 40.0 ms)
rate: LFO modulation rate (0.1 to 10.0 Hz)
depth: Modulation intensity (0.0 to 0.25)
mix: Wet/dry balance (0.0 to 1.0)
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’mix’: Wet/dry balance (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify chorus 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.
Differentiable implementation of a multi-voice chorus effect with independent voice control.
Implementation is based on:
This processor implements a chorus effect with multiple independently controlled voices,
each featuring phase-shifted modulation and individual gain control. The implementation
uses multiple LFO-modulated delay lines with evenly distributed phase offsets to create
rich ensemble effects.
The transfer function for the multi-voice chorus is:
Ensure network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
Examples
Basic DSP Usage:
>>> # Create a 3-voice chorus>>> chorus=MultiVoiceChorus(... sample_rate=44100,... num_voices=3... )>>> # Process with musical settings>>> output=chorus(input_audio,dsp_params={... 'delay_ms':5.0,# Base delay... 'rate':1.5,# Modulation rate... 'depth':0.15,# Moderate detuning... 'mix':0.7,# Mostly wet... 'g0':1.0,# Full level voice 1... 'g1':0.8,# Reduced voice 2... 'g2':0.6# Quiet voice 3... })
Neural Network Control:
>>> # Simple parameter prediction>>> classMultiChorusController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> chorus=MultiVoiceChorus(sample_rate=44100,num_voices=3)>>> num_params=chorus.count_num_parameters()# 7 parameters (4 base + 3 gains)>>> controller=MultiChorusController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=chorus(input_audio,norm_params=norm_params)
An advanced chorus effect that generates multiple detuned and delayed voices from the
original signal. This effect provides more complex and rich spatial modulation compared
to traditional single-voice chorus effects, allowing for more intricate sound design
and spatial enhancement.
Register default parameters for the multi-voice chorus.
Sets up:
delay_ms: Base delay time (1.0 to 10.0 ms)
rate: LFO modulation rate (0.1 to 10.0 Hz)
depth: Modulation intensity (0.0 to 0.25)
mix: Wet/dry balance (0.0 to 1.0)
gi: Gain for each voice i (0.0 to 1.0)
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’mix’: Wet/dry balance (0 to 1)
’g0’ to ‘g{num_voices-1}’: Voice gains (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify chorus 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.
Differentiable implementation of a stereo chorus effect with configurable voices.
Implementation is based on:
This processor implements a stereo chorus effect with multiple independently controlled voices,
each featuring phase-shifted modulation, individual gain control, and stereo panning. The
implementation combines multi-voice modulated delays with constant-power stereo positioning
to create rich, spatially distributed chorus effects.
Processing Chain:
1. Generate phase-offset LFOs for each voice
2. Calculate individual voice delays
3. Apply stereo panning per voice
4. Mix delayed and panned voices
5. Combine with dry signal
where coefficients are functions of:
- N: Number of chorus voices
- g_i: Gain of voice i
- pan_i: Stereo position of voice i (-1 to 1)
- f_r: LFO rate in Hz
- depth: Modulation depth
- delay_base: Base delay time
Args:
sample_rate (int): Audio sample rate in Hz. Defaults to 44100.
num_voices (int): Number of chorus voices. Defaults to 2.
Attributes:
num_voices (int): Number of active chorus voices
sample_rate (int): Audio sample rate in Hz
Parameters Details:
delay_ms: Base delay time
Range: 1.0 to 10.0 ms
Controls center delay time
Shorter delays for tighter effect
rate: LFO modulation frequency
Range: 0.1 to 10.0 Hz
Controls modulation speed
Lower values for gentle chorusing
depth: Modulation intensity
Range: 0.0 to 0.25
Controls amount of detuning
Affects richness of chorus
mix: Wet/dry balance
Range: 0.0 to 1.0
0.0: Only clean signal
1.0: Only processed signal
For each voice i:
gi: Voice gain
Range: 0.0 to 1.0
Controls level of each voice
pani: Voice stereo position
Range: -1.0 to 1.0
-1.0: Full left
0.0: Center
1.0: Full right
Warning:
When using with neural networks:
norm_params must be in range [0, 1]
Parameters will be automatically mapped to ranges
Ensure network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
Total parameters = 4 + 2*num_voices (base params + gain/pan per voice)
Examples:
Basic DSP Usage:
>>> # Create a stereo chorus with 2 voices>>> chorus=StereoChorus(... sample_rate=44100,... num_voices=2... )>>> # Process with musical settings>>> output=chorus(input_audio,dsp_params={... 'delay_ms':5.0,# Base delay... 'rate':1.5,# Modulation rate... 'depth':0.15,# Moderate detuning... 'mix':0.7,# Mostly wet... 'g0':1.0,# Full voice 1... 'pan0':-0.7,# Voice 1 left... 'g1':0.8,# Reduced voice 2... 'pan1':0.7# Voice 2 right... })
Neural Network Control:
>>> # Simple parameter prediction>>> classStereoChorusController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> chorus=StereoChorus(sample_rate=44100,num_voices=2)>>> num_params=chorus.count_num_parameters()# 8 parameters (4 base + 2*2 voice params)>>> controller=StereoChorusController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=chorus(input_audio,norm_params=norm_params)
A stereo-specific chorus effect that creates a wide, immersive modulation by applying
independent chorus processing to left and right channels. This approach enhances the
stereo image and provides a more expansive sound stage compared to mono chorus effects.
Register default parameters for the stereo chorus.
Sets up:
delay_ms: Base delay time (1.0 to 10.0 ms)
rate: LFO modulation rate (0.1 to 10.0 Hz)
depth: Modulation intensity (0.0 to 0.25)
mix: Wet/dry balance (0.0 to 1.0)
For each voice i:
gi: Voice gain (0.0 to 1.0)
pani: Voice stereo position (-1.0 to 1.0)
x (torch.Tensor) – Input audio tensor. Shape: (batch, channels, samples)
Accepts both mono (channels=1) and stereo (channels=2) input.
Mono input will be automatically converted to stereo.
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’mix’: Wet/dry balance (0 to 1)
For each voice i:
f’g{i}’: Voice gain (0 to 1)
f’pan{i}’: Voice position (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify chorus 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.
Differentiable implementation of a flanger audio effect.
Implementation is based on:
This processor implements a modulated delay line to create the flanger effect,
using a low-frequency oscillator (LFO) to modulate a very short delay time.
The implementation creates the characteristic “swooshing” sound through
phase cancellation and reinforcement.
Ensure network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
Examples
Basic DSP Usage:
>>> # Create a flanger effect>>> flanger=Flanger(... sample_rate=44100... )>>> # Process with musical settings>>> output=flanger(input_audio,dsp_params={... 'delay_ms':5.0,# 5ms base delay... 'rate':0.5,# 0.5 Hz modulation... 'depth':0.7,# Strong sweep... 'mix':0.6# 60% wet... })
Neural Network Control:
>>> # Simple parameter prediction>>> classFlangerController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> flanger=Flanger(sample_rate=44100)>>> num_params=flanger.count_num_parameters()# 4 parameters>>> controller=FlangerController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=flanger(input_audio,norm_params=norm_params)
A classic modulation effect that creates a sweeping, metallic sound by mixing the
original signal with a slightly delayed, time-modulated copy of itself. The effect
produces a characteristic whooshing or airplane-like sound through controlled
signal delay and feedback.
Register default parameters for the flanger effect.
Sets up:
delay_ms: Base delay time (1.0 to 10.0 ms)
rate: LFO modulation rate (0.1 to 2.0 Hz)
depth: Modulation intensity (0.0 to 1.0)
mix: Wet/dry balance (0.0 to 1.0)
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’mix’: Wet/dry balance (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify flanger 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.
Differentiable implementation of a stereo flanger effect with quadrature LFOs.
Implementation is based on:
This processor implements a stereo flanger that uses quadrature (90° phase-shifted)
LFOs for the left and right channels, creating a wide stereo image through
independent modulation. The implementation provides smooth phase differences
between channels while maintaining the characteristic flanger sound.
Processing Chain:
1. Generate quadrature LFOs for stereo modulation
2. Calculate independent channel delays
3. Apply stereo variable delay
4. Mix with original signal
where coefficients are functions of:
- x_L, x_R: Left and right input signals
- f_r: LFO rate in Hz
- depth: Modulation depth
- delay_base: Base delay time
- mix: Wet/dry balance
Args:
sample_rate (int): Audio sample rate in Hz. Defaults to 44100.
Attributes:
sample_rate (int): Audio sample rate in Hz
Parameters Details:
delay_ms: Base delay time
Range: 1.0 to 10.0 ms
Controls center delay time
Very short delays for flanger effect
rate: LFO modulation frequency
Range: 0.1 to 2.0 Hz
Controls modulation speed
Lower values create slow stereo sweeps
depth: Modulation intensity
Range: 0.0 to 1.0
Controls stereo sweep width
Affects intensity of effect
mix: Wet/dry balance
Range: 0.0 to 1.0
0.0: Only clean signal
1.0: Only flanged signal
Note:
The processor supports the following features:
Quadrature LFOs for true stereo
Independent channel processing
Phase-coherent stereo field
Automatic buffer size handling
Efficient batch processing
Warning:
When using with neural networks:
norm_params must be in range [0, 1]
Parameters will be automatically mapped to ranges
Ensure network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
Input must be stereo (2 channels)
Examples:
Basic DSP Usage:
>>> # Create a stereo flanger>>> flanger=StereoFlanger(... sample_rate=44100... )>>> # Process with musical settings>>> output=flanger(input_audio,dsp_params={... 'delay_ms':5.0,# 5ms base delay... 'rate':0.5,# 0.5 Hz modulation... 'depth':0.7,# Strong sweep... 'mix':0.6# 60% wet... })
Neural Network Control:
>>> # Simple parameter prediction>>> classStereoFlangerController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> flanger=StereoFlanger(sample_rate=44100)>>> num_params=flanger.count_num_parameters()# 4 parameters>>> controller=StereoFlangerController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=flanger(input_audio,norm_params=norm_params)
A stereo implementation of the flanger effect that applies independent flanger
processing to left and right channels. This approach creates a more complex and
spatially interesting modulation effect compared to mono flanger implementations.
Register default parameters for the stereo flanger effect.
Sets up:
delay_ms: Base delay time (1.0 to 10.0 ms)
rate: LFO modulation rate (0.1 to 2.0 Hz)
depth: Modulation intensity (0.0 to 1.0)
mix: Wet/dry balance (0.0 to 1.0)
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’mix’: Wet/dry balance (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify flanger 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.
Differentiable implementation of a feedback flanger effect.
Implementation is based on:
This processor implements a flanger with feedback path, allowing the delayed signal
to be fed back into the input. The feedback creates resonant peaks in the frequency
response, resulting in a more pronounced and characteristically “metallic” flanger sound.
Processing Chain:
1. Generate LFO for delay modulation
2. Sum input with feedback signal
3. Apply modulated delay
4. Feed delayed signal back
5. Mix with original signal
where coefficients are functions of:
- x(t): Input signal
- f_r: LFO rate in Hz
- depth: Modulation depth
- delay_base: Base delay time
- fb: Feedback amount
- mix: Wet/dry balance
Args:
sample_rate (int): Audio sample rate in Hz. Defaults to 44100.
Attributes:
sample_rate (int): Audio sample rate in Hz
Parameters Details:
delay_ms: Base delay time
Range: 1.0 to 10.0 ms
Controls center delay time
Very short delays for flanger effect
rate: LFO modulation frequency
Range: 0.1 to 10.0 Hz
Controls modulation speed
Lower values create slow sweeps
depth: Modulation intensity
Range: 0.0 to 0.25
Controls sweep width
Affects intensity of effect
feedback: Feedback amount
Range: 0.0 to 0.7
Controls resonance intensity
Higher values create metallic sound
mix: Wet/dry balance
Range: 0.0 to 1.0
0.0: Only clean signal
1.0: Only flanged signal
Note:
The processor supports the following features:
Variable delay implementation
Feedback path processing
Resonant frequency peaks
Automatic stability control
Efficient batch processing
Warning:
When using with neural networks:
norm_params must be in range [0, 1]
Parameters will be automatically mapped to ranges
Ensure network output is properly normalized (e.g., using sigmoid)
Parameter order must match _register_default_parameters()
High feedback can create intense resonance
Examples:
Basic DSP Usage:
>>> # Create a feedback flanger>>> flanger=FeedbackFlanger(... sample_rate=44100... )>>> # Process with musical settings>>> output=flanger(input_audio,dsp_params={... 'delay_ms':5.0,# 5ms base delay... 'rate':0.5,# 0.5 Hz modulation... 'depth':0.15,# Moderate sweep... 'feedback':0.4,# Medium resonance... 'mix':0.6# 60% wet... })
Neural Network Control:
>>> # Simple parameter prediction>>> classFlangerController(nn.Module):... def__init__(self,input_size,num_params):... super().__init__()... self.net=nn.Sequential(... nn.Linear(input_size,32),... nn.ReLU(),... nn.Linear(32,num_params),... nn.Sigmoid()# Ensures output is in [0,1] range... )...... defforward(self,x):... returnself.net(x)>>>>>> # Initialize controller>>> flanger=FeedbackFlanger(sample_rate=44100)>>> num_params=flanger.count_num_parameters()# 5 parameters>>> controller=FlangerController(input_size=16,num_params=num_params)>>>>>> # Process with features>>> features=torch.randn(batch_size,16)# Audio features>>> norm_params=controller(features)>>> output=flanger(input_audio,norm_params=norm_params)
An extended flanger effect that incorporates feedback to create more pronounced
and resonant modulation. The feedback mechanism allows for more intense and
distinctive sweeping sounds, adding additional harmonic complexity to the
original signal.
Register default parameters for the feedback flanger effect.
Sets up:
delay_ms: Base delay time (1.0 to 10.0 ms)
rate: LFO modulation rate (0.1 to 10.0 Hz)
depth: Modulation intensity (0.0 to 0.25)
feedback: Feedback amount (0.0 to 0.7)
mix: Wet/dry balance (0.0 to 1.0)
Normalized parameters (0 to 1)
Must contain the following keys:
’delay_ms’: Base delay time (0 to 1)
’rate’: LFO frequency (0 to 1)
’depth’: Modulation intensity (0 to 1)
’feedback’: Feedback amount (0 to 1)
’mix’: Wet/dry balance (0 to 1)
Each value should be a tensor of shape (batch_size,)
dsp_params (Dict[str, Union[float, torch.Tensor]], optional) – Direct DSP parameters.
Can specify flanger 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.
Differentiable implementation of a high-order allpass phaser effect.
Implementation is based on:
This processor implements a sophisticated phaser effect using allpass filters
with time-varying coefficients, creating complex phase-shifting modulations
in the audio signal. The implementation provides precise control over the
phasing effect through multiple parameters.
The phaser effect works by creating phase shifts across different frequency
bands, resulting in a sweeping, swirling sound characteristic of classic
analog phasers. Unlike simple single-stage phasers, this implementation
uses a fourth-order allpass filter for richer, more complex modulations.
Mathematical Concept:
The core of the phaser is a time-varying allpass filter where the transfer
function is dynamically modified by a low-frequency oscillator (LFO). The
phase shift is controlled by the allpass coefficient p(t), which is derived
from the LFO and frequency range parameters.
Parameters:
sample_rate (int) – Audio sample rate in Hz. Defaults to 44100.
A phase-shifting modulation effect that creates a sweeping, swirling sound by
splitting the signal into multiple all-pass filtered paths and recombining them.
This results in a distinctive, swooping modulation that adds movement and depth
to the original sound.
Register default parameters for the phaser effect.
Sets up:
f0: LFO frequency (0.1 to 5.0 Hz)
f_min: Minimum cutoff frequency (100.0 to 2000.0 Hz)
f_max: Maximum cutoff frequency (2000.0 to 10000.0 Hz)
feedback: Feedback amount (0.0 to 0.9)
wet_mix: Wet/dry balance (0.0 to 1.0)