def sendScore(self, midFile): numTracks = midFile.numTracks() timeScale = midFile.timeDivision # / 250. t0 = midFile.track(0) timeScale = (t0.bpm / 60.) * timeScale for i in range(numTracks): track = midFile.track(i) for e in track.events: #print "e.offset=", e.offset start = e.offset / timeScale if e.type == 0x09 and e.vel > 0: # note on #print "note on", e.note self.noteOn(start, e.channel, e.note, e.vel) elif e.type == 0x08 or (e.type == 0x09 and e.vel == 0): # note off #print "note off", e.note self.noteOff(start, e.channel, e.note, e.vel) elif e.type == 0x0c: # program change self.setProgramForChannel(start, e.program, e.channel)