Repository navigation
Music on the SNES: Krautrecker's songs, the effects through its driver - #100
Merged
Merged
Conversation
…ough it (ADR-6G3HKN6P) A track in [sound] music that is a zip exported by Krautrecker plays on the SNES. The build reads the zip (port interface 1, the manifest's errors, one driver for all songs) and writes music_bank into build/gen/music.c; the effects go after every song's samples and entries, and Sfx checks the room and the voices the songs leave. sdevkit_music_init uploads Krautrecker's driver through the boot code; sdevkit_music_play loads a song with one LOAD (three bytes an exchange, overlapped with the driver's stores) and sends PLAY; sdevkit_music_stop sends STOP. The effects' bank points at music_bank, so either init can come first. The desktop plays nothing for a zip. sound.txt gets play, stop and load lines, decoded the same way in dampf.emu.SoundLog, Mesen's script and Rachael. dev/music_check and MusicCheckTest check it in dampf's emulator, on the desktop, the web and against Mesen; KrautreckerTest checks the build's reading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skerkewitz
approved these changes
Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The SNES now plays music. A track in
[sound] musicthat is a zip exported by Krautrecker (Export for SNES) plays on Krautrecker's driver, and the sound effects play through the same driver on the voices the song leaves them. This is step 3 of the plan: music on the SNES, with effects, as you chose.A game calls
sdevkit_music_init(&music_bank)ingame_init, before or aftersdevkit_sfx_init. You chose this API: the library can't name the generated data itself, because dampf refuses a symbol nobody defines. The decision record: Krautrecker's songs reach the SNES throughsdevkit_music_initand the driver's loader (ADR-6G3HKN6P). It amends the records on the driver and on the effects.How
Build (
cli/.../sfx/Krautrecker.java,Build.java):manifest.jsonand the four.binfiles;driver.bindiffer;music_bankintobuild/gen/music.c, with a song's parts split at 32 KB.Effects: they go after every song:
Sfx checks that they fit below every echo buffer and that every song reserves enough voices. In a game with a zip, the effects' bank points at
music_bank, so either init can come first.Library (
lib/sound/sfx_voices.h, shared by the SNES and Rachael):$0800to the end of the effects' samples, gaps as zeros, then PLAY;Desktop and web: a zip plays nothing (ADR-6G3E49C5). Rachael does what the driver does for the effects (unmute, and DIR at PLAY), so the effects play there as before.
Sound check: new lines
play,stopandload A N H, decoded the same way indampf.emu.SoundLog, Mesen's Lua script and Rachael's log.Check project:
dev/music_checkplays Krautrecker 0.4.0's demo Sprite Run, which I exported from a clean copy of the 0.4.0 tag withreservedSfxVoices2. The zip keeps only the manifest and the.binfiles, 16 KB. The check also plays two of steinschlag's effects, a stop, the same song again, and a WAV track (which stops the song on the SNES). It loads the song twice: music first, effects after.Verified
./gradlew build: 1289 tests, 0 failed. New tests:KrautreckerTest, 7 tests: reading, refusals, layout, generated C, room and voice checks.MusicCheckTest, 2 tests: the samesound.txtin the emulator, desktop and web, with the expected loads, plays and stops; Mesen when present. It also reads the DSP's registers in dampf's emulator after tick 31: the song plays (DIR is its directory page), and the gem's key-on reached voice 6 with directory entry$0D, which points at$66F8, the song's first free byte, where the gem's BRR lies.dev/compare_example.sh dev/music_check: Mesen and the desktop give the same 118 sound lines, the same checksums for 350 ticks, and identical screenshots.dev/bench_examples.shagainst develop): geomean 1.000. catchme, schach and steinschlag change by 1 to 2 cycles a tick. The examples without effects or music are unchanged.What follows
sdevkit_sfx_init's already were, because they wait for the sound CPU.lib/README.md's cost table,cost-baseline.txtandbackend-output.txtare updated.DebugCallsTestno longer lists the music calls: they aren't empty on the SNES any more.docs/superdevkit-findings.md, uncommitted there, for you to forward.docs/game-findings.md.docs/sound.md(Music, The checks, Not built),docs/testing.mdanddocs/history.md;docs/roadmap.md: the "not scheduled" music item is gone;lib/README.md,lib/SNES_HARDWARE.mdandlib/snes/README.md;Open
reservedSfxVoices≥ 1 if the example plays effects. Your zip's song differs from the 0.4.0 demo (9837 bytes against 9549). The driver is the same.🤖 Generated with Claude Code