Skip to content

refactored sound into internal closure and improved tests - #30

Merged
john-doherty merged 1 commit into
masterfrom
refactor-audio
Aug 8, 2026
Merged

refactored sound into internal closure and improved tests#30
john-doherty merged 1 commit into
masterfrom
refactor-audio

Conversation

@john-doherty

Copy link
Copy Markdown
Contributor

All audio state, functions, and event listeners are now grouped into a single var audio = (function(){ ... })() closure, replacing ~7 scattered module-level variables and ~10 functions across the file. No behaviour changes — same iOS unlock flow, stall detection, and pending sound queue. Engine code consumes it via audio.load(), audio.play(), audio.stop(), audio.stopAll(), and audio.checkStall(). Public punter.playSound/punter.stopSound remain unchanged.

Also adds 7 new tests covering pre-setup guards, buffer source creation counts, loop/once/restart tracking behaviour, and scene-transition sound stopping, using AudioContext.prototype spies rather than exposing any internal state.

@john-doherty john-doherty self-assigned this Aug 8, 2026
@john-doherty
john-doherty merged commit bbc14f9 into master Aug 8, 2026
1 check passed
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