feat(audio): sound effects, BGM, volume and procedural synth#91
Draft
xinyao27 wants to merge 9 commits into
Draft
feat(audio): sound effects, BGM, volume and procedural synth#91xinyao27 wants to merge 9 commits into
xinyao27 wants to merge 9 commits into
Conversation
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.
Summary
Adds a complete audio feature to PocketJS as a new host surface
globalThis.audio(spec ops 26–31) — deliberately outside the deterministic core, mirroring the DevTools-ops contract so goldens and input tapes are untouched byte-for-byte.@pocketjs/framework/audio, AUDIO.md):playSfx/defineSfx/playSynth(8-bit synth descriptors: square/pulse/triangle/saw/sine/noise + sweep + envelope),playBgm/pauseBgm/resumeBgm/stopBgm(loop, cross-fade),setVolume/setMuted(master/sfx/bgm buses).<appDir>/sounds.jsonbakes WAVs → mono s16 SND pak entries (audio:sfx.*/audio:bgm.*), resampled at build time so hosts do zero decoding; BGM budget warning at 1 MB/track..rodata.Trace.audio; the music-demo journey asserts ops land on exact frames, chaos-equal.musicplays 3 generated chiptune loops (deterministicgen-sounds.ts) with cross-fading track switches and a synth blip;settings' SOUND EFFECTS toggle is now real.Verification
bun run test— 168 + 9 + 4 pass, 0 fail (incl. newaudio.test.ts×22,sound-bake.test.ts×20, music sim journey)bun run golden— 35/35 unchanged;bun run tape:check— 180 frames match (audio provably outside the replay world)bunx tsc --noEmitclean;music/settings/herobuilds greenNot verified here
The PSP native mixer (
native/src/audio.rs) compiles against the vendoredrust-pspcheckout, which is absent on this machine — needs acargo check+ PPSSPP/hardware smoke in a PSP-toolchain environment before ready-for-review.