Skip to content

Commit

Permalink
Let's go with an "always resample" version for now.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
microbit-matt-hillsdon committed Aug 24, 2024
1 parent 55ad437 commit 3365d06
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/board/audio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,12 @@ class BufferedAudio {
writeData(data: Float32Array) {
let sampleRate = this.sampleRate;
// In practice the supported range is less than the 8k..96k required by the spec
if (sampleRate < 8_000 || sampleRate > 96_000) {
let alwaysResample = true;
if (alwaysResample || sampleRate < 8_000 || sampleRate > 96_000) {
// We need to resample
sampleRate = this.resampler.outputSampleRate;
sampleRate = this.context.sampleRate;
data = this.resampler.full(data);
}
console.log(
"Using actual rate",
sampleRate,
"for requested rate",
this.sampleRate
);

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

0 comments on commit 3365d06

Please sign in to comment.