Skip to content

fix(browser): stop creating throwaway AudioContext in getSampleRate#653

Open
SergioChan wants to merge 1 commit intobfirsh:mainfrom
SergioChan:fix-speakers-samplerate-613
Open

fix(browser): stop creating throwaway AudioContext in getSampleRate#653
SergioChan wants to merge 1 commit intobfirsh:mainfrom
SergioChan:fix-speakers-samplerate-613

Conversation

@SergioChan
Copy link

@SergioChan SergioChan commented Mar 8, 2026

Summary

  • change Speakers.getSampleRate() to return 44.1kHz by default unless playback has already started
  • reuse this.audioCtx.sampleRate when an active audio context exists instead of creating and closing a temporary context
  • add regression tests confirming getSampleRate() no longer constructs AudioContext and still reports the active context rate

Testing

  • node --test test/speakers.spec.js

Related

Fixes #613

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.

Speakers.getSampleRate() wastefully creates/destroys AudioContext

1 participant