Skip to content

Sound effects take the top voices, 8 - n to 7 - #93

Merged
skerkewitz-agent[bot] merged 2 commits into
developfrom
sfx-top-voices
Nov 29, 2026
Merged

skerkewitz-agent[bot] merged 2 commits into
developfrom
sfx-top-voices

Conversation

@skerkewitz-agent

Copy link
Copy Markdown
Contributor

What

Sound effects now play on the top voices: with "voices": n in sfx.json they take voices 8 − n to 7, not 0 to n − 1. Krautrecker reserves the voices from the top for sound effects (reservedSfxVoices: 7, then 6 and so on). Music will play on Krautrecker's driver, as the record on the music driver (ADR-6FYT4Z4T) decides, so the effects have to sit where a song leaves them room.

How

  • lib/sound/sfx_voices.h: sfx_voice looks for a free voice, and else for the one to replace, among voices 8 - n to 7. The rules are unchanged: a free voice first, then the lowest priority not above the new effect, the older of equal ones. The SNES and Rachael share this C, so both move together.
  • tools/brr_lab.html: the Lab's pads choose and show the same voices. With one voice the view says "voice 7".
  • tools/lab_test/brr_lab.spec.js: the voice test expects voice 7.
  • docs/sound.md: the voices row and the paragraph on how a voice is chosen.
  • backend-output.txt and cost-baseline.txt, updated with -PbackendOutput=update. Only the library's code changed.

I first tried scanning from 7 downwards (v = 7 - i). That cost 12,666 master cycles at worst, so the loop counts up from 8 - n instead.

Verified

  • ./gradlew build: 1,269 tests. 1 failed: RandomProgramTest seed 20786007, which also fails on develop at 165ecf1 (see Open). 13 skipped.
  • ExamplesTest: all 9 examples pass, so the emulator's and the desktop's sound logs agree.
  • The BRR Lab's Playwright tests: 38 passed. BrrLabTest skips here without Playwright, so I installed it and ran them in tools/lab_test.
  • dev/compare_example.sh (Mesen against the desktop):
    • Schach: 9,376 ticks with the same checksums, 1,052 sound lines the same, 0 pixels different.
    • Steinschlag: 1,700 ticks with the same checksums, 780 sound lines the same, 0 pixels different.
  • Steinschlag's sound log shows its effects writing the registers of voices 6 and 7.

What follows

  • Generated code: the worst case of sfx_voice rises from 10,970 to 11,302 master cycles (+332, 3 %), for the start of the loop. Nothing else changes.
  • The C guide and its StyleGuideTest rules: unchanged.
  • The game: the effects move to other voice numbers, and nothing to change on its side. No entry in docs/game-findings.md.
  • Documents: docs/sound.md.
  • Book: the sound page may name the voices the effects take. If so, it will be stale at the release.

Open

The CI build will probably fail on the random program test, just as it fails on develop: its seed follows the day, and today's seed 20786007 finds a miscompile that is already there. dampf gives a3[1].x and a3[44].x as 0 where gcc gives 1. That needs a fix of its own in a separate pull request, before this one can merge green.

🤖 Generated with Claude Code

A song of Krautrecker leaves the voices from the top to the effects
(reservedSfxVoices: 7, then 6, ...), and music will play on its driver
(ADR-6FYT4Z4T). sfx_voice now looks at voices 8 - n to 7 instead of
0 to n - 1; the BRR Lab chooses and shows the same voices. The worst
case of sfx_voice rises from 10970 to 11302 master cycles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skerkewitz-agent

Copy link
Copy Markdown
Contributor Author

🤖 Merged develop at 03b5a9d (#94 and #95)

Problem: CI failed on this pull request because of the random loop program with seed 20786007, a miscompile already on develop and unrelated to this change. #94 fixed it.
Fix: merged develop, which brings #94's fix and #95 (Pixel Lab). No conflicts.
Commits: 03b5a9d Merge develop into sfx-top-voices
Verified: ./gradlew build: 1,272 tests, 0 failed, 1 skipped, the Lab's Playwright tests included.

@skerkewitz-agent
skerkewitz-agent Bot merged commit 92605ec into develop Nov 29, 2026
1 check passed
@skerkewitz-agent
skerkewitz-agent Bot deleted the sfx-top-voices branch November 29, 2026 22:07
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