8000 AudioBufferManager(I2s, PWMAudio, ADCInput) clicking fix (#1500) · anrp-tri/arduino-pico@3c408da · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c408da

Browse files
AudioBufferManager(I2s, PWMAudio, ADCInput) clicking fix (earlephilhower#1500)
The ABM had an off-by-one error in the DMA buffer swapover. Instead of setting the DMA address to the newly added buffer in active[], it set it to the buffer that was currently running. This would effectively disable the ping-pong and cause clicks/lost data. Fixes earlephilhower#1491
1 parent 2888f4d commit 3c408da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/AudioBufferManager/src/AudioBufferManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void __not_in_flash_func(AudioBufferManager::_dmaIRQ)(int channel) {
257257
_active[1] = _takeFromList(&_filled);
258258
}
259259
_overunderflow = _overunderflow | (_active[1] == _silence);
260-
dma_channel_set_read_addr(channel, _active[0]->buff, false);
260+
dma_channel_set_read_addr(channel, _active[1]->buff, false);
261261
} else {
262262
if (_empty) {
263263
_addToList(&_filled, _active[0]);
@@ -266,7 +266,7 @@ void __not_in_flash_func(AudioBufferManager::_dmaIRQ)(int channel) {
266266
} else {
267267
_overunderflow = true;
268268
}
269-
dma_channel_set_write_addr(channel, _active[0]->buff, false);
269+
dma_channel_set_write_addr(channel, _active[1]->buff, false);
270270
}
271271
dma_channel_set_trans_count(channel, _wordsPerBuffer * (_dmaSize == DMA_SIZE_16 ? 2 : 1), false);
272272
dma_channel_acknowledge_irq0(channel);

0 commit comments

Comments
 (0)
0