Skip to content

emuscd, emusc-winmidi: --reset gs|gm locks every device in GS or GM - #21

Merged
mlainez merged 6 commits into
mainfrom
emuscd-gm-lock
Oct 19, 2026
Merged

mlainez merged 6 commits into
mainfrom
emuscd-gm-lock

Conversation

@mlainez

@mlainez mlainez commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Addresses the GM-only part of #18.

--reset gs or --reset gm on emuscd and emusc-winmidi keeps every device in that mode for as long as the daemon runs, whatever SysEx it is sent, and across device switches. A device without the requested mode is kept in the other one. Without --reset, behaviour is unchanged: devices start in GS and the MIDI stream may switch them.

Each device load prints a notice:

device --reset gs --reset gm
sc55 stays in GS no GM mode → GS selected, stays in GS
sc55mkii stays in GS stays in GM
jv880 neither GS nor GM → its own default mode same
sc88 stays in GS no GM mode → GS selected, stays in GS
jv1080 no GS mode → GM selected, stays in GM stays in GM

For example: emuscd: no GM mode available on sc55, so GS was selected as the default; it stays in GS mode while emuscd runs, whatever SysEx it is sent

Library

  • Synth::has_gs_mode() / has_gm_mode() answer from the device profiles, so the daemons never name a device:
    • GS: the GP profile's gsScaleTuningOnly, or the XP profile's SysEx model ID being GS's 42H.
    • GM: the conditions Settings::set_gm_mode() already checked, or the XP device having a GM System On.
  • Synth::set_mode_lock(None|GS|GM):
    • Locked in GS: a GM System On resets the device into GS.
    • Locked in GM: on the SC-55mkII, GM mode is GS with Rx.BankSelect and Rx.NRPN off. Both switches are put back after every Roland DT1, so neither a GS Reset nor a DT1 to them leaves GM. A GS Reset still resets everything else.
    • The XP engine has no SysEx path from one of its modes to the other, so only the GP engine reads the lock.
  • SC-88 GM mode: the real SC-88 has one, but this emulator does not model it, so under --reset gm the SC-88 is reported as having none.

Verified locally

  • Mode-lock test: new synth_mode_lock_test (skips without ROMs, like the other ROM tests), run with real ROMs for all five devices, natively and as the 32-bit MinGW .exe under Wine.

    • On the SC-55mkII, each locked case is first run unlocked. A GM System On, a GS Reset and a Rx.BankSelect DT1 each switch the mode, observed as whether CC0 8 + PC 0 lands on bank 8. Locked, none of them does. A reset under either lock still resets a part level written before it. Unlocking hands the mode back to the stream.
    • has_gs_mode() and has_gm_mode() match the table above on all five devices.
    • Seven mutations (each lock mechanism removed, each query forced either way) each make it fail.
  • End to end: emuscd driven over ALSA by two songs. One sends a GS Reset plus a Rx.BankSelect-on DT1, the other a GM System On. Both then send CC0 8 + PC 80 (bank 0 Square Wave, bank 8 Sine Wave). The audio was captured through ALSA's file PCM and classified by 3rd-harmonic energy:

    run song switches to captured tone
    no --reset GS sine (stream in control)
    no --reset GM square (stream in control)
    --reset gs GM sine (stayed GS)
    --reset gm GS square (stayed GM)
    --reset gm, then sc55, then sc55mkii on stdin GS square, with the right notice at each load
  • Notices: the notice is right for all 5 devices × gs/gm/none on emuscd, and for the JV-880 and JV-1080 in both modes on emusc-winmidi under Wine. --reset xg is rejected with exit 1. emusc-winmidi.exe still imports only KERNEL32, msvcrt and WINMM.

  • Unrelated, pre-existing: with the SC-88 ROMs present, synth_reset_test's SC-88 case fails on origin/main as well (restored > silenced * 100.0). CI runs without ROMs, so it is skipped there. This PR does not change it.

SC-88 GM mode (a740e6c, 7788745)

The SC-88 now has a real GM mode, so --reset gm enters GM on it instead of falling back to GS.

  • Firmware (traced): GM System On (7E 7F 09 01, device ID 7F only) runs the GS Reset's module reset. It then turns Rx.Bank Select off (part +18 bit 0) where GS Reset turns Rx.NRPN on (+2 bit 15).
  • Part switches: each part now has Rx.Bank Select, Rx.Bank Select LSB and Rx.NRPN switches. They gate CC0, CC32 and the NRPN numbers, and are writable at 40 1x 23/24/0a.
  • Profile field: a new field, XpDeviceProfile::firmwarePortGmMode, says which devices have the mode, and device_has_gm_mode() reads it.
  • Mode lock on the XP engine: the lock now holds there as well. Locked in GS, a GM System On does a GS Reset. Locked in GM, Rx.Bank Select and Rx.NRPN are turned off again after every SysEx.
  • Tests: synth_mode_lock_test gains an SC-88 case, and there is a new emuscd/tests/power_on_test. With the SC-88 and JV-1080 ROMs supplied, ctest runs 33 tests: 30 pass, 2 skip, and only the pre-existing synth_reset_test failure remains. JV-1080 and GP-engine output is byte-identical.
  • Not modelled: MODE-2 resets one module on the hardware but every part here. System Mode Set's effect on Rx.NRPN is not established, so it is left as it was.

🤖 Generated with Claude Code

The lock keeps a device in GM mode whatever SysEx it is sent, for hosts
that offer a GM-only mode.

Assisted-by: Claude:claude-opus-5-5
gm powers every device that has a GM mode on in it and locks it there for
as long as the daemon runs, across device switches; a device without one
runs in GS.

Assisted-by: Claude:claude-opus-5-5
Locked in GS, a GM System On resets the device into GS. Without --reset the
stream keeps control of the mode. A device without the mode asked for is
locked in the other one, and a device with neither runs in its own default;
each case prints a notice. has_gs_mode() joins has_gm_mode() so the daemons
can tell which lock a device can take.

Assisted-by: Claude:claude-opus-5-5
@mlainez mlainez changed the title emuscd, emusc-winmidi: add --reset gs|gm (GM-only mode) emuscd, emusc-winmidi: --reset gs|gm locks every device in GS or GM Oct 19, 2026
@mlainez

mlainez commented Oct 19, 2026

Copy link
Copy Markdown
Owner Author

Note that sc88 doesn't have it's GM mode completed yet, this is still a gap in the sc88 support in emuscd.

# Conflicts:
#	README.md
#	emuscd/README.md
#	emuscd/main.cc
#	emuscd/main_winmidi.cc
GM System On was refused on the shared firmware port, so the SC-88 had
no GM mode. The firmware's handler runs the GS Reset's module reset and
then turns Rx.Bank Select off where the GS Reset turns Rx.NRPN on; both
switches, and Rx.Bank Select LSB, now gate CC0, CC32 and the NRPN
numbers and are writable at 40 1x 23, 24 and 0a. Which devices have the
mode is a profile field. Provenance: P-xxxx.

Assisted-by: Claude:claude-opus-5-5
device_has_gm_mode() now follows the profile's firmwarePortGmMode, so
Synth::has_gm_mode() is true on the SC-88 and --reset gm enters GM there
instead of falling back to GS. With both modes reachable by SysEx, the
lock has to hold on the XP path too: locked in GS a GM System On does a
GS Reset, locked in GM Rx.Bank Select and Rx.NRPN are turned off again
after every message. Provenance: P-xxxx.

Assisted-by: Claude:claude-opus-5-5
@mlainez
mlainez merged commit e565403 into main Oct 19, 2026
16 checks passed
@mlainez
mlainez deleted the emuscd-gm-lock branch October 19, 2026 14:14
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