Skip to content

Add MIDI input - #281

Open
v10101a wants to merge 4 commits into
processing:mainfrom
v10101a:midi-input
Open

v10101a wants to merge 4 commits into
processing:mainfrom
v10101a:midi-input

Conversation

@v10101a

@v10101a v10101a commented Nov 17, 2026 •

Copy link
Copy Markdown

currently libprocessing could only send MIDI, though #74 describes sending and receiving. This PR exposes nannou_midi's existing input in libprocessing, following existing MIDI output code in processing_midi

  • add MIDI input to processing_midi: midi_list_input_ports(), midi_connect_input(), midi_disconnect_input(), midi_read()
  • add same functions to python. midi_read() returns MidiMessage objects with kind, channel, note/velocity, control/value.
  • midi_connect_input() takes a port number or part of a name (e.g. "IAC") and returns the port it connected to
  • add midi-related error messages

Fix: MIDI out on macOS

MIDI output was sent with timestamp 0. Simpler listeners that ignore timestamps still receive them, but notes don't show up in Ableton or Web MIDI visualizer when i tested on MacOS. This also affects the existing midi example.

  • I enabled midir's coremidi_send_timestamped feature (macOS only) in processing_midi/Cargo.toml, so each message is stamped with the current time. nannou_midi uses the same midir, so this applies to all MIDI output, in Rust and Python.

Example

Merged MIDI in and out into the existing midi example (examples/midi.rs and crates/processing_pyo3/examples/midi.py):

  • MIDI OUT: click to play a note, shown as a colorful ripple
  • MIDI IN: incoming notes show up as colorful bars, a control change (CC) brightens color of the bar
  • the connected port names are shown on screen and printed to the console

I tested on macOS only: IAC loopback, Ableton, a Web MIDI visualizer, and unit tests.

Disclosure: used claude to help with coding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@catilac
catilac self-requested a review November 17, 2026 23:43
@catilac

catilac commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

amazing! just kicked off automated tests for you, and will do some hand testing. but looks good!

@tychedelia tychedelia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind collapsing the new midi_input example into the midi example? Feel free to be as creative as you want here, we just want to show off both examples in a single example.

@github-actions

Copy link
Copy Markdown

Visual regression: 1 changed of 43 cases

case status detail
py_flocking_gpu ❌ changed 7.95% of pixels differ

If these changes are intentional, add the deliberate-rendering-change label.

baseline 56dc3f7d01 · adapter llvmpipe (LLVM 20.1.2, 256 bits) (Vulkan, Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2))

Open the visual report · workflow run

@v10101a

v10101a commented Nov 18, 2026

Copy link
Copy Markdown
Author

@tychedelia examples merged! While testing I also found that MIDI out (including the original midi example) wasn't reaching Ableton or Web MIDI tools on macOS, likely bc messages were sent with timestamp 0. Enabling midir's coremidi_send_timestamped feature fixed it. The change is in crates/processing_midi/Cargo.toml and only applies to macOS

@v10101a
v10101a requested a review from tychedelia November 18, 2026 21:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants