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), orNonefor silence.right – Right channel signal with shape
(..., m), orNonefor silence.downmix – If
True(default), each side is downmixed to mono before being placed in its output row. IfFalse, 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. IfFalse, the longer one is trimmed.norm – If
True(default), signals are combined by averaging. IfFalse, they are combined by summing.
- Returns:
Stereo signal with shape
(2, n_out), left channel first.- Raises:
librosax.util.exceptions.ParameterError – If both
leftandrightareNone, or if a channel has an unsupported shape whendownmixisFalse.
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)