fix(audio): a stereo menu sound plays whole on the controller, not its right side on the TV #2728
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2728
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix-2725-speaker-prefetch-channels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
With a DualSense on a cable, the game sends some sounds to the controller's own speaker. Menu sounds are one of them, and their default is "Controller only". On main, most menu chimes then come out of the PC's right speaker (or the right headphone side) alone. This happens on any output, 7.1 included: the title screen's Continue, cycling the Start menu's tabs, and so on. Nothing is wrong with the 7.1 output or its channel order.
The cause is the controller speaker's sound classes. A stereo sound plays as two mono voices, one per channel. Each wave buffer the game queues gets its class from the BWAV whose channel starts there. The lookup took a channel's start from +0x30 of the BWAV's channel table, but +0x30 is where the channel's samples sit in the whole wave. The game plays from the wave in the archive in memory, which +0x34 names. The two agree for every channel of a short sound. Most of the game's longer stereo sounds are prefetch waves, though: their archive holds only the first part of each channel, and the rest is streamed. There the two agree for the first channel alone. So a menu chime's left channel was classed and went to the controller only, while its right channel went unclassed and stayed in the TV's mix. In the game's interface archive, 35 of its stereo and surround waves are like this; so are the ocarina's 24 stereo waves, and 4 of Navi's.
This reads +0x34 in both places that take a channel's start: the search behind a wave buffer (
audio_source_find_back,host/audio_source.h) and the channels kept from a header once found (known_channels,host/audio_source.c).To see it on main: a DualSense on a cable, the Controller speaker page at its defaults, Continue at the title screen, then cycle the Start menu's tabs. The chimes are heard from the right side only.
Fixes #2725. The reporter has since said the problem was the DualSense one (their log shows a cabled DualSense Edge with its speaker playing). Longshot#2233 (menu sounds on one headphone side only, gone with Menu sounds at Off or Controller + TV) looks like the same cause: this should fix its first half, but it isn't closed here. Its second half, a global opt-out, is a separate request.
Read first:
BWAV_CHANNEL_SAMPLESinhost/audio_source.h.Testing
Tested: Windows 11 Pro (26300), RTX 5080, against the shared base of main @
22d0d200(dev.py pack/rt,rt --emptyfor main), through the queue (--mode shared).With a DualSense on USB (its speaker on its own stream; the Controller speaker page at its defaults; a stereo PC output), main and this PR played the same scripted run through the control bridge, from the repository's
kokiri-startsave: Continue at the title screen, the Start menu opened, its tabs cycled three times each way, closed.HOS_AUDIO_DUMPrecorded what the PC's output played, andHOS_AUDIO_SOURCE_TRACE=1logged the classes.By ear, the same DualSense with headphones on a USB DAC (a FiiO Q series), main and then this PR, the same run with longer pauses: on main the menu chimes came from the controller and from the headphones' right side too; with this PR only from the controller, and everything else played as expected (the game's music and world in the headphones, the chimes and the other classed sounds on the pad, with no crackle).
Before that, with no DualSense yet (without one the speaker's route never opens, so the class lookup never runs), a local build (not pushed) forced the route on and could switch between main's offset (+0x30) and this one (+0x34). It showed the same on the game's own sounds. The same scripted run was played on each side through the control bridge, from the repository's
kokiri-startsave, withHOS_AUDIO_SOURCE_TRACE=1: Continue at the title screen, Start menu open, its tabs cycled three times each way, closed.stop: close work done. Audio opened as before (stereo device), nothing classed (no DualSense).diff -rq).Checks:
tests/test_audio_source.pyandtests/test_audio_source_load.pyfail on main @22d0d200at the prefetch wave's second channel and pass here. Each was checked against main's offset again: the load test fails with +0x30 and passes with +0x34. Both also pass on Linux (Ubuntu 24.04 under WSL, gcc, the first one with ASan and UBSan); the load check compileshost/audio_source.cthere. The other audio and pad speaker checks pass.mise run test(with the build's llvm-mingw clang): 632 passed, 209 failed, 47 skipped. The same 209 fail on main @22d0d200with the same tools: most need gcc, g++ or glslang, which this PC lacks. None fails only here. CI's "Third-party parts and guide screenshots" job fails on this head onscripts/check_guide_screenshots.py --review-sources. It fails the same way on main @22d0d200: the same 14 reviewed sources ofsettings-graphics.png(game/game.h,gpu/vk/vk_menu.cppand others) no longer match their recorded hashes. This PR changes none of them. Longshot#2724 recaptures that image at22d0d200and passes the check, so after it merges, a rebase here passes too.Still to test:
Measurements
Verdict: a correctness fix with no change in cost: one table offset read in place of another, in the same searches. The before and after are the classes the game's own sounds got in the game.
Setup: Windows 11, RTX 5080, a DualSense on USB, stereo PC output; the same scripted run on each side (above); the classes logged by
HOS_AUDIO_SOURCE_TRACE=1, the PC's output recorded byHOS_AUDIO_DUMPand read in 20 ms windows.22d0d2000b701b22tests/test_audio_source.py,tests/test_audio_source_load.pyRisks
The class lookup runs only while a DualSense on a cable plays the controller speaker; nothing else changes. With it, the right channels of the game's longer stereo sounds now follow their class's choice: at "Controller only" (menu sounds, pick-ups, targeting) they leave the TV's mix, as their left channels already did. At either setting they now reach the pad too. Each channel is its own mono voice, so the pad gets the two channels added where it had the left alone: up to 6 dB louder there for a sound whose sides are alike. Main already does this for the short stereo sounds (both channels found, added on the pad), so the long ones now match them. The speaker's limiter is still after it. For a short wave, +0x34 equals +0x30, so its result is unchanged. A revert is enough to undo it. Nothing changes in saves,
longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro 26300, RTX 5080, against main's base
22d0d200through the queue. No DualSense here, so a local build (not pushed) forced the speaker's route on and switched between main's offset and this one. The same scripted run on each side (kokiri-start save: Continue at the title screen, the Start menu's tabs cycled both ways, HOS_AUDIO_SOURCE_TRACE=1): main's classed one voice of each stereo pair (the left), this PR's classed both, and all six of a six-channel pick-up. This PR's own build played the same run (title, Continue, Start menu, quit) with audio as before and a clean close. Still to test: the sound itself on a cabled DualSense, by hand.Tested on a real DualSense (USB, its own speaker stream, the Controller speaker page at its defaults, stereo PC output): main and this PR played the same scripted run (kokiri-start: Continue at the title screen, the Start menu's tabs cycled both ways) with HOS_AUDIO_DUMP recording the PC's output. Main left the chimes' right halves on the PC: 23 stretches with the right channel 9 dB or more over the left, 4.06 s, the long ones on the title screen's presses and the Start menu's chimes. This PR: 16 short ones (0.58 s, the world's own sounds during play), none on the title screen or in the Start menu; both voices of every stereo sound classed. Testing, Still to test (the reporter's 7.1 setup, a listen for the pad's loudness) and Measurements updated.
Listened to by ear with the DualSense and headphones on a USB DAC, main and then this PR, the same scripted run with longer pauses: on main the menu chimes came from the controller and from the headphones' right side too; with this PR only from the controller, and everything else played as expected. Tested updated; the pad loudness check is off Still to test, which keeps the reporter's 7.1 setup.
The reporter has since said the problem was the DualSense one, which matches the cause here. Summary notes it; Still to test is now the reporter checking a build with this PR on their own 7.1 setup.
Summary's line on the reporter: only what they said (it was the DualSense issue), with what their log shows kept apart.
@review
Recommendation: Request changes. The Windows DualSense run shows that the menu chimes now route together to the controller. The reporter’s 7.1 setup and an in-game Linux controller run remain to be checked before merge. (It stands on L3: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 12s.)The change looks up channel starts using their offsets in the in-memory prefetch wave, so both sides of longer stereo sounds follow their controller-speaker setting. It changes two offset reads without adding a switch or a new search.
Blocking (1): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 12s.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/audio_source.h:147: The changed lookup has not been exercised in the game with a wired DualSense on Linux. (more on the line) Do: Run the menu and a longer classed sound with a wired DualSense on Linux, checking controller-only and controller-plus-TV routing.@fixcan do L3.Checks: Still running: 7 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. On Windows with a wired DualSense, the reported run classed both voices of each stereo pair instead of one; right-heavy stretches on the PC output fell from 4.06 seconds to 0.58 seconds, with none remaining in the tested menus. The author also heard the menu chimes only on the controller after the change.
Other systems: The lookup runs when a wired DualSense speaker route is active, independently of GPU vendor. It can change routing for other classed prefetch sounds, including ocarina and pick-up sounds; the Windows run covered a six-channel pick-up, but an in-game Linux run and the reporter’s 7.1 setup remain untested. Saves, build tools, and the renderer interface are unchanged.
Switches: None added, changed, or removed.
Reviewed:
0b701b22dcagainst22d0d20098: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, both commits, the full diff and all four changed files. Read the wave-buffer caller and relevant mixer routing; skimmed other controller-speaker call sites. docs/review-checklist.md and the sibling Tooling AGENTS.md were absent. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests, scripts, or game runs were executed. The author reports both new checks passing on Windows and Linux, and an in-game Windows DualSense comparison. CI has a head-only failure and several checks still running; the supplied CI result is left to the bot.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -140,3 +145,3 @@const unsigned channels = audio_source_u16(b + BWAV_CHANNELS);for (unsigned ch = 0; ch < channels; ch++)if (audio_source_u32(b + BWAV_HEADER + ch * BWAV_CHANNEL + BWAV_CHANNEL_DATA) == back) {if (audio_source_u32(b + BWAV_HEADER + ch * BWAV_CHANNEL + BWAV_CHANNEL_SAMPLES) == back) {L2 (should fix): The changed lookup has not been exercised in the game with a wired DualSense on Linux.
When: Linux uses a different readable-memory path for this lookup, while the reported Linux checks use a synthetic archive rather than the live controller route.
Do: Run the menu and a longer classed sound with a wired DualSense on Linux, checking controller-only and controller-plus-TV routing.
@fix
Nothing needed changing: the review's items are already done.
Not done
22d0d200, so the reported base/head difference cannot be explained from this checkout. The full REVIEW REQUIRED lines are needed to identify and review the failing inputs. No checks were run.For the author (no edit does these)
host/audio_source.h:147: The changed lookup has not been exercised in the game with a wired DualSense on Linux. When: Linux uses a different readable-memory path for this lookup, while the reported Linux checks use a synthetic archive rather than the live controller route. Do: Run the menu and a longer classed sound with a wired DualSense on Linux, checking controller-only and controller-plus-TV routing.Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
Replies to the review:
scripts/check_guide_screenshots.py --review-sources) on a clean LF export of main @22d0d200and of this head. Both print the same 14REVIEW REQUIREDlines, all forsettings-graphics.png:game/game.h,gpu/render/rx_nvn.h,gpu/vk/display_modes.h,gpu/vk/menu/controller.cpp,gpu/vk/menu/output.cpp,gpu/vk/menu_i18n.h,gpu/vk/vk_api.h,gpu/vk/vk_dlss.h,gpu/vk/vk_menu.cpp,gpu/vk/vk_menu.h,gpu/vk/vk_menu_i18n.cpp,gpu/vk/vk_paths.h,gpu/vk/vk_texture.handhost/hos_wide_size.h, each "changed since reviewed revision". This PR changes none of them (onlyhost/audio_source.c,host/audio_source.hand two tests). The "passes on main" was against an older result: main's own CI run for22d0d200hasn't run yet (every job pending). The guide's README asks for a human review of the pictured UI, never an automatic hash refresh, so it isn't something this audio fix should stamp. Longshot#2724 already recapturessettings-graphics.pngat22d0d200, and the check passes on its head (d1472268). Once it merges I'll rebase this one and the job should pass. Testing names this.No code changed and main hasn't moved (
22d0d200), so nothing was pushed. The checks were run again here:test_audio_source.pyandtest_audio_source_load.pypass;check_third_party.py(with and without--base) passes.