Wav in SD

Hi;
Trying to play a sound without a mp3 shield. And found a way to read .wav files from SD card and send signals to speaker.

Problem is that: I connect my Arduino to a power source and speaker plays the music. But it is really fast, like breathed hellium. :slight_smile:
Anyone who knows solution for this? Thanks a lot...

Note: Using that code:

#include <SimpleSDAudio.h>

void setup() {

SdPlay.setSDCSPin(4); // sd card cs pin
pinMode(2,OUTPUT);
digitalWrite(2,LOW);
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER))

{ while(1){
  digitalWrite(2,HIGH);
  }
}

if(!SdPlay.setFile("music.wav")) // music name file

{ while(1);
  digitalWrite(2,HIGH);
}

}

void loop(void)

{

SdPlay.play(); // play music

while(!SdPlay.isStopped())

{ ;

}

}

And my wav files has this properties:
-Samples Per second (Hz): 16000
-Channel: Mono
-Bits Per Sample: 8

Where did you find the library, please provide a link.

This code probably expects a higher sampling rate than 16kHz. Have you tried 44.1kHz, for example?

Pieter

The .h file lists these playback speeds

#define SSDA_MODE_FULLRATE      0x00    // 62.500 kHz @ 16 MHz, 31.250 kHz @ 8 MHz
#define SSDA_MODE_HALFRATE 0x10 // 31.250 kHz @ 16 MHz, 15.625 kHz @ 8 MHz

Try SSDA_MODE_HALFRATE instead of SSDA_MODE_FULLRATE. That should reduce the playback speed but maybe not enough to sound even close to reasonable.
If it doesn't, you may have to resample your WAV file from 16kHz up to 31.25 kHz.

Pete

That is the project. Thanks for all yoır answers

Solved :wink:

Did you convert the sampling rate of your WAV file(s) to 30kHz?
In other words, what solved the problem?

Pete

kahve:
Hi;
Trying to play a sound without a mp3 shield. And found a way to read .wav files from SD card and send signals to speaker.

use TMRpcm library. it is perfectly well for playing .wav files. you can connect SD card directly to the arduino without any mp3 boards. you will get a great sound quality. keeping same specifications for the .wav file.

Thanks, but I have another problem now: I must change audio files with pressing the buttons, so, how can I do that?