librosax.to_stereo

to_stereo(*, left: Array | None, right: Array | None, downmix: bool = True, pad: bool = True, norm: bool = True) Array[source]

Combine two signals into a stereo signal.

Parameters:
  • left – Left channel signal with shape (..., n), or None for silence.

  • right – Right channel signal with shape (..., m), or None for silence.

  • downmix – If True (default), each side is downmixed to mono before being placed in its output row. If False, the inputs must already be mono or stereo and are combined additively.

  • pad – If True (default), the shorter channel is zero-padded to match the longer one. If False, the longer one is trimmed.

  • norm – If True (default), signals are combined by averaging. If False, they are combined by summing.

Returns:

Stereo signal with shape (2, n_out), left channel first.

Raises:

librosax.util.exceptions.ParameterError – If both left and right are None, or if a channel has an unsupported shape when downmix is False.

See also

to_mono, to_multi, fix_length

Examples

>>> y1 = librosax.tone(440.0, sr=22050, duration=1.0)
>>> y2 = librosax.tone(550.0, sr=22050, duration=1.0)
>>> y_stereo = librosax.to_stereo(left=y1, right=y2)

Upmix a mono signal into the left channel only

>>> y_left = librosax.to_stereo(left=y1, right=None)