Skip to content

Commit

Permalink
incrementing index after using them
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksh-10 committed Mar 7, 2024
1 parent 4d3cb41 commit d630cf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/audio-worklet/design-pattern/lib/wasm-audio-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d630cf2

Please sign in to comment.