Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created May 20, 2025 12:34
Show Gist options
  • Save ochilab/8508524913a3c9cbb6ef71e2951c1e5c to your computer and use it in GitHub Desktop.
Save ochilab/8508524913a3c9cbb6ef71e2951c1e5c to your computer and use it in GitHub Desktop.
Pythonでmidiデータを取得する
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