Skip to content

Rachael's S-DSP: the whole chip, a port of ares's - #106

Merged
skerkewitz-agent[bot] merged 1 commit into
developfrom
rachael-dsp
Dec 1, 2026
Merged

skerkewitz-agent[bot] merged 1 commit into
developfrom
rachael-dsp

Conversation

@skerkewitz-agent

Copy link
Copy Markdown
Contributor

What

This is step 3 of "Krautrecker's songs on the desktop and the web". Rachael's DSP is now the whole sound chip. It plays ADSR envelopes, every GAIN mode, looped samples, noise, pitch modulation and echo, and it has the chip's five-sample key-on delay. As you chose, it is exact against the hardware: a port of ares's S-DSP, checked sample for sample against blargg's accurate SPC_DSP. The decision is a new record: Rachael's S-DSP is a port of ares's, checked against blargg's (ADR-6G426G3P).

How

  • lib/rachael/dsp.c is rewritten as a port of ares/sfc/dsp (ISC). The chip's 32 steps per sample are a switch on the step, each doing what the chip does at that point. The register write logic, the rate counter, the BRR decoder, the Gaussian interpolation (Rachael's literal table equals ares's computed one, checked), the envelopes and the echo follow ares function for function.
  • apu.c runs one DSP step after every SPC700 cycle, so a driver's write lands on the step it would on the chip. sdevkit__dsp_render remains for tests without the SPC700 (32 steps per sample).
  • The check, RachaelDspTest:
    • With -PdspTests, it fetches blargg's SPC_DSP (snes_spc 0.9.0 at a pinned commit of the blarggs-audio-libraries mirror) into ~/.cache/dampf/snes_spc and builds it with the host's C++ compiler. Both DSPs then replay 200 random scenarios of 3,000 samples: random audio RAM (BRR blocks with every filter, loop and end flag), every register of every voice, and writes at random steps. Every sample must be the same.
    • With -PdspTests=update, it also records the hashes of 20 scenarios. Every build checks Rachael's output against those, without blargg.
    • blargg's code is LGPL. It is never part of the kit: only the test fetches it.
    • Two settings make the comparison fair. Both DSPs power on with every register 0 except FLG $E0. blargg's reset latches ESA and FLG's echo bit from a hardware snapshot for one sample, so a scenario keeps the echo from writing and starts its random writes after 16 samples. And blargg's SPC_DSP doesn't wrap the sample directory's address at 64 KB (snes_spc pads its RAM for that), so the test's runner mirrors the start of the RAM behind its end.
  • The BRR Lab's voicePlay (tools/brr_lab.html) runs the same steps for one voice. It now takes the BRR bytes instead of decoded samples, so the Lab still plays exactly what Rachael plays. RachaelSoundTest checks it on its five cases; the Lab's three callers and its browser test are updated.
  • unheard: Rachael plays every feature now, so nothing counts as unheard. The count stays in the desktop check's line, always 0, so the line's format doesn't change. The test of the old counting is gone.

Verified

  • ./gradlew build: 1301 tests, 0 failed, including every example's desktop and web checks with the new DSP.
  • -PdspTests: 200 of 200 scenarios match blargg's sample for sample.
  • The first fuzz run had found two differences: the directory wrap and the power-on latch described above, both in blargg's setup, not in Rachael. Each one I shrank to a few writes, traced inside both DSPs, and fixed in the test's runner.
  • RachaelSoundTest: the Lab's new voice equals Rachael on all five cases, every sample including the voice's end.
  • Not tried: Windows (MSVC). The C is plain C99.

What follows

  • The game and the examples' effects on the desktop: they now start after the chip's key-on delay, a few samples later than before, as on the console.
  • Generated code and the SNES: unchanged; only Rachael and the Lab change. No entry in docs/game-findings.md.
  • Documents:
    • docs/sound.md (On Rachael), docs/roadmap.md (step 3 built) and docs/testing.md;
    • the new ADR;
    • NOTICE: ares's licence, and a note that the tests fetch snes_spc.
  • compiler/build.gradle.kts gains -PdspTests.
  • Book pages stale at the release: guide/the-desktop and guide/graphics-and-sound, if they describe what Rachael's DSP plays.

Open

Step 4: Krautrecker's driver on Rachael's SPC700, so the songs play on the desktop.

🤖 Generated with Claude Code

lib/rachael/dsp.c is now ares's S-DSP in C: 32 steps a sample, one after
every cycle of her SPC700, with ADSR, every GAIN mode, loops, noise,
pitch modulation, echo with its FIR filter, the key-on delay, ENDX, ENVX
and OUTX. RachaelDspTest compares it with blargg's accurate SPC_DSP
(-PdspTests, 200 random scenarios, every sample the same) and checks
the hashes of 20 in every build. The BRR Lab's voice runs the same steps,
so the Lab still plays what Rachael plays. NOTICE carries ares's licence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skerkewitz-agent
skerkewitz-agent Bot merged commit 895a14a into develop Dec 1, 2026
4 checks passed
@skerkewitz-agent
skerkewitz-agent Bot deleted the rachael-dsp branch December 1, 2026 10:40
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