def amplify_max(self):
"""Amplify the sample to maximum volume without clipping or overflow happening."""
assert not self.__locked
max_amp = audioop.max(self.__frames, self.samplewidth)
max_target = 2 ** (8 * self.samplewidth - 1) - 2
if max_amp > 0:
factor = max_target/max_amp
self.__frames = audioop.mul(self.__frames, self.samplewidth, factor)
return self
评论列表
文章目录