Created
March 20, 2024 06:56
-
-
Save yingshaoxo/f3099197d0042071b2f19c10c62e6d06 to your computer and use it in GitHub Desktop.
linux usb midi driver 1.0 for python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: yingshaoxo | |
# Python: 3.5 | |
# midi usb protocol: 1.0 ; There has no need to upgrade to 2.0 | |
device_name = "/dev/midi1" # "/dev/dmmidi1" # "/dev/snd/midiC1D0" | |
while True: | |
with open(device_name, "rb") as f: | |
bytes_list = [None] * 3 | |
for index in range(3): | |
bytes_list[index] = f.read(1) | |
int_list = [int.from_bytes(one, "big") for one in bytes_list] | |
the_key = int_list[1] | |
the_strongth = int_list[2] | |
print(" strongth:", the_strongth) | |
if int_list[0] == 144: | |
print("pressed:", the_key) | |
else: | |
print("released:", the_key) | |
print("\n\n-------\n") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment