Go Down

Topic: WAV File from SD Card (Read 6360 times) previous topic - next topic


I am trying to play a 16kHz, 8-bit, mono wav file i have on an SD Card though a speaker attached to my Ardunio. I know everything is wired correctly because when I test the speaker with the Tone library everything comes out fine and when I test the SD Card with the CardInfo example it is connected and my WAV file shows up. When running my code however, the WAV file is trying to play but it just sounds like static and not the WAV file that can be played through the card on the computer. Any advice on how to get this to work? Below is my code:

Code: [Select]
#include <SD.h>
#define SD_ChipSelectPin 10
#include <TMRpcm.h>

TMRpcm tmrpcm;
char mychar;

void setup(){
  tmrpcm.speakerPin = 9;
  if (!SD.begin(SD_ChipSelectPin)){
    Serial.println("SD Fail!");
void loop(){


It would be helpful to know what shield board you're using, or if it's your own circuitry we'd like to see your schematic.  My Adafruit Wave Shield needs it's own library to be compiled and loaded to play audio, and it seems like you have no DAC firmware or software functioning.  If it sounds like a FAX machine or a telephone modem it's because you need that DAC to turn the digital code into an audio waveform.


I think this it the wave file playback library:  TMRpcm.h

but still the hardware you have would be nice to know..

maybe these will help as they have code in them:



Lib link:


Streaming Music/Audio examples? (lib)

Im not sure about how to wire up a transistor as an AMP... but I think thats the gist of it..

You might want to check out the SimpleSDAudio lib posted here too..  (seems similar..but need to convert files)


Jul 06, 2013, 08:53 pm Last Edit: Jul 06, 2013, 08:56 pm by TMRh20 Reason: 1
If the audio comes out like static, the most likely cause is some sort of file corruption on the SD card, or a problem with the file itself. If not, then make sure the wav file is encoded correctly (16khz, 8bit, mono). Also make sure you have the most recent version: https://github.com/TMRh20/TMRpcm/archive/master.zip

Go Up