Pages: [1]   Go Down
Author Topic: WAV File from SD Card  (Read 2149 times)
0 Members and 1 Guest are viewing this topic.
Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include <SD.h>
#define SD_ChipSelectPin 10
#include <TMRpcm.h>

TMRpcm tmrpcm;
char mychar;

void setup(){
 
  tmrpcm.speakerPin = 9;
 
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)){
    Serial.println("SD Fail!");
    return;}}
   
   
void loop(){
   tmrpcm.play("delay.wav");
 return;}
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1221
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

http://forum.arduino.cc/index.php/topic,154062.0.html

http://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/

Lib link:

https://github.com/TMRh20/TMRpcm/blob/master/TMRpcm/examples/music/music.ino


Streaming Music/Audio examples? (lib)
https://github.com/TMRh20/TMRpcm/blob/master/TMRpcm/examples/streamingExamples/pcmRF/musicStreamerSimple/musicStreamerSimple.ino


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)


Logged


Offline Offline
Jr. Member
**
Karma: 3
Posts: 68
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: July 06, 2013, 01:56:27 pm by TMRh20 » Logged

Pages: [1]   Go Up
Jump to: