grafx.processors.delay

class MultitapDelay(segment_len=3000, num_segments=20, num_delay_per_segment=1, processor_channel='stereo', zp_filter_per_tap=True, zp_filter_bins=20, flashfftconv=True, max_input_len=131072, pre_delay=0, **surrogate_delay_kwargs)

Bases: Module

A stereo delay module comprising feed-forward delays, each with learnable delay length.

Simliar to the other LTI processors, we first compute the FIR of the processor and convolve it with the input. The multitap delay’s FIR is given as

\[ h[n] = \sum_{m=1}^{M} \underbrace{c_m[n]}_{\mathrm{optional}}*\delta[n-d_m] \]

where \(\delta[n]\) denotes a unit impulse and \(c_m[n]\) is an optional coloration filter. The delays lengths are optimized with the surrogate delay lines: see SurrogateDelay. Instead of allowing the delays to have the full range (from \(0\) to \(N-1\)), we can restrict them to have a smaller range and then concatenate them to form a multitap delay; see the arguments segment_len and num_segments below. This multitap delay’s learnable parameter is \(p = \{\mathbf{z}, \mathbf{H}\}\) where the latter is optional log-magnitude responses of the coloration filters.

Parameters:
  • segment_len (int, optional) – The length of the segment for each delay (default: 3000).

  • num_segments (int, optional) – The number of segments for each channel (default: 20).

  • num_delay_per_segment (int, optional) – The number of delay taps per segment (default: 1).

  • stereo (bool, optional) – Use two independent delays for left and right. (default: True).

  • zp_filter_per_tap (bool, optional) – Use a ZeroPhaseFIREqualizer for each tap (default: True).

  • zp_filter_bins (int, optional) – The number of bins for each equalizer (default: 20).

  • flashfftconv (bool, optional) – An option to use FlashFFTConv [FKNRe23] as a backend to perform the causal convolution efficiently (default: True).

  • max_input_len (int, optional) – When flashfftconv is set to True, the max input length must be also given (default: 2**17).

  • **surrgate_delay_kwargs (optional) – Additional arguments for the SurrogateDelay module.

forward(input_signals, delay_z, log_fir_magnitude=None)

Processes input audio with the processor and given parameters.

Parameters:
  • input_signals (FloatTensor, \(B \times 2 \times L\)) – A batch of input audio signals.

  • delay_z (FloatTensor, \(B \times M \times 2\)) – A log-magnitude vector of the FIR filter.

  • log_fir_magnitude (FloatTensor, \(B \times M \times P\), optional) – A log-magnitude vector of the FIR filter. Must be given when zp_filter_per_tap is set to True.

Returns:

A batch of output signals of shape \(B \times 2 \times L\).

Return type:

FloatTensor

parameter_size()
Returns:

A dictionary that contains each parameter tensor’s shape.

Return type:

Dict[str, Tuple[int, ...]]