Skip to content

emuscd, emusc-winmidi: --midi-in by index or name on both platforms - #20

Merged
mlainez merged 2 commits into
mainfrom
emuscd-midi-in-by-name
Oct 19, 2026
Merged

mlainez merged 2 commits into
mainfrom
emuscd-midi-in-by-name

Conversation

@mlainez

@mlainez mlainez commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Addresses the MIDI-in part of #18.

Both daemons now take --midi-in with the same argument and the same matching, as scva-headless does:

  • A number is an index from --list-midi-in. Out of range reports out of range (0..N).
  • Otherwise a port whose whole name matches is chosen first, then the single port whose name contains the text.
  • Matching ignores case, and runs of whitespace count as one space. MIDI Yoke's names are In From MIDI Yoke: 1, with two spaces.
  • A partial name that more than one port contains is an error that lists the candidates, instead of silently taking the first.

What it selects differs by platform:

  • emusc-winmidi (Windows): WinMM cannot create a port, so --midi-in chooses which existing input to open. It used to take an index only.
  • emuscd (Linux, new): emuscd still creates its own ALSA sequencer port (--name) for programs to connect to. --midi-in additionally subscribes it at startup to an existing source, such as a USB keyboard, instead of needing an aconnect after every start. Sources are every readable sequencer port except the system client's and emuscd's own, named <client>: <port>. --list-midi-in lists them.

The matching is a platform-free header (emuscd/midi_port_match.h) with a unit test, midi_port_match_test.

Verified locally

  • Unit test: passes natively and as the 32-bit MinGW .exe under Wine. Five mutations of the matcher (no exact-match pass, ambiguity ignored, case kept, whitespace dropped, numbers searched as names) each make it fail.

  • Test ports: both platforms were tested against two ALSA ports named exactly like MIDI Yoke's. Only port 2 sends notes: a held 24-note chord.

  • Windows (emusc-winmidi.exe under Wine, which exposes ALSA ports as WinMM inputs):

    • "MIDI Yoke" is rejected as ambiguous, with both ports listed. Maple matches nothing. 9 reports out of range (0..2).
    • With --midi-in "MIDI YOKE: 2", synthesis load went from 1.7% to 14–18% while the chord was held. With --midi-in "yoke: 1" it stayed at 1.6–1.8%.
    • Both 32- and 64-bit .exes still import only KERNEL32, msvcrt and WINMM.
  • Linux (emuscd, audio captured through ALSA's file PCM):

    • --list-midi-in lists Midi Through and both Yoke ports. The ambiguous, unknown and out-of-range cases give the same errors as on Windows, exiting 1.
    --midi-in aconnect -l captured audio
    "MIDI YOKE: 2" connected from 128:1 peak 11404
    "yoke: 1" connected from 128:0 silence (peak 0)
    "yoke: 1", plus a song played into emuscd's own port connected from 128:0 peak 5545 (own port still works)

🤖 Generated with Claude Code

A number is still an index. Anything else picks the port whose name it is,
or the only one containing it, ignoring case and runs of whitespace.

Assisted-by: Claude:claude-opus-5-5
Same matching as emusc-winmidi's --midi-in. emuscd still creates its own
port; this subscribes it to a source such as a USB keyboard at startup,
which otherwise takes an aconnect after every start.

Assisted-by: Claude:claude-opus-5-5
@mlainez mlainez changed the title emusc-winmidi: accept a port name for --midi-in emuscd, emusc-winmidi: --midi-in by index or name on both platforms Oct 19, 2026
@mlainez
mlainez merged commit 8a5b6c0 into main Oct 19, 2026
16 checks passed
@mlainez
mlainez deleted the emuscd-midi-in-by-name branch October 19, 2026 13:24
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.

1 participant