Created
May 20, 2025 12:34
-
-
Save ochilab/8508524913a3c9cbb6ef71e2951c1e5c to your computer and use it in GitHub Desktop.
Pythonでmidiデータを取得する
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
import mido | |
# 利用可能なMIDI入力ポートの一覧を表示 | |
print("利用可能なMIDI入力ポート:") | |
ports = mido.get_input_names() | |
for i, name in enumerate(ports): | |
print(f"{i}: {name}") | |
# # 適切なポート名に置き換えてください(例:"MIDI 1") | |
port_name = mido.get_input_names()[0] | |
# ポートを開いてMIDIメッセージを受信 | |
with mido.open_input(port_name) as inport: | |
print(f"{port_name} を開いて受信中... Ctrl+C で終了") | |
for msg in inport: | |
print(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment