Summary
browser/speakers.js:21-29:
getSampleRate() {
if (!window.AudioContext) return 44100;
let myCtx = new window.AudioContext();
let sampleRate = myCtx.sampleRate;
myCtx.close();
return sampleRate;
}
Creates and immediately destroys an AudioContext just to read the sample rate. This is wasteful and can trigger browser autoplay warnings.
Fix
Cache the sample rate, or defer reading it until start() is called and the AudioContext is created anyway:
getSampleRate() {
if (this.audioCtx) return this.audioCtx.sampleRate;
return 44100; // Default until start() is called
}
Summary
browser/speakers.js:21-29:Creates and immediately destroys an AudioContext just to read the sample rate. This is wasteful and can trigger browser autoplay warnings.
Fix
Cache the sample rate, or defer reading it until
start()is called and the AudioContext is created anyway: