music.write_wav_stereo¶
- music.write_wav_stereo(sonic_vector=None, filename='asound.wav', sample_rate=None, fades_ms=0, bit_depth=16, remove_bias=True, normalize_separately=False, normalize=True, **renamed)[source]¶
Write a stereo sound to a WAV or FLAC file.
- Parameters:
- sonic_vectorarray_like, optional
The PCM samples to be written, of shape
(2, nsamples). A mono sound, or a single row, is written in both channels. Unlessnormalizeis False they are normalized by normalize_stereo(sonic_vector) to have samples between -1 and 1 and remove the offset. Defaults to about two seconds of uniform noise.- filename
str The path to write.
.wavand.flacare understood.- sample_ratescalar or
None The sample frequency. None, the default, is the rate
music.get_sample_rate()returns.- fades_msiterable or scalar
Milliseconds of fade in and fade out (to avoid clicks), either as a pair or as a single value applied to both ends.
- bit_depth
integer The number of bits in each sample of the final file: 8, 16, 24 or 32 for WAV, and 8, 16 or 24 for FLAC, which has no 32-bit form. Any other value raises ValueError.
- remove_biasbool
Whether to remove or not the bias (or offset). Part of normalizing, so it has no effect when
normalizeis False.- normalize_separatelybool
Set to True if each channel should be normalized separately. If False (default), the arrays will be rescaled in the same proportion. Part of normalizing, so it has no effect when
normalizeis False.- normalizebool
Normalize to full scale, as by default, or write the samples as they are. Normalizing makes every file peak at full scale, so a piece written a phrase to a file loses its dynamics; False keeps them, and refuses a sound reaching past [-1, 1].
- **renamed
fades, the namefades_mshad before it said its unit. Still accepted, with aDeprecationWarning.
- Raises:
ValueErrorIf the extension or bit depth is not one this package writes, the sound is empty or has more than two channels, or, with
normalize=False, it reaches past [-1, 1]; or iffades_msis neither one value nor two, or is negative. A mono sound was written in two channels when it was normalized and in one when it was not, and more channels were all written.
- Parameters:
- Return type:
None
See also
normalize_stereoNormalizes a stereo array to [-1,1]
write_wav_monoWrite a mono file.
convert_to_stereoFold more channels into two.
Examples
>>> placed = localize(note(freq=440, duration=0.5), theta=30, ... distance=1) >>> write_wav_stereo(placed, "placed.wav") >>> read_audio("placed.wav").shape[0] 2