Exemplo n.º 1
0
class ViziMidiFile(object):
    def AddNote(self, e):
        print e
        
    def __init__(self, infile):
        self.my_tracks = []  #read from file
        self.my_midiMap = [] # matches MidiSndObj.note_event() with NoteEvents  
        self.next_time = 0.0
        self.tempo = 120.0     
        self.tick_counter = 0
        self.each_time = (60.0 / self.tempo) / 96.0
        self.m = MidiFile()
        self.m.open(infile)
        self.m.read()
        self.m.close()
            
    def __repr__(self):
        return `self.__dict__`
    
    def Print(self):
        print self.m

    def Restart(self, restart_tick = 0):
        for my_track in self.my_tracks:
            my_track.Restart(restart_tick)
        self.tick_counter = restart_tick
        self.next_time = restart_tick * self.each_time
        
    def DoProcess(self, this_time): # increments the tick counter when the time is right
        if self.next_time >= this_time:
            return True
        else:
            ret_value = 0
            self.next_time += self.each_time
            self.tick_counter += 1
            for this_track in self.my_tracks:
                ret_value += this_track.DoProcess(self.tick_counter)
            return ret_value