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

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1843
    Anonymous
    Inactive

    Hi Bill,

    Here is a simple code I am trying to run (omitting the librairies)

    void setup() {
    Serial.begin(9600);
    sd.begin(); //card access
    MP3player.begin(); //player access

    //setup
    MP3player.setDiffertialOutput(1);
    MP3player.setVolume(5, 5);  //-2.5dB
    //question: how does L/R balance is handled in differential output ?
    }

    void loop(){

    int errorCode = MP3player.playTrack(1);
    Serial.print(“error Code :”);
    Serial.println(errorCode);

    delay(5000);
    MP3player.stopTrack();
    delay(1000);
    }

    So, I am expecting the song to play for 5 sec, then stop for 1sec, then restart for 5sec.

    It is indeed playing the first time, but at the second loop and every following attempt, I get error code 2, can’t locate the file.

    When I used your sample code, I am able to stop/start track 1 by hitting “1” and “s” successively so it is not a hardware thing. Your code looks the same to me but it is obviously not, otherwise it’d work.

     

    Can you help me spot what I am missing ?

     

    Thanks !

    #1844
    Anonymous
    Inactive

    Try removing sd.begin(); and also SdFat sd;

    Despite what the troubleshooting says, the MP3player library will do this for you. Note that the sample code does not have sd.begin();

    #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);
    }
    #1849
    Anonymous
    Inactive

    It works, thanks.

    Now I’ll move to the actual stuffing in the toy and report on the volume.

     

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.