def loadFile(self): # stop currently playing songs stopAll(self) # show dialog box self.options = {} self.options["filetypes"] = [("MIDI files", ".mid")] midiFilename = askopenfilename(parent=c.ROOT, title="Choose a MIDI file", **self.options) # ensure a file has been loaded if midiFilename != "": # ensure file is midi pattern = compile("\.midi?$", IGNORECASE) find = search(pattern, midiFilename) if find != None: # read midi file success = readMidiFile(self, midiFilename) if success: c.MIDI_FILENAME = midiFilename c.MIDI_FILENAME_SHORT = c.MIDI_FILENAME.split("/")[-1] # print "\nMidi " + str(c.MIDI_FILENAME_SHORT) + " read successfully." # get settings createSettingsInterface() else: self.showError("ERROR: " + c.MIDI_FILENAME + " is not a MIDI file.") return False return
def playPause(self): initSuccess = initializePlayAlong(self, c.DRUM_TRACK, int(c.TEMPO), c.MIDI_FILE.resolution) if initSuccess: isPlaying = stopOrPlay(self) if isPlaying == True: self.btnPlay["text"] = "Stop " + str(c.MIDI_FILENAME_SHORT) isComplete = playAlong(self, c.DRUM_TRACK) if isComplete: stopAll(self) self.btnPlay["text"] = "Restart " + str(c.MIDI_FILENAME_SHORT) else: self.btnPlay["text"] = "Play " + str(c.MIDI_FILENAME_SHORT) else: self.btnPlay["text"] = "Play " + str(c.MIDI_FILENAME_SHORT) return