From 7ef0ef0d7c9c3403636942ca12b7f5dbba0f58f3 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 20 Oct 2019 23:48:49 +0200 Subject: [PATCH] don't split ringbuffer blocks in the output; this means up to 3ms stay in the buffer. --- htdocs/lib/AudioProcessor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/AudioProcessor.js b/htdocs/lib/AudioProcessor.js index 24c7b9e..900e56f 100644 --- a/htdocs/lib/AudioProcessor.js +++ b/htdocs/lib/AudioProcessor.js @@ -32,11 +32,11 @@ class OwrxAudioProcessor extends AudioWorkletProcessor { this.port.start(); } process(inputs, outputs) { - const samples = Math.min(128, this.remaining()); + if (this.remaining() < 128) return true; outputs[0].forEach((output) => { - output.set(this.audioBuffer.subarray(this.outPos, this.outPos + samples)); + output.set(this.audioBuffer.subarray(this.outPos, this.outPos + 128)); }); - this.outPos = (this.outPos + samples) % this.bufferSize; + this.outPos = (this.outPos + 128) % this.bufferSize; return true; } remaining() {