Home Forums Sparkfun MP3 Shield Library Support Forum fail to replay an existing file Reply To: fail to replay an existing file

#1845

I believe it is due to the sd.begin() missing the chipselect. Where it will default to something else (non SFE). I have seen such SPI chipselects work at first and then not later. The omission of the test and initiErrorHalt as shown below may be allowing the bad init of the SD card through and some incompleteness having problems later in that object when replayed. Either way I have this very example below working fine, on my UNO-R3/SFE.

Note: the sd.begin() is moved to outside the library on the current per-release version, as to allow the main sketch more direct and simpler access to the files. I have some examples in the works. As a result it is needed. And the setDiffertialOutput() indicates you are using the pre release.

As to the setDiffertialOutput question refer to setDiffertialOutput() and getDiffertialOutput() of the manual. which quotes the datasheet; “Left channel output is the invert of the right channel.” and “For stereo playback streams this creates a virtual sound“. Not to sure what virtual sound is though. This mode is meant to have the + and – of the speaker connected to L and R, omitting GBUFF. And used with a mono stream or setMono if you have a stereo stream. This will double the peak to peak output. But if you leave the wiring as typical with stereo headsets, then there will not be much of a difference. Just L will be inverted. And the common signals such as base may be subtracted from between your ears.

As mentioned in another thread, I expect the volume to be so muted while inside the plush toy that a boost is needed. And setting differential and mono gets the most out of the VS1053 chip. Before needing an audio amp. (FYI looks like i typo’ed the function names and will be correcting that before release.)

Hope this helps.

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>

SdFat sd;
SFEMP3Shield MP3player;

void setup() {
    Serial.begin(115200);
    if(!sd.begin(SD_SEL, SPI_HALF_SPEED))    sd.initErrorHalt();
    uint8_t result = MP3player.begin();
      Serial.print(F("Error    code:    "));
      Serial.println(result);
    MP3player.setDiffertialOutput(1);
    MP3player.setVolume(5, 5);    //-2.5dB
}

void loop() {
  int errorCode = MP3player.playTrack(8);
    Serial.print("error    Code :");
    Serial.println(errorCode);
  delay(5000);
  MP3player.stopTrack();
  delay(1000);
}