From d630cf2c3d4390b189f952b806390360bd2b342e Mon Sep 17 00:00:00 2001 From: Daksh Date: Thu, 7 Mar 2024 19:29:50 +0530 Subject: [PATCH] incrementing index after using them --- src/audio-worklet/design-pattern/lib/wasm-audio-helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio-worklet/design-pattern/lib/wasm-audio-helper.js b/src/audio-worklet/design-pattern/lib/wasm-audio-helper.js index a089f2be5..87b2f5e2b 100644 --- a/src/audio-worklet/design-pattern/lib/wasm-audio-helper.js +++ b/src/audio-worklet/design-pattern/lib/wasm-audio-helper.js @@ -216,10 +216,10 @@ class RingBuffer { // Transfer data from the |arraySequence| storage to the internal buffer. const sourceLength = arraySequence[0].length; for (let i = 0; i < sourceLength; ++i) { - this._writeIndex = (this._writeIndex + 1) % this._length; for (let channel = 0; channel < this._channelCount; ++channel) { this._channelData[channel][this._writeIndex] = arraySequence[channel][i]; } + this._writeIndex = (this._writeIndex + 1) % this._length; } // For excessive frames, the buffer will be overwritten. @@ -247,10 +247,10 @@ class RingBuffer { // Transfer data from the internal buffer to the |arraySequence| storage. for (let i = 0; i < destinationLength; ++i) { - this._readIndex = (this._readIndex + 1) % this._length; for (let channel = 0; channel < this._channelCount; ++channel) { arraySequence[channel][i] = this._channelData[channel][this._readIndex]; } + this._readIndex = (this._readIndex + 1) % this._length; } this._framesAvailable -= destinationLength;