0

Music Maker MP3 Shield
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Music Maker MP3 Shield

by garyallen on Tue Jun 11, 2019 12:24 am

Purchased Adafruit "Music Maker" MP3 Shield for Arduino product no. 1790. Assembled following instructions. Downloaded the "latest VS1053 library" per instructions. Copied two MP3 files to my micro SD card. Tried the example sketches player_simple and player_interrupts. Neither was able to play the files. I heard a short tone when using the "interrupts" sketch. Nothing on the other. I'm using an Elegoo Uno R3 arduino ( it has worked for other applications). No error messages. Everything seems fine but...
Serial monitor sez:
Adafruit VS1053 Library Test
VS1053 found
SD OK!
TRACK0~1.MP3 6833297
TRACK0~2.MP3 9150484
Could not open file track001.mp3
I am unable to find out why it can't open and play the files.
Any suggestions for troubleshooting this situation? Thanks, Gary
Attachments
music-maker-bottom.jpg
The bottom of the shield
music-maker-bottom.jpg (181.53 KiB) Viewed 364 times
music-maker-top-with-disk.jpg
The top of the shield with micro card.
music-maker-top-with-disk.jpg (205.78 KiB) Viewed 364 times

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by stevelup on Tue Jun 11, 2019 9:36 am

For the interrupt sketch try commenting out the if-test that gave you the error, just for debugging purposes. You can put it back once you solve the underlying problem. But also there may be something wrong with your filenames. There should be no ~ in the name. Are you playing full file or a single song? Obviously you need to be sure your file name is called exactly as it appears.

stevelup
 
Posts: 2
Joined: Wed Sep 27, 2017 4:16 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Tue Jun 11, 2019 1:03 pm

What are the actual names of the files on the SD card?

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Re: Music Maker MP3 Shield

by garyallen on Thu Jun 13, 2019 8:29 pm

Thanks for the replies.
Files are named:
track001.mp3
track002.mp3
I'm not sure why the ~ was in there. Something the Serial Monitor came up with? I was just following instructions and trying to get 2 songs to play.

Pardon my ignorance but is this the part I should comment out?
// Start playing a file, then we can do stuff while waiting for it to finish
if (! musicPlayer.startPlayingFile("/track001.mp3")) {
Serial.println("Could not open file track001.mp3");
while (1);

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Thu Jun 13, 2019 9:48 pm

You should be able to run the example sketch as is without any modifications.

That requires you to use the filenames that are hardwired in the program. But, as way to test things, try changing the filenames, both on the SD card and in the code to match. See if you get the same error message "Could not open file".

What are the MP3 files? Do they play OK in something else?

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Re: Music Maker MP3 Shield

by garyallen on Thu Jun 13, 2019 11:34 pm

The mp3 files are songs I purchased and downloaded from Itunes. They play fine on my Ipod and computer and have been burned to CDs. I've tried several different files.
I changed the name of one of the files on the card and the corresponding name in the sketch. There was no difference. Got the same message.

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Fri Jun 14, 2019 12:47 pm

Let's try a known working MP3. Grab the sample Bartlebeats song from here:
https://learn.adafruit.com/adabox004/lo ... he-sd-card
and rename it to track001.mp3 and copy it to the SD card. And try again.

We don't need to worry about track002.mp3 at this point since you're getting an error right away about track001.mp3.

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Re: Music Maker MP3 Shield

by garyallen on Fri Jun 14, 2019 6:48 pm

OK. Did as you instructed. When using the "player_simple" sketch I got this:
Adafruit VS1053 Simple Test
VS1053 found
TRACK0~1.MP3 14005206
Playing track 001
Playing track 002
Done playing music

The "player_interrupts" sketch yielded this:
Adafruit VS1053 Library Test
VS1053 found
SD OK!
TRACK0~1.MP3 14005206
Could not open file track001.mp3

The only difference being a tone heard when the interrupts sketch is done uploading.
Once again, thanks for you assistance. If you would like to view my project, https://www.youtube.com/watch?v=OewIPoDoKcc
Gary

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Fri Jun 14, 2019 6:56 pm

Did the MP3 actually play for the case of running the "player_simple" example?

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Re: Music Maker MP3 Shield

by garyallen on Sat Jun 15, 2019 1:21 am

No. I've never gotten anything to play.

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by XRAD on Sun Jun 16, 2019 2:45 pm

1) Not sure why you have this '~' symbol in the track name?
TRACK0~1.MP3 14005206

2) try changing the just the track name on the SD card to:

TRACK001 (without '.MP3')

and see what happens... I had a similar issue and for some reason, played just fine without .MP3

XRAD
 
Posts: 475
Joined: Sat Nov 19, 2016 3:28 pm

Re: Music Maker MP3 Shield

by garyallen on Sun Jun 16, 2019 3:29 pm

That symbol is something that the Serial Monitor puts in. It is not in the name of the file.
The file name is:
track001.mp3
Changed name to TRACK001 and got this from the serial monitor:
Adafruit VS1053 Library Test
VS1053 found
SD OK!
TRACK001.MP3 14005206
Could not open file TRACK001
Using this sketch:
Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =
  // create breakout-example object!
  //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);


////

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Library Test");

  // initialise the music player
  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));

  musicPlayer.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working
 
  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  Serial.println("SD OK!");
 
  // list files
  printDirectory(SD.open("/"), 0);
 
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  /***** Two interrupt options! *******/
  // This option uses timer0, this means timer1 & t2 are not required
  // (so you can use 'em for Servos, etc) BUT millis() can lose time
  // since we're hitchhiking on top of the millis() tracker
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT);
 
  // This option uses a pin interrupt. No timers required! But DREQ
  // must be on an interrupt pin. For Uno/Duemilanove/Diecimilla
  // that's Digital #2 or #3
  // See http://arduino.cc/en/Reference/attachInterrupt for other pins
  // *** This method is preferred
  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
    Serial.println(F("DREQ pin is not an interrupt pin"));
}

void loop() { 
  // Alternately, we can just play an entire file at once
  // This doesn't happen in the background, instead, the entire
  // file is played and the program will continue when it's done!
  musicPlayer.playFullFile("track001.ogg");

  // Start playing a file, then we can do stuff while waiting for it to finish
  if (! musicPlayer.startPlayingFile("/TRACK001")) {
    Serial.println("Could not open file TRACK001");
    while (1);
  }
  Serial.println(F("Started playing"));

  while (musicPlayer.playingMusic) {
    // file is now playing in the 'background' so now's a good time
    // to do something else like handling LEDs or buttons :)
    Serial.print(".");
    delay(1000);
  }
  Serial.println("Done playing music");
}


/// File listing helper
void printDirectory(File dir, int numTabs) {
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}
Last edited by adafruit_support_carter on Mon Jun 17, 2019 11:49 am, edited 1 time in total.
Reason: added [code] tags

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Mon Jun 17, 2019 11:54 am

It looks like you had the most success with the "player_simple" sketch:
Code: Select all | TOGGLE FULL SIZE
Adafruit VS1053 Simple Test
VS1053 found
TRACK0~1.MP3 14005206
Playing track 001
Playing track 002
Done playing music

You did not get the "could not open file" error message. But it also did not play for some reason. How much time was there between the printing of the line:
Code: Select all | TOGGLE FULL SIZE
Playing track 001

and
Code: Select all | TOGGLE FULL SIZE
Playing track 002

Was it near instant or after a period of time?

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Re: Music Maker MP3 Shield

by garyallen on Mon Jun 17, 2019 1:27 pm

Near instant.

garyallen
 
Posts: 22
Joined: Mon Jun 10, 2019 11:42 pm

Re: Music Maker MP3 Shield

by adafruit_support_carter on Mon Jun 17, 2019 2:12 pm

For the sketch you provided the listing for above, you left off the file extension:
Code: Select all | TOGGLE FULL SIZE
      if (! musicPlayer.startPlayingFile("/TRACK001")) {


But what looks odd is there seems to be a weird variation in the file listing prints. That's all done with a single line:
Code: Select all | TOGGLE FULL SIZE
      printDirectory(SD.open("/"), 0);

It looks like sometimes it has the ~ in it:
Code: Select all | TOGGLE FULL SIZE
Adafruit VS1053 Simple Test
VS1053 found
TRACK0~1.MP3 14005206

and sometimes it does not:
Code: Select all | TOGGLE FULL SIZE
Adafruit VS1053 Library Test
VS1053 found
SD OK!
TRACK001.MP3 14005206


Do you know what filesystem format the SD card is formatted as?

adafruit_support_carter
 
Posts: 12726
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.