rMp3 player problems SOLVED

I can increase and decrease the volume, but nothing ever plays...when I tell it to play, it still prints stopped.....

Well it should start playing if you have a song in the root directory called mysong.mp3

change this to your song:

#define SONG "/mysong.mp3"

thats why im confused.... nothing ever plays... I have the correct filename for the song, but nothing.....p doesnt toggle anything, like the function fails silently

Ok how is your SD card looking.

There should be a single .mp3 song in the root directory of the card (no folders), this should match the name of the song as defined in the top of the sketch. Make sure this song works on the computer.
I presume your SD card doesn't have weird formatting - how is it formatted?

Just loading stuff up myself to test.

yes. I have about 10 files in the sd card....none play, and they are in root....

sorry, it's not 'p' it's 'f' to start playing

Oh and my volume instructions were wrong...

i is volume up, k is volume down - I forgot it's reversed

I saw that when looking through the code. But still no sound :frowning: really weird since I can use the SD library to obtain the filenames on the disk, but just not play them.

Is it playing now? Activity light glowing?

no, the activity light flashes occasionally, but never does anything to indicate its playing. What should the LED behavior be when playing? I used to us a VMusic module, and whenever it was playing the led was constantly flashing indicating that it was reading from the SD card.

When the module is playing, the activity light will be constantly on.

ok, I have some more info on this... I used the following code

    #include <RogueSD.h>
    #include <RogueMP3.h>
    #include <NewSoftSerial.h>
     
    NewSoftSerial rmp3_serial(6, 7);
     
    RogueMP3 rmp3(rmp3_serial);
    RogueSD filecommands(rmp3_serial);
     
    int numberOfSongs;
    int lastSong;
    char path[96];
     
    const char *directory = "/";
     
     
    void setup()
    {
      Serial.begin(9600);
     
      Serial.println("Merry Xmas!");
     
      rmp3_serial.begin(9600);
     
      rmp3.sync();
      rmp3.stop();
     
      filecommands.sync();
     
      // mix up our random number generator
      randomSeed(analogRead(0));
     
      // get the number of songs available
      strcpy(path, directory);
      
      strcat(path, "*.mp3");  // we have to do this because the IDE thinks that "/*" needs to be terminated everywhere
     
      numberOfSongs = filecommands.filecount(path);
     
      lastSong = -1;
    }
     
     
     
    void playNextSong()
    {
      uint8_t s, i;
      char filename[80];
      char path[96];
      int nextSong = 0;
     
      if (numberOfSongs > 0)
      {
        // Select our next song randomly
        if (numberOfSongs > 2)
        {
          do
            nextSong = random(numberOfSongs);
          while (nextSong == lastSong);
        }
        else if (numberOfSongs == 2)
        {
          // we only have two songs
          if (lastSong == 0)
            nextSong = 1;
          else
            nextSong = 0;
        }
     
        // now, get our file name from file list
     
        filecommands.opendir(directory);
     
        for (i = 0; i <= nextSong; i++)
        {
          filecommands.readdir(filename, "*.mp3");
        }
     
        strcpy(path, directory);
        
        strcat(path, filename);
     
        rmp3.playfile(path);
     
        Serial.print("Playing: ");
        Serial.println(path);
     
        lastSong = nextSong;
      }
      else
      {
        Serial.println("No files to play.");
      }
    }
     
     
    void loop()
    {
      char c;
      uint8_t i;
      uint8_t lastvolume = 20;
      int16_t newtime;
     
      playbackinfo playinfo;
     
      char status = 'S';
      uint8_t playing = 1;
      uint8_t volume = 20;
      uint8_t boostOn = false;
     
      volume = rmp3.getvolume();  // this only gets the left volume
     
      playNextSong();
     
      while(1)
      {
        while(!Serial.available())
        {
          // we should do fancy stuff like flash lights on our Xmas tree here!
          // got lots of time!
          delay(200);
     
          status = rmp3.getplaybackstatus();
          playinfo = rmp3.getplaybackinfo();
     
          if (status == 'S' && playing)
            playNextSong();
        }
     
        // OOH!! got a character!
        c = Serial.read();
     
        switch(c)
        {
          case 'p':
            // pause
            if(status == 'D')
            {
              // fade in
              rmp3.playpause();
              rmp3.fade(volume, 400);
            }
            else if(status == 'P')
            {
              // fade out
              rmp3.fade(100, 400);
              rmp3.playpause();
            }
            else
            {
              // start playing
              playNextSong();
              playing = 1;
            }
            break;
          case 's':
            rmp3.stop();
            playing = 0;
            break;
          case 'n':
            playNextSong();
            playing = 1;
            break;
     
          case 'e':
            if(boostOn)
            {
              rmp3.setboost(0);
              boostOn = false;
            }
            else
            {
              rmp3.setboost(8, 6, 7, 3);
              boostOn = true;
            }
            break;
     
          case 'a':
            // jump back 5 seconds
            newtime = playinfo.position - 5;
            if (newtime < 0) newtime = 0;
            rmp3.jump(newtime);
            break;
     
          case 'd':
            // jump forward 5 seconds
            rmp3.jump(playinfo.position + 5);
            break;
     
          case 'k':
            if(volume < 254) volume+=50;
            if(status != 'D') rmp3.setvolume(volume);
            break;
     
          case 'i':
            if(volume > 0) volume--;
            if(status != 'D') rmp3.setvolume(volume);
            break;
     
        }
      }
    }

and its reading the files,but the status must say that the song is finished because it keeps printing the next song filename every 200 milliseconds... so its like playfile just doesnt work.....

further debugging, shows that it constantly is returning S for getPlayback status, so the app thinks its ready to move onto the next song.

getplaybackstatus= S
Playing: /ANNOYED.mp3
getplaybackstatus= S
Playing: /ALARM11.mp3
getplaybackstatus= S
Playing: /DOODOO.mp3
getplaybackstatus= S
Playing: /FAILURE.mp3
getplaybackstatus= S
Playing: /ANNOYED.mp3
getplaybackstatus= S
Playing: /CHORTLE.mp3

Also I have 2 rMp3 shields, one with the latest firmware, the other with whatever version it came with. I know it can read the memory card, I know that its communicating fine, but just failing somewhere.

Also I have 2 rMp3 shields, one with the latest firmware, the other with whatever version it came with. I know it can read the memory card, I know that its communicating fine, but just failing somewhere.

If they both don't work then there's no point in looking at code (as I know it works fine).

How is your card formatted? What bitrate are your songs?

here is a zip file with some of the sounds I am trying to use. www.westhierry.net/JEDI.zip more info, is I am using windows 7 64 bit, I have formatted the card with both fat12 and fat32. Im kind of at wits end and frustrated, I use the arduino duelinove 168... and version 0022 of the arduino software... At this point I am thinking of trashing all my arduino software and start from scratch, maybe a library is corrupted or something......

Well it does seem a weird problem - I'll nudge bhagman over this way, maybe he knows what's going on (as he makes the thing :stuck_out_tongue: )

thanks for that. I would love to know, because through all my searching I seem to be the only one with the problem. If I find out in the meantime, I will let you know. as a recap, here is what I have checked....

2 boards, 2 versions of firmware
2GB sd card tried fat12 and fat32
All files can be seen be the RogueSD library
sync() returns 0 playfile seems to not do anything since getplaybackstatus() always returns S after calling playfile()
windows 7 64 bit runing version 0022 of arduino dev software
tried the latest SoftwareSerial libraries as well as NewSoftSerial,
Tried the mp3 files I uploaded and sent the link to.www.westhierry.net/JEDI.zip
tried with headphones as well as powered speakers.
ran through all of the diagnostics from the old arduino rmp3 thread (the READ only one) and I seem to pass all the questions... so I know my board is soldered well.

so Brett emailed me, and gave me this code to run... it appears there was a problem with the SD card I used... I tried another card and its up and purring like a kitten... Anyway, if anyone else finds a similar problem, run this code, and send the output to Rogue robotics support...

#include <RogueMP3.h>
#include <NewSoftSerial.h>

NewSoftSerial rmp3_serial(6, 7);
RogueMP3 rmp3(rmp3_serial);

const char *filename;

void setup(void)
{
 int8_t response = 0;

 Serial.begin(9600);

 Serial.println("Ready to go!");

 rmp3_serial.begin(9600);

 rmp3.sync();
 rmp3.stop();

 response = rmp3.playfile("/WOWIE.mp3");

 if (response < 0)
 {
   Serial.print("Error: ");
   Serial.println(rmp3.LastErrorCode, HEX);
 }
 else
   Serial.println("First file playing!");

 while (rmp3.getplaybackstatus() == 'P')
   delay(50);  // wait here until sound is finished

 response = rmp3.playfile("/STARTSND.mp3");

 if (response < 0)
 {
   Serial.print("Error: ");
   Serial.println(rmp3.LastErrorCode, HEX);
 }
 else
   Serial.println("Second file playing!");
}

void loop(void)
{
}

Glad it's sorted.
After exhausting most other possibilities the card was the last thing I could think of but I didn't have the code to test it.