[7DRL Prep] SDL audio working in browser (WASM) #247

Closed
opened 2026-02-09 02:44:14 +00:00 by john · 1 comment
Owner

Goal

Get Sound and Music playback working in the Emscripten/WebAssembly build.

Current State

  • Desktop: SFML audio fully working (mcrfpy.Sound, mcrfpy.Music)
  • Web: All audio methods are no-ops in src/platform/SDL2Types.h:925-974
  • No SDL2_mixer in CMakeLists.txt for Emscripten builds
  • Audio assets ARE preloaded in .data file

Implementation Plan

  1. Add -sUSE_SDL_MIXER=2 to Emscripten link flags
  2. Replace audio stubs in SDL2Types.h with SDL2_mixer implementation
  3. Implement SoundBuffer (Mix_Chunk), Sound (Mix_PlayChannel), Music (Mix_LoadMUS)
  4. Initialize audio after user gesture ("Click to Run" overlay provides this)

Key Files

  • src/platform/SDL2Types.h:925-974 - Audio stub classes
  • src/PySound.h/cpp - Python Sound binding (no changes needed)
  • src/PyMusic.h/cpp - Python Music binding (no changes needed)
  • CMakeLists.txt:265-321 - Emscripten config

Browser Gotchas

  • Autoplay policy: audio context must start after user interaction
  • Main thread only: potential latency in Emscripten
  • OGG Vorbis decoding via Emscripten's built-in decoder

Detailed Report

.claude/reports/sdl_audio_wasm.md

7DRL Critical Path

20 days until 7DRL (Feb 28). Game needs sound for itch.io deployment.

## Goal Get Sound and Music playback working in the Emscripten/WebAssembly build. ## Current State - Desktop: SFML audio fully working (`mcrfpy.Sound`, `mcrfpy.Music`) - Web: All audio methods are no-ops in `src/platform/SDL2Types.h:925-974` - No SDL2_mixer in CMakeLists.txt for Emscripten builds - Audio assets ARE preloaded in .data file ## Implementation Plan 1. Add `-sUSE_SDL_MIXER=2` to Emscripten link flags 2. Replace audio stubs in SDL2Types.h with SDL2_mixer implementation 3. Implement SoundBuffer (Mix_Chunk), Sound (Mix_PlayChannel), Music (Mix_LoadMUS) 4. Initialize audio after user gesture ("Click to Run" overlay provides this) ## Key Files - `src/platform/SDL2Types.h:925-974` - Audio stub classes - `src/PySound.h/cpp` - Python Sound binding (no changes needed) - `src/PyMusic.h/cpp` - Python Music binding (no changes needed) - `CMakeLists.txt:265-321` - Emscripten config ## Browser Gotchas - Autoplay policy: audio context must start after user interaction - Main thread only: potential latency in Emscripten - OGG Vorbis decoding via Emscripten's built-in decoder ## Detailed Report `.claude/reports/sdl_audio_wasm.md` ## 7DRL Critical Path 20 days until 7DRL (Feb 28). Game needs sound for itch.io deployment.
Author
Owner

Intended labels (apply manually due to MCP label bug): priority:tier1-active, Major Feature, system:rendering

**Intended labels** (apply manually due to MCP label bug): `priority:tier1-active`, `Major Feature`, `system:rendering`
john closed this issue 2026-02-09 12:47:41 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
john/McRogueFace#247
No description provided.