From 91b8c55de9242b6a67f0a8eab50696b726e96183 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 20 Oct 2019 13:28:25 +0200 Subject: [PATCH] optimize --- htdocs/lib/AudioProcessor.js | 1 - htdocs/openwebrx.js | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/lib/AudioProcessor.js b/htdocs/lib/AudioProcessor.js index 3789608..525299f 100644 --- a/htdocs/lib/AudioProcessor.js +++ b/htdocs/lib/AudioProcessor.js @@ -2,7 +2,6 @@ class OwrxAudioProcessor extends AudioWorkletProcessor { constructor(options){ super(options); this.maxLength = options.processorOptions.maxLength; - this.reduceToLength = options.processorOptions.reduceToLength; // initialize ringbuffer, make sure it aligns with the expected buffer size of 128 this.bufferSize = Math.round(sampleRate * this.maxLength / 128) * 128 this.audioBuffer = new Float32Array(this.bufferSize); diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 1722b43..855018e 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1546,7 +1546,7 @@ function audio_prepare(data) { buffer = audio_resampler.process(sdrjs.ConvertI16_F(buffer)); if (audio_node.port) { // AudioWorklets supported - audio_node.port.postMessage(buffer, [buffer.buffer]); + audio_node.port.postMessage(buffer); } else { audio_buffers.push(buffer); } @@ -1568,9 +1568,9 @@ function audio_onprocess(e) { var newLength = total + b.length; // not enough space to fit all data, so splice and put back in the queue if (newLength > audio_buffer_size) { - var tokeep = b.slice(0, audio_buffer_size - total); + var tokeep = b.subarray(0, audio_buffer_size - total); out.set(tokeep, total); - var tobuffer = b.slice(audio_buffer_size - total, b.length); + var tobuffer = b.subarray(audio_buffer_size - total, b.length); audio_buffers.unshift(tobuffer); break; } else { @@ -1732,8 +1732,7 @@ function audio_init() { numberOfOutputs: 1, outputChannelCount: [1], processorOptions: { - maxLength: audio_buffer_maximal_length_sec, - reduceToLength: audio_buffer_decrease_to_on_overrun_sec + maxLength: audio_buffer_maximal_length_sec } }); audio_node.connect(gainNode);