Skip to content

fix(mobile): fast track load + pitch-preserving tempo on chunked engine#242

Merged
thcp merged 1 commit into
mainfrom
fix/mobile-chunked-speed-load
Jun 30, 2026
Merged

fix(mobile): fast track load + pitch-preserving tempo on chunked engine#242
thcp merged 1 commit into
mainfrom
fix/mobile-chunked-speed-load

Conversation

@thcp

@thcp thcp commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fast load: track shows as ready after ~100 ms (WAV header fetches only) instead of blocking on the full first-chunk download. Chunk 0/1 are kicked off in the background; the first play press waits for them if not yet cached.
  • Smaller chunks: CHUNK_SEC 10 -> 5, halving the first-play buffer from ~10 MB to ~5 MB for 6 stems.
  • Pitch-preserving speed on mobile: adds SoundTouch WSOLA AudioWorklet on the chunked engine master bus. The mobile speed slider was already calling engine.setPlaybackRate() but the method was missing from the API - voices and instruments now stay at original pitch when tempo changes.

Test plan

  • Load a 6-stem track on mobile - appears ready much faster than before
  • Press play immediately after track shows as ready - plays with at most a brief wait for chunk 0
  • Adjust speed slider - vocals stay at original pitch (no tape effect)
  • Playback continues gaplessly across chunk boundaries at non-1x speeds
  • Seek and resume at non-1x speed works correctly

Three changes to chunkedAudioEngine.js:

- CHUNK_SEC 10 -> 5: halves the initial chunk download (~10 MB -> ~5 MB for 6
  stems), reducing the first-play buffering time.

- ready() no longer blocks on chunk 0 download. It resolves after the parallel
  WAV header fetches (~6 x 1 KB) and kicks chunk 0/1 off in the background.
  play() already handled the not-yet-cached case, so first play is gapless
  once the background fetch finishes. Track appears ready in the UI in ~100 ms
  instead of several seconds.

- Add SoundTouch WSOLA AudioWorklet on the master bus (same pattern as
  audioEngine.js) and expose setPlaybackRate(). The mobile speed slider was
  already wired to call this method, but it was missing from the API so the
  control silently did nothing. Pitch is now preserved at all speeds on mobile.
@thcp thcp marked this pull request as ready for review June 30, 2026 11:03
@thcp thcp merged commit c603c59 into main Jun 30, 2026
8 checks passed
@thcp thcp deleted the fix/mobile-chunked-speed-load branch June 30, 2026 11:03
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