def start(self, devname="hw:1,0,1", filter=0): try: pyrawmidi.open(devname) pyrawmidi.setfilter(filter, 0) self.threadid = thread.start_new_thread(self.threadfunc, ()) except (IOError, MemoryError): pyrawmidi.close() raise
def runmain(): pyrawmidi.close() pyrawmidi.open("hw:1,0,1") pyrawmidi.setfilter(0,0) app = wx.PySimpleApp() frame = MainFrame() midiinthread = MidiInThread(frame) app.MainLoop() sys.stdout.write("terminating midi thread...") sys.stdout.flush() midiinthread.stop() sys.stdout.write("\n") pyrawmidi.close()
import pyrawmidi, thread def printcmd(cmd): for b in cmd: print "%02X " % b, print def midiinthread(): while 1: cmd = pyrawmidi.read() printcmd(cmd) pyrawmidi.open("hw:1,0,1") thread.start_new_thread(midiinthread, ()) while 1: s = raw_input() if s == "q": break elif s.startswith("f"): f = s.split() pyrawmidi.setfilter(int(f[1]), int(f[2])) pyrawmidi.close() pyrawmidi.wait() pyrawmidi.wait()
def openmidi(self): pyrawmidi.open("hw:1,0,1") pyrawmidi.setfilter(0,0) return MidiInThread()