Reputation: 53
I'm trying to play a wav file from the microSD card reader. I tried using SimpleSDAudio and TMRpcm libraries but the playback is a way too fast. The song which lasts 3 minutes is played in 1 second.
I'm using Arduino Uno and Ethernet Shield with microSD card reader built-in. Speaker is connected to the pin 9.
#include <SimpleSDAudio.h>
void setup()
{
// SdPlay.setSDCSPin(10); // Enable if your SD card CS-Pin is not at Pin 4...
SdPlay.init(SSDA_MODE_HALFRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER);
SdPlay.setFile("track.wav");
SdPlay.play();
}
void loop(void) {
}
Upvotes: 2
Views: 1883
Reputation: 46375
The problem is that the library you use cannot play 8k sample files - see http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio . The slowest rate is 32k (depending on clock rate on your board) - so you are getting a 4x speed increase just from that.
It is also possible that your buffer isn't large enough. Does it play the whole file, or does it stop before the end? You might want to use
getLastError();
to find out if errors caused the playback to stop too soon (is the file fragmented? You need a cleanly formatted SD card and must not have deleted any files on it otherwise it will get confused and corrupted). See the above link for more details.
Upvotes: 2