def remove_offset(self): """ Convert the channel by removing the offset in the channel. """ newchannel = Channel() newchannel.sampwidth = self.sampwidth newchannel.framerate = self.framerate a = AudioFrames( self.channel.get_frames(self.channel.get_nframes()), self.channel.get_sampwidth(), 1) avg = a.avg() newchannel.set_frames( a.bias( - avg ) ) self.channel = newchannel
def bias(self, biasvalue): """ Convert the channel with a bias added to each frame. Samples wrap around in case of overflow. @param biasvalue (int) the value to bias the frames """ if biasvalue == 0: return newchannel = Channel() newchannel.sampwidth = self.sampwidth newchannel.framerate = self.framerate a = AudioFrames( self.channel.get_frames(self.channel.get_nframes()), self.channel.get_sampwidth(), 1) newchannel.set_frames( a.bias( biasvalue ) ) self.channel = newchannel