Exemplo n.º 1
0
Arquivo: vxcmidi.py Projeto: cwyss/vxc
 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
Exemplo n.º 2
0
Arquivo: wxtest.py Projeto: cwyss/vxc
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()
Exemplo n.º 3
0
Arquivo: vxcmidi.py Projeto: cwyss/vxc
    def stop(self):
        if self.threadid:
            self.threadid = 0
            self.terminated = False

            # next midi msg makes virus produce some midi msgs, 
            # causing threadfunc
            # to return from pyrawmidi.read() and terminate
            try:
                pyrawmidi.write([0xf0,0,0x20,0x33,0x01,0x10,0x73,0,0,0,0xf7])
            except IOError:
                pass

            # wait for thread to terminate
            for i in range(8):
                if self.terminated:
                    break
                time.sleep(.1)

        pyrawmidi.close()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
 def closemidi(self, midithread):
     sys.stdout.write("terminating midi thread...")
     sys.stdout.flush()
     midithread.stop()
     sys.stdout.write("\n")
     pyrawmidi.close()