music.convert_to_stereo

music.convert_to_stereo(sound_vector)[source]

Converts a sound vector to stereo format.

Converts a mono or multi-channel sound vector into stereo format. If the input vector is mono, it duplicates the signal to both left and right channels. If the input vector has more than two channels, it keeps only the first two channels (left and right) and sums the rest to both left and right channels.

Parameters:
sound_vectorarray_like

The input sound vector to be converted to stereo format. Can be a one-dimensional array (mono) or a two-dimensional array (stereo or multi-channel).

Returns:
stereo_soundndarray

A two-dimensional numpy array representing the sound vector in stereo format. The first row corresponds to the left channel, and the second row corresponds to the right channel.

Parameters:

sound_vector (ArrayLike)

Return type:

NDArray[float64]

Examples

>>> mono_vector = np.array([0.1, 0.2, 0.3, 0.4])
>>> stereo_vector = convert_to_stereo(mono_vector)
>>> stereo_vector.shape
(2, 4)