Skip to content

Commit 3365d06

Browse files
Let's go with an "always resample" version for now.
We're resampling anyway, it's just that Web Audio is doing it sometimes. This way we can get more experience with the SRC and understand its performance impact.
1 parent 55ad437 commit 3365d06

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Diff for: src/board/audio/index.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,12 @@ class BufferedAudio {
298298
writeData(data: Float32Array) {
299299
let sampleRate = this.sampleRate;
300300
// In practice the supported range is less than the 8k..96k required by the spec
301-
if (sampleRate < 8_000 || sampleRate > 96_000) {
301+
let alwaysResample = true;
302+
if (alwaysResample || sampleRate < 8_000 || sampleRate > 96_000) {
302303
// We need to resample
303-
sampleRate = this.resampler.outputSampleRate;
304+
sampleRate = this.context.sampleRate;
304305
data = this.resampler.full(data);
305306
}
306-
console.log(
307-
"Using actual rate",
308-
sampleRate,
309-
"for requested rate",
310-
this.sampleRate
311-
);
312307

313308
// Use createXXX instead to support Safari 14.0.
314309
const buffer = this.context.createBuffer(1, data.length, sampleRate);

0 commit comments

Comments
 (0)