def speed(self, speed):
"""
Changes the playback speed of the sample, without changing the sample rate.
This will change the pitch and duration of the sound accordingly.
The algorithm used is simple, and it will cause a loss of sound quality.
"""
assert not self.__locked
assert speed > 0
if speed == 1.0:
return self
rate = self.samplerate
self.__frames = audioop.ratecv(self.__frames, self.samplewidth, self.nchannels, int(self.samplerate*speed), rate, None)[0]
self.__samplerate = rate
return self
评论列表
文章目录