Skip to content

feat(audio): play on multiple outputs, with a live mute per output - #27

Merged
mattromano merged 8 commits into
customfrom
feat/play-on-all-outputs
Nov 12, 2026
Merged

mattromano merged 8 commits into
customfrom
feat/play-on-all-outputs

Conversation

@mattromano

Copy link
Copy Markdown
Owner

--- fix(renderer): use Tailwind classes the bundled sheet already has
ml-6 and text-amber-300/80 are missing from the shipped tailwind.min.css,
so the output list rendered unindented in a build that doesn't regenerate
the sheet. Use ml-5 and text-amber-300 instead.

--- feat(audio): play on multiple outputs, with a live mute per output
Opt-in desktop setting "Play on multiple outputs" (off by default),
stored in desktop-config. With it on, the engine opens every output
channel the device advertises (for example ASIO4ALL with both a headset
and the Realtek speakers ticked) and copies the finished stereo mix,
after master gain, to every further pair. Each output pair also gets a
live play/mute checkbox. Mutes are saved by output channel name, so
they survive ASIO4ALL reordering channels, and apply without reopening
the device. Toggling the switch reopens the device through the normal
Apply flow, with no relaunch.

  • DeviceSetup: a single outputChannelsToOpen() helper feeds the duplex
    skip check, the open, the verify, and the split open, so the masks
    can't disagree.
  • Engine: duplex mixes into the first pair only. Metering and the
    loop ring still read that pair. fanOutStereoMix() (OutputFanout.h)
    then writes or clears every extra channel and silences the muted ones.
  • Main: the setDevice handler adds multiOutput from desktop-config, so
    every renderer caller gets it. Saved mutes are pushed to the engine at
    startup and on every change, and only while the switch is on.

Intended contract changes: new addon exports set/getMutedOutputChannels;
new IPC and preload audio:getMultiOutput / setMultiOutput /
setMutedOutputChannels. The fallbacks snapshot was regenerated
(UPDATE_SNAPSHOT=1) for those three handlers, and the handler count
went from 111 to 114.

--- refactor(renderer): name the Apply device handler applyDeviceForm
Moves the Apply Device Settings click handler body into a named function
so another control can re-run the exact same flow (stop, setDevice,
restore input/monitor state, start, save) instead of copying it. No
behaviour change.

🤖 Generated with Claude Code

mattromano and others added 8 commits November 12, 2026 10:14
Moves the Apply Device Settings click handler body into a named function
so another control can re-run the exact same flow (stop, setDevice,
restore input/monitor state, start, save) instead of copying it. No
behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opt-in desktop setting "Play on multiple outputs" (off by default),
stored in desktop-config. With it on, the engine opens every output
channel the device advertises (for example ASIO4ALL with both a headset
and the Realtek speakers ticked) and copies the finished stereo mix,
after master gain, to every further pair. Each output pair also gets a
live play/mute checkbox. Mutes are saved by output channel name, so
they survive ASIO4ALL reordering channels, and apply without reopening
the device. Toggling the switch reopens the device through the normal
Apply flow, with no relaunch.

- DeviceSetup: a single outputChannelsToOpen() helper feeds the duplex
  skip check, the open, the verify, and the split open, so the masks
  can't disagree.
- Engine: duplex mixes into the first pair only. Metering and the
  loop ring still read that pair. fanOutStereoMix() (OutputFanout.h)
  then writes or clears every extra channel and silences the muted ones.
- Main: the setDevice handler adds multiOutput from desktop-config, so
  every renderer caller gets it. Saved mutes are pushed to the engine at
  startup and on every change, and only while the switch is on.

Intended contract changes: new addon exports set/getMutedOutputChannels;
new IPC and preload audio:getMultiOutput / setMultiOutput /
setMutedOutputChannels. The fallbacks snapshot was regenerated
(UPDATE_SNAPSHOT=1) for those three handlers, and the handler count
went from 111 to 114.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ml-6 and text-amber-300/80 are missing from the shipped tailwind.min.css,
so the output list rendered unindented in a build that doesn't regenerate
the sheet. Use ml-5 and text-amber-300 instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Muting or unmuting an output in "Play on multiple outputs" cut the signal
at a block boundary, which clicks mid-note. fanOutStereoMix() now takes
the mask it applied last block and ramps any channel whose mute changed
(1->0 or 0->1) across the block; steady channels are copied or cleared
as before. Each output callback keeps its own previous mask, reset to
the current mask in its about-to-start so a muted output doesn't leak a
block when the device starts.

OutputFanout.h no longer needs JUCE (std::copy/fill), so it now has a
real buffer test in tests/engine_units/output_fanout_test.cpp: copy to
every pair, steady mutes, fade out/in, source-pair mute after the
copies, odd/mono channel counts, the 64-channel mask limit and the
degenerate cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in main or the renderer called it: main is the source of truth
for the saved mutes (desktop-config). Removes the binding, the engine
getter and the export.

Intended contract change: tests/contracts/addon-exports.json loses
getMutedOutputChannels (hand-edited so the native addon never loads
locally; CI's contract-check confirms it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ulti-output open

Three problems with the multi-output mutes:

- Turning the switch on pushed the saved mutes at once, while the device
  still had only its first pair open, so a muted headset pair silenced
  the app until Apply. Mutes now reach the engine only from setDevice,
  and only after a successful open with every output; any other open
  clears them. There is no startup push any more.
- Mutes were one global list of bare channel names. WASAPI names
  channels generically ("Output channel 1"), so a mute followed the user
  onto another device. desktop-config now keeps mutedOutputChannelsByDevice,
  keyed "<outputType>|<outputDevice>" (the setDevice payload's values).
  getMultiOutput / setMutedOutputChannels take that device; a list saved
  for another device is never pushed. The unreleased mutedOutputChannels
  array is ignored.
- A device that can't open every output fails closed in the engine, and
  with the setting saved, every Apply and startup restore failed with no
  audio. setDevice now retries with the first pair only and returns
  multiOutputFallback + multiOutputError; the setting stays on.

The renderer sends the form's output device with each mute and loads
that device's mutes when a probe lists its outputs. A mute click now
updates the state before the await, and saves run in click order, so
two quick clicks no longer overwrite each other.

The setDevice object/legacy call moved into openDeviceObject() so the
fallback reuses it. IPC channel and preload method names are unchanged;
the fallbacks snapshot did not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ips no-op reopens

Toggling "Play on multiple outputs" re-ran Apply, which always ended in
startAudio(), so a user who had pressed Stop got audio back. It also
reopened the device when saving the setting failed and nothing changed.

applyDeviceForm() takes { startAudio } (default true, so the Apply
button is unchanged); the toggle passes the current running state and
returns early when the saved value didn't change. Apply's status line
now says when main fell back to the first output pair
(multiOutputFallback).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tputs

# Conflicts:
#	tests/engine_units/CMakeLists.txt
@mattromano
mattromano merged commit f14e7c6 into custom Nov 12, 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.

1 participant