Skip to content

Broadcast MIDI unlearn to all clients - #9

Merged
sastraxi merged 2 commits into
mainfrom
fix/midi-unlearn-broadcast
Sep 1, 2026
Merged

sastraxi merged 2 commits into
mainfrom
fix/midi-unlearn-broadcast

Conversation

@sastraxi

@sastraxi sastraxi commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

MOD-UI does not tell the clients when a user removes a MIDI addressing. Only the browser that made the change shows the correct state. pi-Stomp keeps the binding on its LCD until the user selects a different pedalboard and comes back.

MOD-UI sends a message when a user adds a MIDI addressing. When mod-host reports midi_mapped, Host calls msg_callback("midi_map ...").

Cause

Host.address() removes an addressing in two places. Neither place sent a message to the clients.

  1. actuator_uri == "null". The user removed a complete addressing with the dialog. The code sets bypassCC and midiCCs to the empty values, but sends no message. Users get this path.
  2. actuator_uri == kMidiUnlearnURI. The learn is not complete, because the user did not move a control. html/js/hardware.js sends this URI only when currentAddressing.uri == kMidiLearnURI. The code sends midi_unmap to mod-host and returns. It keeps the addressing and the old CC values. MOD-UI then sends these incorrect values to the next client that connects.

Change

Send midi_map {instance} {symbol} -1 -1 0.0 1.0 from the two places. In the second place, also remove the addressing and set bypassCC and midiCCs to the empty values.

mod-host uses -1 -1 for a control with no MIDI mapping. The clients need no new message type.

Test

On pi-Stomp hardware:

  1. Learn a CC to the :bypass port of a plugin.
  2. Set the addressing to None.
  3. The LCD removes the binding immediately. The user does not load a pedalboard again.

sastraxi and others added 2 commits August 22, 2026 17:29
The kMidiUnlearnURI branch returned straight after sending midi_unmap to
mod-host: it never popped the addressing, never reset bypassCC/midiCCs,
and never broadcast. Only the browser that performed the unlearn knew the
mapping was gone; every other client (pi-stomp's LCD, a second browser)
kept showing it, and the stale pluginData was replayed to the next client
to connect.

Learn already broadcasts via the midi_mapped feedback path; unlearn now
matches it with a -1:-1 midi_map.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Setting a MIDI-addressed control back to "None" reaches address() as
actuator_uri="null", not kMidiUnlearnURI — the latter only fires while a
learn is still pending and uncommitted. That path cleared bypassCC /
midiCCs but never broadcast, so only the browser that made the change
knew the mapping was gone. pi-stomp kept the binding on its LCD until
the board was switched away and back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Didn't test, but looks good.

@rreichenbach rreichenbach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks good

@sastraxi
sastraxi merged commit d28bde9 into main Sep 1, 2026
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.

2 participants