Skip to content

Conversation

@dogo
Copy link
Owner

@dogo dogo commented Dec 24, 2025

Fix BGM audio playback freeze and noise issues

Issue reported here: dogo/gods-defense#2

Problem

BGM (IMA-ADPCM) audio caused freezes/crashes and had noise/static at start, end, and during loops.

Root Causes

  1. Unpacked header struct - BGM_FORMAT_HEADER had padding, misaligning the 53-byte file header
  2. Header included in audio data - RAM mode read from file position 0 instead of after header
  3. Mono format issues - PSP audio system and double-buffering work better with stereo output

Changes

  • bgm.h: Added #pragma pack for exact 53-byte struct
  • bgm.c: Fixed file seek to skip header; output stereo (L=R) instead of mono; simplified decoder
  • audio.c: Added mono/stereo aware buffer allocation and pointer arithmetic

@dogo dogo merged commit 2878ab4 into master Dec 24, 2025
8 checks passed
@dogo dogo deleted the fix-bgm branch December 24, 2025 14:55
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