ringbuffer changes, but still broken with multiple samples

This commit is contained in:
Sebastian
2025-06-30 00:47:28 +02:00
parent ad035e69e2
commit 7418cdfd35
3 changed files with 6 additions and 5 deletions

View File

@ -77,7 +77,7 @@ class RingBuffer{
counter -= 2;
rp2040.memcpyDMA(target, &buffer[read], 4);
read += 2;
if(read == bufferSize) read = 0;
if(read >= bufferSize) read = 0;
}
}

View File

@ -760,7 +760,7 @@ void loop(){
// if(cnt == 16) cnt = 0;
if(streams_loaded) {
for(int i = 0; i < NSTREAMS; i++){
stream[i].streamChunk();
stream[i].stream();
}
}
// int16_t sample_l = 0;

View File

@ -109,8 +109,9 @@ struct WaveFile{
bool readblockDMA128(){
void *bufferStart = buffer.getWritePointer();
file.read((uint8_t*)bufferStart, 128);
buffer.advance(128);
int adv = 128;
adv = file.read((uint8_t*)bufferStart, 128);
buffer.advance(adv);
if(!file.available() && loop) file.seek(44, SeekSet);
if(!file.available() && !loop) {
@ -173,7 +174,7 @@ class WaveStream{
void stream(){
int cnt = 0;
while (!wavefile.buffer.isFull() && cnt < 128 && playing) {
while (!wavefile.buffer.isFull() && cnt < 128) {
bool ok = wavefile.readblockDMA();
if(!ok) playing = false;
cnt += 2;