-
Notifications
You must be signed in to change notification settings - Fork 51
/
23.ex-midi-monitor.py
executable file
·33 lines (27 loc) · 950 Bytes
/
23.ex-midi-monitor.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
#!/usr/bin/env python3
#------------------------------------------------------------------------
# Prints all received MIDI messages to the console.
# Demonstrates the use of callbacks to generate events when MIDI
# messages are received.
#------------------------------------------------------------------------
from isobar import *
import logging
import time
def main():
def print_message(message):
"""
The callback argument is a mido Message object:
https://mido.readthedocs.io/en/latest/messages.html
"""
print(" - Received MIDI: %s" % message)
midi_in = MidiInputDevice()
midi_in.callback = print_message
print("Opened MIDI input: %s" % midi_in.device_name)
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
pass
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")
main()