|
Revision 1, 1.1 kB
(checked in by anonymous, 1 year ago)
|
Imported old repos
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
#!/usr/bin/env python |
|---|
| 2 |
|
|---|
| 3 |
import os, sys |
|---|
| 4 |
BUILD_PATHS = [os.path.join(os.getcwd(), 'build/lib.linux-x86_64-2.4/'), |
|---|
| 5 |
os.path.join(os.getcwd(), 'build/lib.darwin-8.5.0-Power_Macintosh-2.3/'), |
|---|
| 6 |
] |
|---|
| 7 |
sys.path = BUILD_PATHS + sys.path |
|---|
| 8 |
import rtmidi |
|---|
| 9 |
import threading |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
class Collector(threading.Thread): |
|---|
| 13 |
def __init__(self, device, port): |
|---|
| 14 |
threading.Thread.__init__(self) |
|---|
| 15 |
self.setDaemon(True) |
|---|
| 16 |
self.port = port |
|---|
| 17 |
self.device = device |
|---|
| 18 |
self.quit = False |
|---|
| 19 |
|
|---|
| 20 |
def run(self): |
|---|
| 21 |
self.device.openPort(self.port) |
|---|
| 22 |
self.device.ignoreTypes(True, False, True) |
|---|
| 23 |
while True: |
|---|
| 24 |
if self.quit: |
|---|
| 25 |
return |
|---|
| 26 |
msg = self.device.getMessage() |
|---|
| 27 |
if msg: |
|---|
| 28 |
print 'PORT: %s, MESSAGE: %s' % (self.port, msg) |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
dev = rtmidi.RtMidiIn() |
|---|
| 32 |
collectors = [] |
|---|
| 33 |
for i in range(dev.getPortCount()): |
|---|
| 34 |
device = rtmidi.RtMidiIn() |
|---|
| 35 |
print 'OPENING',dev.getPortName(i) |
|---|
| 36 |
collector = Collector(device, i) |
|---|
| 37 |
collector.start() |
|---|
| 38 |
collectors.append(collector) |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
print 'HIT ENTER TO EXIT' |
|---|
| 42 |
sys.stdin.read(1) |
|---|
| 43 |
for c in collectors: |
|---|
| 44 |
c.quit = True |
|---|