Odin bindings for libremidi — クロスプラットフォーム MIDI ライブラリ (hot-plug / MIDI 1.0 / MIDI 2.0 UMP 対応)。
| OS | Backend | Status |
|---|---|---|
| macOS | CoreMIDI | ✅ |
| Linux | ALSA | 🚧 |
| Windows | WinMM | 🚧 |
- Odin
dev-2026-05+ - CMake 3.22+
- Xcode CLT (macOS)
git clone https://github.com/jcelerier/libremidi.git
make libremidi # → macos/libremidi.a (静的、推奨)
make libremidi-shared # → macos/libremidi.dylib (動的)make macos_version # version 表示
make macos_list_ports # ポート列挙
make macos_hotplug # hot-plug 監視
make macos_midi_in # MIDI 入力受信動的リンクは make LIBREMIDI_SHARED=true macos_hotplug。
自分のプロジェクトで使う場合は本リポジトリを vendor し、ビルド済みの macos/libremidi.a も同梱する。
import lr "vendor/odin-libremidi"最小の hot-plug receiver は example/hotplug.odin 参照。重要なポイント:
proc "c"コールバック内では先頭でcontext = g_ctxを必ず実行- macOS では CoreMIDI 通知のために
CFRunLoopRun()等で runloop を回す Port_Metadataは使い終わったらport_metadata_destroyで解放
export ODIN_C_BINDGEN=/path/to/odin-c-bindgen/bindgen
make regen-bindings出力 (bindgen/output/) を手動で libremidi.odin にマージする。
- CoreMIDI シンボル未解決:
makeかodin runを使うこと。odin build直叩きなら-extra-linker-flags:"-lc++ -framework CoreMIDI -framework CoreFoundation -framework CoreAudio"を付ける @rpath/libremidi.dylib読み込めない: 静的リンクを使うか-Wl,-rpath,@executable_path/../macosを追加- 入力ポートが見つからない: Audio MIDI Setup で IAC Driver を online にして確認
- hot-plug が発火しない: CFRunLoop を回していない
- odin-libremidi: (TBD)
- libremidi (同梱バイナリ): BSD-3-Clause —
macos/LIBREMIDI_LICENSE.md