h4yn0nnym0u5e
Well-known member
OK, I've tested with a Kingston 16Gb card I happen to have, and which performs pretty badly on tests. The read and write speeds are OK, but it can have horrible internal delays at times, up to 1.4 seconds. I did a re-format using the official tool, which seems to have got the delays down to "only" 0.8 seconds - still really poor.
I then took a look at what might be done about this, and I think I found a pretty obscure bug in the SPI library, which I've posted about elsewhere on the forum, in case I'm wrong ... has been known to happen
Fortunately I think there's a fix (OK, horrible bodge) you could try, without digging into the library code. You need to change two files in the sketch:
In play_sd_wav.cpp, add the following lines:
In audio-guestbook.ino, increase the audio buffers from 60 to 600:
This should, if my calculations are correct, allow audio interrupts to continue while the slow SD card writes are taking place, and massively increase the buffer available so that incoming audio can be stored during that time. 600 blocks is enough for 1.74 seconds of audio - if your card is slower than that, definitely get another one!
I then took a look at what might be done about this, and I think I found a pretty obscure bug in the SPI library, which I've posted about elsewhere on the forum, in case I'm wrong ... has been known to happen
Fortunately I think there's a fix (OK, horrible bodge) you could try, without digging into the library code. You need to change two files in the sketch:
In play_sd_wav.cpp, add the following lines:
Code:
#include <Arduino.h>
#include "play_sd_wav.h"
[COLOR="#FF0000"]// ***** bodge round possible bug *****
#define SPI_HAS_NOTUSINGINTERRUPT 1
unsigned short AudioUsingSPICount;
// ************************************[/COLOR]
#include "spi_interrupt.h"
In audio-guestbook.ino, increase the audio buffers from 60 to 600:
Code:
// Audio connections require memory, and the record queue
// uses this memory to buffer incoming audio.
AudioMemory([COLOR="#FF0000"]600[/COLOR]);
This should, if my calculations are correct, allow audio interrupts to continue while the slow SD card writes are taking place, and massively increase the buffer available so that incoming audio can be stored during that time. 600 blocks is enough for 1.74 seconds of audio - if your card is slower than that, definitely get another one!