-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.py
executable file
·53 lines (40 loc) · 1.22 KB
/
test.py
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
48
49
50
51
52
53
#!/usr/bin/python3 -i
# Handy utility to debug the bridge at the python command prompt.
# Bridge must be run in virtual-port mode.
# hirsch@z87:~$ aconnect -o
# client 14: 'Midi Through' [type=kernel]
# 0 'Midi Through Port-0'
# client 130: 'RtMidiIn Client' [type=user]
# 0 'VIRT_PORT '
#
# Given the above, open RtMidi as: 'RtMidi Input Client 128:0'
import sys
import mido
from time import sleep
mido.set_backend('mido.backends.rtmidi')
# Edit this as appropriate for your environment
virtual_port = 'RtMidiIn Client:VIRT_PORT 130:0'
def send( msg ):
with mido.open_output(virtual_port) as outport:
outport.send( msg )
outport.close()
def capture( prog ):
with mido.open_output(virtual_port) as outport:
cc.control = 3
cc.value = 127
for i in range( 3 ):
outport.send( cc )
sleep( 0.2 )
pc.program = prog
outport.send( pc )
outport.close()
pc = mido.Message('program_change')
cc = mido.Message('control_change')
sx = mido.Message('sysex')
pc.channel = 1
cc.channel = 1
# pc.program = #
# cc.control = 50
# cc.value = 64
# Set the various attributes at the python prompt and
# call send() - passing message object.