def stereo(self, left_factor=1.0, right_factor=1.0):
"""
Turn a mono sample into a stereo one with given factors/amplitudes for left and right channels.
Note that it is a fast but simplistic conversion; the waveform in both channels is identical
so you may suffer from phase cancellation when playing the resulting stereo sample.
If the sample is already stereo, the left/right channel separation is changed instead.
"""
assert not self.__locked
if self.__nchannels == 2:
# first split the left and right channels and then remix them
right = self.copy().right()
self.left().amplify(left_factor)
return self.stereo_mix(right, 'R', right_factor)
if self.__nchannels == 1:
self.__frames = audioop.tostereo(self.__frames, self.__samplewidth, left_factor, right_factor)
self.__nchannels = 2
return self
raise ValueError("sample must be mono or stereo already")
评论列表
文章目录