Ejemplo n.º 1
0
    def convert(self):
        """
        Convert the channel to the expected sample width and frame rate.
        
        """
        newchannel = Channel()
        newchannel.set_frames( self.__convert_frames( self.channel.frames ) )
        newchannel.sampwidth = self.sampwidth
        newchannel.framerate = self.framerate

        self.channel = newchannel
Ejemplo n.º 2
0
 def remove_offset(self):
     """
     Remove the offset in the channel
     
     """
     newchannel = Channel()
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     avg = audioutils.avg(self.channel.frames, self.sampwidth)
     newchannel.set_frames(audioutils.bias(self.channel.frames, self.sampwidth, - avg))
     
     self.channel = newchannel
Ejemplo n.º 3
0
 def append_frames(self, frames):
     """
     Convert the channel by appending frames.
     
     @param frames (string) the frames to append
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames + frames )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel
Ejemplo n.º 4
0
 def add_frames(self, frames, position):
     """
     Convert the channel by adding frames.
     
     @param position (int) the position where the frames will be inserted
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames[:position*self.sampwidth] + frames + self.channel.frames[position*self.sampwidth:] )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel
Ejemplo n.º 5
0
 def mul(self, factor):
     """
     Multiply the frames by the factor
     
     @param bias (int) the factor to multiply the frames
     
     """
     newchannel = Channel()
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     newchannel.set_frames(audioutils.mul(self.channel.frames, self.sampwidth, factor))
     
     self.channel = newchannel
Ejemplo n.º 6
0
 def bias(self, bias):
     """
     Apply a bias on the frames
     
     @param bias (int) the value to bias the frames
     
     """
     newchannel = Channel()
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     newchannel.set_frames(audioutils.bias(self.channel.frames, self.sampwidth, bias))
     
     self.channel = newchannel
Ejemplo n.º 7
0
 def remove_frames(self, begin, end):
     """
     Convert the channel by removing frames.
     
     @param begin (int) the position of the beggining of the frames to remove
     @param end (int) the position of the end of the frames to remove
     
     """
     newchannel = Channel()
     newchannel.set_frames( self.channel.frames[:begin*self.sampwidth] + self.channel.frames[end*self.sampwidth:] )
     newchannel.sampwidth = self.sampwidth
     newchannel.framerate = self.framerate
     self.channel = newchannel