grafx.processors.stereo

class StereoGain

Bases: Module

A simple stereo-to-stereo or mono-to-stereo gain.

We use simple channel-wise constant multiplication with a gain vector. The gain is assumed to be in log scale, so we apply exponentiation before multiplying it to the stereo signal.

\[ y[n] = \exp (g_{\mathrm{log}}) \cdot u[n]. \]

Hence, the learnable parameter is \(p = \{ g_{\mathrm{log}} \}.\)

forward(input_signals, log_gain)

Processes input audio with the processor and given parameters.

Parameters:
  • input_signals (FloatTensor, \(B \times C \times L\)) – A batch of input audio signals, either mono or stereo.

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

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, ...]]

class SideGainImager

Bases: Module

Stereo imager with side-channel loudness control.

We multiply the input’s side signal \(u_{\mathrm{s}}[n]\), i.e., left \(u_{\mathrm{l}}[n]\) minus right \(u_{\mathrm{r}}[n]\), with a gain parameter \(g \in \mathbb{R}\) to control the stereo width. The mid and side outputs are given as

\[\begin{split} y_{\mathrm{m}}[n] &= u_{\mathrm{l}}[n] + u_{\mathrm{r}}[n], \\ y_{\mathrm{s}}[n] &= \exp (g) \cdot (u_{\mathrm{l}}[n] - u_{\mathrm{r}}[n]). \end{split}\]

Hence, the learnable parameter is \(p = \{ g_{\mathrm{log}} \}.\)

forward(input_signals, log_gain)

Processes input audio with the processor and given parameters.

Parameters:
  • input_signals (FloatTensor, \(B \times C \times L\)) – A batch of input audio signals; must be stereo.

  • log_magnitude (FloatTensor, \(B \times P \:\!\)) – A log-magnitude vector of the FIR filter.

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, ...]]

class MonoToStereo

Bases: Module

A simple mono-to-stereo conversion.

forward(input_signals)

Processes input audio with the processor and given parameters.

Parameters:

input_signals (FloatTensor, \(B \times 1 \times L\)) – A batch of input audio signals; must be mono.

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, ...]]

class StereoToMidSide(normalize=True)

Bases: Module

A simple stereo-to-mid-side conversion.

forward(input_signals)

Processes input audio with the processor and given parameters.

Parameters:

input_signals (FloatTensor, \(B \times 2 \times L\)) – A batch of input audio signals; must be stereo.

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, ...]]

class MidSideToStereo(normalize=True)

Bases: Module

A simple mid-side-to-stereo conversion.

forward(mid, side)

Processes input audio with the processor and given parameters.

Parameters:
  • mid (FloatTensor, \(B \times 1 \times L\)) – A batch of mid audio signals.

  • side (FloatTensor, \(B \times 1 \times L\)) – A batch of side audio signals.

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, ...]]