Skip to content

feat(audio): zen-wood SFX + BGM assets, audio now audible (#330 P3) - #444

Merged
wei18 merged 2 commits into
mainfrom
feat/330-p3-zenwood-assets
Jun 9, 2026
Merged

wei18 merged 2 commits into
mainfrom
feat/330-p3-zenwood-assets

Conversation

@wei18

@wei18 wei18 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

#330 P3 — zen-wood audio assets (audio now audible)

P1/P2 wired GameAudio.LiveSoundPlayer to resolve each soundKey from Bundle.main, but shipped no assets — every play() / playMusic() hit the tolerated missing-asset path and silently no-op'd. P3 drops the zen-wood palette into both app bundles so gameplay audio actually plays. Engine/wiring unchanged.

How LiveSoundPlayer resolves a soundKey

audioURL(for:) searches the injected bundle (default .main) across, in order:

["caf", "wav", "m4a", "aif", "aiff", "mp3"]

via bundle.url(forResource: key, withExtension: ext). So an asset loads iff its filename stem == the soundKey and its extension is in that set.

Assets per app (stem == soundKey)

Sudoku — App/Sudoku/Resources/Audio/

soundKey file bytes
place (SFX) place.wav 23858
complete (SFX) complete.wav 71486
error (SFX) error.wav 44144
win (SFX) win.wav 233774
gameplay (BGM, ~8s loop) gameplay.wav 710054

Minesweeper — App/Minesweeper/Resources/Audio/

soundKey file bytes
reveal (SFX) reveal.wav 23858
flag (SFX) flag.wav 10628
floodClear (SFX) floodClear.wav 44144
explosion (SFX) explosion.wav 70604
win (SFX) win.wav 233774
bgm (BGM, ~8s loop) bgm.wav 710054

Generated by the gitignored build/audio-demos/gen_palettes.py zen-wood palette (pure-numpy synthesis, royalty-free). Sudoku BGM is sudoku/zen-wood/bgm.wav renamed to the gameplay soundKey; Minesweeper BGM keeps the bgm soundKey.

Format choice

Assets ship as 16-bit PCM mono 44.1kHz WAV (validated via the Python wave module: ch=1, 16-bit, 44100Hz). AVAudioPlayer plays WAV natively and wav is in the resolver's extension list, so playback is unaffected.

The spec preferred afconvert → SFX .caf (LEI16/caff) + BGM .m4a (AAC). afconvert/afinfo were hard-denied in this sandboxed environment, so conversion wasn't possible here. WAV is the pragmatic, resolver-compatible fallback; a follow-up can re-encode to .caf/.m4a to shrink the BGM (710KB → ~120KB AAC) if bundle size matters. The resolver needs no change either way.

Project.swift

Each app target now globs App/<App>/Resources/Audio/** into resources: (mirrors the existing Settings.bundle glob style). Only the banner files are untouched per scope.

Verification (all green)

  • tuist generate --no-open ✔ — generated Game.xcodeproj references all 11 audio files; 22 "in Resources" build-file entries (11 per-target memberships) confirm both app targets bundle them.
  • swift test ✔ GameAudioKit (15), SudokuKit (220), MinesweeperKit (127) — all pass.
  • New mise run verify:audio ✔ — asserts every soundKey (Sudoku place/complete/error/win/gameplay + Minesweeper reveal/flag/floodClear/explosion/win/bgm) resolves to a non-empty asset whose stem == the soundKey, using the same extension set LiveSoundPlayer uses. Output: audio verify PASS.
  • mise run scan:l10n ✔ — L10n gate passed.

Headless audio playback can't be unit-tested, so verification covers file presence + naming + resolver-extension match + bundle membership.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 9, 2026 16:30
P1/P2 wired GameAudio.LiveSoundPlayer to resolve each `soundKey` from
`Bundle.main` but shipped no assets, so gameplay audio silently no-op'd.
P3 drops the zen-wood palette into both app bundles, with each filename
stem matching the soundKey the apps fire.

Sudoku (App/Sudoku/Resources/Audio/):
  place / complete / error / win (SFX) + gameplay (BGM, from zen-wood bgm)

Minesweeper (App/Minesweeper/Resources/Audio/):
  reveal / flag / floodClear / explosion / win (SFX) + bgm (BGM)

Assets are generated by the gitignored build/audio-demos/gen_palettes.py
zen-wood palette (pure-numpy synth, royalty-free).

Format note: LiveSoundPlayer.audioURL(for:) resolves a soundKey across
[caf, wav, m4a, aif, aiff, mp3] from the injected bundle. Assets ship as
16-bit PCM mono 44.1kHz WAV (AVAudioPlayer plays natively); the BGM loops
~8s. afconvert to .caf/.m4a was unavailable in this environment, and WAV
is in the resolver's extension set, so playback is unaffected.

Project.swift globs App/<App>/Resources/Audio/** into each app target;
verified via `tuist generate` (both targets reference all 11 files) and a
new `mise run verify:audio` task that asserts every soundKey resolves to a
non-empty asset whose stem == the soundKey.

Co-Authored-By: Wei18 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
afconvert was denied in the implementing agent's sandbox; re-encoding the two ~710KB uncompressed BGM loops to AAC-in-CAF (resolver tries .caf first; gapless-friendly) before merge avoids committing ~1.3MB of throwaway WAV. Short SFX stay WAV for low-latency one-shots.

Co-Authored-By: Wei18 <[email protected]>

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit 1189393 into main Jun 9, 2026
4 checks passed
@wei18
wei18 deleted the feat/330-p3-zenwood-assets branch June 9, 2026 08:39
wei18 added a commit that referenced this pull request Jun 9, 2026
…on banner-seam note (#445)

Reflect the post-#442 work: #330 audio CLOSED (P3 #444), real shared banner #441/#443. Meeting log decisions/open-questions updated; mise-task-operations index gains verify:audio; monetization-sdk-integration records the GADBannerView -> AnyView cross-target seam + the #if DEBUG/Release ID split (supersedes the old REPLACE_IN_v2.5.3 placeholder).

Co-authored-by: Claude Opus 4.8 <[email protected]>
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