Skip to content

Commit 881abb0

Browse files
authored
fix: two ring-buffer bugs in DelayNode::delayBufferOperation (#998)
1 parent f7c925b commit 881abb0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • packages/react-native-audio-api/common/cpp/audioapi/core/effects

packages/react-native-audio-api/common/cpp/audioapi/core/effects/DelayNode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ void DelayNode::delayBufferOperation(
4343

4444
// handle buffer wrap around
4545
if (operationStartingIndex + framesToProcess > delayBuffer_->getSize()) {
46-
int framesToEnd =
47-
static_cast<int>(operationStartingIndex + framesToProcess - delayBuffer_->getSize());
46+
auto framesToEnd = static_cast<int>(delayBuffer_->getSize() - operationStartingIndex);
4847

4948
if (action == BufferAction::WRITE) {
5049
delayBuffer_->sum(
5150
*processingBuffer, processingBufferStartIndex, operationStartingIndex, framesToEnd);
5251
} else { // READ
5352
processingBuffer->sum(
5453
*delayBuffer_, operationStartingIndex, processingBufferStartIndex, framesToEnd);
54+
delayBuffer_->zero(operationStartingIndex, framesToEnd);
5555
}
5656

5757
operationStartingIndex = 0;

0 commit comments

Comments
 (0)