fix(audio): Auto counts 5.1 speakers, not channels #1167

Merged
HumanBean merged 1 commit from TrashPanda/Longshot:fix/audio-auto-speakers into main 2026-11-16 22:55:12 +00:00
Contributor

Type: fix · Risk: low · Tested on: Linux, RTX 4070 Ti (game-free checks) · Needs: Windows, an audio interface or a 5.1 system

Why

On Windows with Speaker layout on Auto, an audio interface such as a Focusrite Scarlett (8 outputs, no speakers named) was counted as 5.1, so voices, the ocarina and Link's own sounds went to outputs with nothing connected and were silent.

Restored from Hookshot 3044, by David B, and split out of #286 so it can be reviewed and merged on its own.

How to reproduce

Seen on: Windows, a Focusrite Scarlett 18i8 as the default output (reported on Hookshot)
Settings and switches: Speaker layout: Auto
Steps: play the ocarina or watch a cutscene with voices
Expected: every sound plays
Actual: voices, the ocarina and Link's sounds are silent

What changed

au_device_channels in host/nn_audio.c reads the mix format's channel mask through a new au_layout_channels: a device is 5.1 only when its mask names a centre and a pair behind or beside the player, else stereo. Stereo, 5.1, Mono and HOS_AUDIO_CHANNELS work as before; Linux is unchanged (SDL gives only a count).

Commits, each with its original author and message:

e11c1945 fix(audio): Auto counts 5.1 speakers, not channels (David B)

Fixes https://github.com/NotRexed/Hookshot/issues/2182 (one of the reports collected in https://github.com/NotRexed/Hookshot/pull/2503).

With Audio output on Auto, Hookshot told the game 5.1 whenever the
default output device had 6 or more channels. An audio interface
reports all of its outputs as channels without naming them as speakers.
A Focusrite Scarlett 18i8, for example, has 8 channels and a channel
mask of 0. The game then mixed for 5.1, and everything it puts in the
centre or behind the player went to outputs with nothing connected. That
includes voices (Saria in the ocarina cutscene), the ocarina and Link's
own sounds. Those sounds were silent while the rest of the game played
normally.

The readme already says Auto follows the device's speakers. The code
counted channels.

  • host/nn_audio.c: au_device_channels now reads the mix format's
    channel mask through a new au_layout_channels. A device counts as 5.1
    only when its mask names a centre and a pair of speakers behind or
    beside the player (5.1 back, 5.1 side, 7.1). Everything else is stereo:
    mask 0, no mask, quad, or 5.1 without a centre. The log says why, for
    example: audio: the default output has 8 channels but not 5.1 speakers (channel mask 0): counted as stereo. As stereo, the game's own downmix
    keeps every sound.

  • The Stereo and 5.1 menu choices and HOS_AUDIO_CHANNELS work as
    before. Real 5.1 and 7.1 systems still get 5.1.

  • Linux is unchanged: SDL2 reports only a channel count, not speaker
    positions.

  • readme.md: one sentence on what Auto counts.

  • New game-free check, tests/test_audio_speaker_layout.py. It compiles
    the real au_layout_channels and tests it against 13 mix formats
    (stereo, mono, 5.1 back and side, 7.1, 7.1 wide, interfaces with mask 0,
    quad, 5.1 without a centre, formats with no mask). It also checks that
    au_device_channels goes through the new function. It passes locally
    with MSVC; run_all.py passes {cxx} on CI.

  • The changed au_device_channels was compiled on its own and run on
    the reporting PC (Windows 11, Scarlett 18i8 as the default output, RTX
    3080). It reads the live mix format (8 channels, mask 0) and returns

  • Not tested yet: an in-game run on v2.1.0 with this build. Before this
    change, choosing Stereo in the menu works around the problem.

Co-authored-by: Claude Opus 5.5 [email protected]
Restored-from: https://github.com/NotRexed/Hookshot/pull/3044

Measurements

Verdict: nothing to measure: a correctness fix off the frame path, covered by game-free checks.

Flags and settings

None.

Testing

Tested: On Linux (kernel 7.0), RTX 4070 Ti, main @ 71b1edd8, this PR @ e11c1945: tests/test_audio_speaker_layout.py, tests/test_audio_output_menu.py, tests/test_audio_mono.py, tests/test_readme_menu_rows.py pass. tests/test_audio_output_devices.py fails here on main too (it looks for LONGSHOT_SHADER_STAMP in the build script). The full suite (tests/run_all.py) has not been run on this branch yet; a comment will follow when it has.

Not tested: The game on Windows with an audio interface or a 5.1 system (I am on Linux). Opened as work in progress until it runs in the game.

Must be tested:

  • Windows, an audio interface whose outputs are not speakers (by hand): Auto, expecting voices and the ocarina to play; the log says it counted stereo
  • Windows, a real 5.1 or 7.1 system (by hand): Auto, expecting 5.1 as before

Risks

What could break: Auto's speaker count on Windows.

Turning it off: revert the commit.

Compatibility: A player on Auto with an audio interface hears stereo instead of 5.1, which is the fix; nothing else changes.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).

When it applies

  • A game-free test added for the fix, failing on main and passing here.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
**Type:** fix · **Risk:** low · **Tested on:** Linux, RTX 4070 Ti (game-free checks) · **Needs:** Windows, an audio interface or a 5.1 system ## Why On Windows with Speaker layout on Auto, an audio interface such as a Focusrite Scarlett (8 outputs, no speakers named) was counted as 5.1, so voices, the ocarina and Link's own sounds went to outputs with nothing connected and were silent. Restored from [Hookshot 3044](https://github.com/NotRexed/Hookshot/pull/3044), by David B, and split out of [#286](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/286) so it can be reviewed and merged on its own. ## How to reproduce **Seen on:** Windows, a Focusrite Scarlett 18i8 as the default output (reported on Hookshot) **Settings and switches:** Speaker layout: Auto **Steps:** play the ocarina or watch a cutscene with voices **Expected:** every sound plays **Actual:** voices, the ocarina and Link's sounds are silent ## What changed `au_device_channels` in `host/nn_audio.c` reads the mix format's channel mask through a new `au_layout_channels`: a device is 5.1 only when its mask names a centre and a pair behind or beside the player, else stereo. Stereo, 5.1, Mono and `HOS_AUDIO_CHANNELS` work as before; Linux is unchanged (SDL gives only a count). Commits, each with its original author and message: <details><summary><code>e11c1945</code> fix(audio): Auto counts 5.1 speakers, not channels (David B)</summary> Fixes https://github.com/NotRexed/Hookshot/issues/2182 (one of the reports collected in https://github.com/NotRexed/Hookshot/pull/2503). With Audio output on **Auto**, Hookshot told the game 5.1 whenever the default output device had 6 or more *channels*. An audio interface reports all of its outputs as channels without naming them as speakers. A Focusrite Scarlett 18i8, for example, has 8 channels and a channel mask of `0`. The game then mixed for 5.1, and everything it puts in the centre or behind the player went to outputs with nothing connected. That includes voices (Saria in the ocarina cutscene), the ocarina and Link's own sounds. Those sounds were silent while the rest of the game played normally. The readme already says Auto follows the device's *speakers*. The code counted channels. - `host/nn_audio.c`: `au_device_channels` now reads the mix format's channel mask through a new `au_layout_channels`. A device counts as 5.1 only when its mask names a centre and a pair of speakers behind or beside the player (5.1 back, 5.1 side, 7.1). Everything else is stereo: mask `0`, no mask, quad, or 5.1 without a centre. The log says why, for example: `audio: the default output has 8 channels but not 5.1 speakers (channel mask 0): counted as stereo`. As stereo, the game's own downmix keeps every sound. - The Stereo and 5.1 menu choices and `HOS_AUDIO_CHANNELS` work as before. Real 5.1 and 7.1 systems still get 5.1. - Linux is unchanged: SDL2 reports only a channel count, not speaker positions. - `readme.md`: one sentence on what Auto counts. - New game-free check, `tests/test_audio_speaker_layout.py`. It compiles the real `au_layout_channels` and tests it against 13 mix formats (stereo, mono, 5.1 back and side, 7.1, 7.1 wide, interfaces with mask 0, quad, 5.1 without a centre, formats with no mask). It also checks that `au_device_channels` goes through the new function. It passes locally with MSVC; `run_all.py` passes `{cxx}` on CI. - The changed `au_device_channels` was compiled on its own and run on the reporting PC (Windows 11, Scarlett 18i8 as the default output, RTX 3080). It reads the live mix format (8 channels, mask `0`) and returns 2. - Not tested yet: an in-game run on v2.1.0 with this build. Before this change, choosing **Stereo** in the menu works around the problem. Co-authored-by: Claude Opus 5.5 <[email protected]> Restored-from: https://github.com/NotRexed/Hookshot/pull/3044 </details> ## Measurements **Verdict:** nothing to measure: a correctness fix off the frame path, covered by game-free checks. ### Flags and settings None. ## Testing **Tested:** On Linux (kernel 7.0), RTX 4070 Ti, `main` @ 71b1edd8, this PR @ e11c1945: `tests/test_audio_speaker_layout.py`, `tests/test_audio_output_menu.py`, `tests/test_audio_mono.py`, `tests/test_readme_menu_rows.py` pass. `tests/test_audio_output_devices.py` fails here on `main` too (it looks for `LONGSHOT_SHADER_STAMP` in the build script). The full suite (`tests/run_all.py`) has not been run on this branch yet; a comment will follow when it has. **Not tested:** The game on Windows with an audio interface or a 5.1 system (I am on Linux). Opened as work in progress until it runs in the game. **Must be tested:** - Windows, an audio interface whose outputs are not speakers (by hand): Auto, expecting voices and the ocarina to play; the log says it counted stereo - Windows, a real 5.1 or 7.1 system (by hand): Auto, expecting 5.1 as before ## Risks **What could break:** Auto's speaker count on Windows. **Turning it off:** revert the commit. **Compatibility:** A player on Auto with an audio interface hears stereo instead of 5.1, which is the fix; nothing else changes. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). ### When it applies - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers.
fix(audio): Auto counts 5.1 speakers, not channels
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 12s
e11c1945a3
Fixes https://github.com/NotRexed/Hookshot/issues/2182 (one of the reports collected in https://github.com/NotRexed/Hookshot/pull/2503).

With Audio output on **Auto**, Hookshot told the game 5.1 whenever the
default output device had 6 or more *channels*. An audio interface
reports all of its outputs as channels without naming them as speakers.
A Focusrite Scarlett 18i8, for example, has 8 channels and a channel
mask of `0`. The game then mixed for 5.1, and everything it puts in the
centre or behind the player went to outputs with nothing connected. That
includes voices (Saria in the ocarina cutscene), the ocarina and Link's
own sounds. Those sounds were silent while the rest of the game played
normally.

The readme already says Auto follows the device's *speakers*. The code
counted channels.

- `host/nn_audio.c`: `au_device_channels` now reads the mix format's
channel mask through a new `au_layout_channels`. A device counts as 5.1
only when its mask names a centre and a pair of speakers behind or
beside the player (5.1 back, 5.1 side, 7.1). Everything else is stereo:
mask `0`, no mask, quad, or 5.1 without a centre. The log says why, for
example: `audio: the default output has 8 channels but not 5.1 speakers
(channel mask 0): counted as stereo`. As stereo, the game's own downmix
keeps every sound.
- The Stereo and 5.1 menu choices and `HOS_AUDIO_CHANNELS` work as
before. Real 5.1 and 7.1 systems still get 5.1.
- Linux is unchanged: SDL2 reports only a channel count, not speaker
positions.
- `readme.md`: one sentence on what Auto counts.

- New game-free check, `tests/test_audio_speaker_layout.py`. It compiles
the real `au_layout_channels` and tests it against 13 mix formats
(stereo, mono, 5.1 back and side, 7.1, 7.1 wide, interfaces with mask 0,
quad, 5.1 without a centre, formats with no mask). It also checks that
`au_device_channels` goes through the new function. It passes locally
with MSVC; `run_all.py` passes `{cxx}` on CI.
- The changed `au_device_channels` was compiled on its own and run on
the reporting PC (Windows 11, Scarlett 18i8 as the default output, RTX
3080). It reads the live mix format (8 channels, mask `0`) and returns
2.
- Not tested yet: an in-game run on v2.1.0 with this build. Before this
change, choosing **Stereo** in the menu works around the problem.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Restored-from: https://github.com/NotRexed/Hookshot/pull/3044
Author
Contributor

Tested in game: Linux (Ubuntu 26.04.1, kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D: this branch built together with the other 18 split from #218 and #284-#288, merged onto main @ 71b1edd8 (make_game.py --update, build v3.0.0-rc.5-82-g5952bb3d), then played by a scripted tour through the control bridge (scripts/memtour.py: a save loaded, Zora's Domain, the Market, Hyrule Field and Death Mountain Trail, 40 s each with walking and camera swings). All 4 stops reached, a clean quit, and no device loss or Vulkan error in the log. Auto chose stereo for this PC's 2-channel output (log: "audio: stereo for the game (the selected/default output has 2 channels)"). A 5.1 output was not available here.

Tested in game: Linux (Ubuntu 26.04.1, kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D: this branch built together with the other 18 split from #218 and #284-#288, merged onto main @ 71b1edd8 (make_game.py --update, build v3.0.0-rc.5-82-g5952bb3d), then played by a scripted tour through the control bridge (scripts/memtour.py: a save loaded, Zora's Domain, the Market, Hyrule Field and Death Mountain Trail, 40 s each with walking and camera swings). All 4 stops reached, a clean quit, and no device loss or Vulkan error in the log. Auto chose stereo for this PC's 2-channel output (log: "audio: stereo for the game (the selected/default output has 2 channels)"). A 5.1 output was not available here.
Member

Possibly related, for context:

  • issue #982 Game: Cutscene voice lines are missing on every cutscene (Windows, RTX 3060) — Open Windows report of missing cutscene voices; potentially addressed by this fix
Possibly related, for context: - issue #982 Game: Cutscene voice lines are missing on every cutscene (Windows, RTX 3060) — Open Windows report of missing cutscene voices; potentially addressed by this fix
HumanBean changed title from WIP: fix(audio): Auto counts 5.1 speakers, not channels to fix(audio): Auto counts 5.1 speakers, not channels 2026-11-16 22:54:33 +00:00
HumanBean deleted branch fix/audio-auto-speakers 2026-11-16 22:55:17 +00:00
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 12s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1167
No description provided.