feat(mobile): chunked audio engine via WAV Range requests - #237
Merged
Conversation
Replaces full-file MP3 decode with a progressive WAV engine that fetches stems in 10-second chunks and chains AudioBufferSourceNodes back-to-back. - First audio after ~7 MB download (one chunk for 4 stems) vs. waiting for the complete file - Peak RAM ~28 MB vs. ~420 MB for a 5-minute 4-stem track - No track-length cap (removes the 7-14 min OOM limit) - Same glitch-free behavior on Safari/WKWebView: AudioBufferSourceNode, no streaming elements, no HTTP/1.1 connection-cap underruns - Backend needs no changes: Starlette FileResponse handles Range requests Closes #236
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.
Closes #236
What changed
Replaces the full-file MP3 decode approach with a progressive WAV engine (
static/js/chunkedAudioEngine.js) that fetches stems in 10-second chunks via HTTP Range requests and chainsAudioBufferSourceNodes back-to-back for gapless playback.static/mobile/app.jschanges are three lines: new import, WAV URLs (no.mp3replacement), engine constructor swap.Why
How it works
ready(): fetches WAV headers (first 1 KB per stem), decodes chunk 0, pre-fetches chunk 1play(): schedules chunk 0 immediately from the sync cacheseek(t): stops all nodes, evicts stale cache, restarts from the new positionFileResponsealready handlesRangeheadersTested