From 7c043157fba42a5abbaaff63b192066e5cf9438b Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 31 Dec 2024 19:33:02 +0000 Subject: [PATCH] TODOisms --- src/web/audio-renderer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/web/audio-renderer.js b/src/web/audio-renderer.js index 64b90bc..604b946 100644 --- a/src/web/audio-renderer.js +++ b/src/web/audio-renderer.js @@ -1,5 +1,4 @@ -// TODO look into using https://www.npmjs.com/package/@alexanderolsen/libsamplerate-js or similar (the full API). -/*global sampleRate, currentTime*/ +/*global sampleRate, currentTime */ const lowPassFilterFreq = sampleRate / 2; const RC = 1 / (2 * Math.PI * lowPassFilterFreq); @@ -82,6 +81,8 @@ class SoundChipProcessor extends AudioWorkletProcessor { this.cleanQueue(); if (this.queue.length === 0) return true; + // I looked into using https://www.npmjs.com/package/@alexanderolsen/libsamplerate-js or similar (the full API), + // but we fiddle the sample rate here to catch up with the target latency, which is harder to do with that API. const outByMs = this._queueAge() - this.targetLatencyMs; const maxAdjust = this.inputSampleRate * 0.01; const adjustment = Math.min(maxAdjust, Math.max(-maxAdjust, outByMs * 100));