-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmode.py
More file actions
47 lines (35 loc) · 1.09 KB
/
mode.py
File metadata and controls
47 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from sys import argv
from ports import *
# TODO: Use argparse
_prog = argv.pop(0)
if not len(argv):
print('Please chose a mode:')
print(' * "l"/"live"')
print(' * "p"/"programmer"')
print(' * L[int]')
print(' * P[int]')
exit(1)
def isint( s: str ):
try:
int(s)
return True
except:
return False
m = None
ma = argv.pop(0)
port = int(argv.pop(0) or '2') if len(argv) else MIDI_OUTPUT
from rtmidi import MidiOut
outp = MidiOut()
outp.open_port(port)
if ma == 'l' or ma == 'live':
outp.send_message([240, 0, 32, 41, 2, 13, 14, 0, 247])
outp.send_message([240, 0, 32, 41, 2, 13, 0, 4, 247])
elif ma == 'p' or ma == 'programmer':
outp.send_message([240, 0, 32, 41, 2, 13, 14, 1, 247])
outp.send_message([240, 0, 32, 41, 2, 13, 0, 127, 247])
elif len(ma) >= 2 and ma[0] == 'L' and isint(ma[1:]):
outp.send_message([240, 0, 32, 41, 2, 13, 0, int(ma[1:]), 247])
elif len(ma) >= 2 and ma[0] == 'P' and isint(ma[1:]):
outp.send_message([240, 0, 32, 41, 2, 13, 14, int(ma[1:]), 247])
else:
print('Invalid mode')