#NEWLINE# def frames( self , frameSize , windowFunction = None ) : #NEWLINE# #INDENT# '\n        Decompose this frame into smaller frames of size frameSize\n        ' #NEWLINE# frames = [ ] #NEWLINE# start = 0 #NEWLINE# end = frameSize #NEWLINE# while ( start < len ( self ) ) : #NEWLINE# #INDENT# if ( windowFunction == None ) : #NEWLINE# #INDENT# frames . append ( self [ start : end ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# window = windowFunction ( frameSize ) #NEWLINE# window . shape = ( frameSize , 1 ) #NEWLINE# window = numpy . squeeze ( window ) #NEWLINE# frame = self [ start : end ] #NEWLINE# if ( len ( frame ) < len ( window ) ) : #NEWLINE# #INDENT# frameType = frame . __class__ . __name__ #NEWLINE# sampleRate = frame . sampleRate #NEWLINE# channels = frame . channels #NEWLINE# format = frame . format #NEWLINE# diff = ( len ( window ) - len ( frame ) ) #NEWLINE# frame = numpy . append ( frame , ( [ 0 ] * diff ) ) #NEWLINE# if ( frameType == 'AudioFile' ) : #NEWLINE# #INDENT# frame = frame . view ( pymir . AudioFile ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# frame = frame . view ( Frame ) #NEWLINE# #UNINDENT# frame . sampleRate = sampleRate #NEWLINE# frame . channels = channels #NEWLINE# frame . format = format #NEWLINE# #UNINDENT# windowedFrame = ( frame * sampleRate ) #NEWLINE# frames . append ( windowedFrame ) #NEWLINE# #UNINDENT# start = ( start + frameSize ) #NEWLINE# end = ( end + frameSize ) #NEWLINE# #UNINDENT# return frames