Unknown error playing MP3 files on Music Maker

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Ial_Mazan12
 
Posts: 8
Joined: Wed Nov 16, 2022 8:00 am

Unknown error playing MP3 files on Music Maker

Post by Ial_Mazan12 »

Hello!


I'm developing a build in which I need to play an .mp3 file in the ESP32-based Feather HUZZAH32 board.
In order to get that, I decided to use the Adafruit Music Maker FeatherWing (without Amp) board, and Adafruit VS1053 library.

I started with the example recomended in official site. So, after connecting all the pins of both boards, I uploaded the VS1053 library's example "feather_player" without any modification. However, I get the error below:

Code: Select all

Adafruit VS1053 Feather Test
VS1053 found
SD OK!
track002.wav		5299354
track001.wav		5299346
Playing full track 001
Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception). 
Debug exception reason: Stack canary watchpoint triggered (dF⸮?) 
Core  1 register dump:
PC      : 0x40084583  PS      : 0x00050036  A0      : 0x3ffb097c  A1      : 0x3ffb08bc  
A2      : 0x00000029  A3      : 0x3ffbe110  A4      : 0x400845eb  A5      : 0xc0000000  
A6      : 0x3ffb097c  A7      : 0x3ffbdc1c  A8      : 0x000000f9  A9      : 0x4008459f  
A10     : 0x80000000  A11     : 0x3ffbdf58  A12     : 0x3ffbdf5c  A13     : 0x3ffbdf2c  
A14     : 0x00008000  A15     : 0x3ffbdc1c  SAR     : 0x00000001  EXCCAUSE: 0x00000001  
EXCVADDR: 0x00008000  LBEG    : 0x40087151  LEND    : 0x40087161  LCOUNT  : 0xfffffffa  


Backtrace:0x40084580:0x3ffb08bc |<-CORRUPTED




ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13160
load:0x40080400,len:3036
entry 0x400805e4
This text is repeated once and again without any change. The only sound you can hear is the one that is generated at start of the sketch.
You can see that the error doesn't start when reading the uSD card: it appears when starts playing a file.

I have tried checking conections, changing the HUZZAH32 board (I got two of them), changing the uSD card, changing audio files format, making all code and conection changes that appears on the official troubleshooting page... But none of them worked. Even more, none of the characters of the error changed.

Could somenone explain what should I do? Why does the error occur?


Thank you very much for help!

Iñigo

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Unknown error playing MP3 files on Music Maker

Post by mikeysklar »

Let's try another example and see if you get the same behavior.

When you run the player_simple.ino what do you see on the console and hear audio wise?

Can you post a photo of your soldering / wiring?

User avatar
Ial_Mazan12
 
Posts: 8
Joined: Wed Nov 16, 2022 8:00 am

Re: Unknown error playing MP3 files on Music Maker

Post by Ial_Mazan12 »

Hi Mike,


Thanks for your answer.

I have run the "player_simple" example and the result is the same: same output to Serial, same error at the same point.

This is the wiring I have done. I started connectong only the pins that are mentioned on the Pinout but, after some tries, I changed it to this one you can see attached.


Thank you for the help, I keep making tries.

Iñigo
Attachments
Wiring.jpg
Wiring.jpg (606.75 KiB) Viewed 119 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Unknown error playing MP3 files on Music Maker

Post by mikeysklar »

Thanks for the photos.

Can you link me to which Huzzah32 (Adafruit product id#) you are using. Sometimes there is confusion between the Feather V2 or ESP8266 and finally the actual Huzzah32. The pinouts are different on all three so we should confirm that you are using the Huzzah32.

https://www.adafruit.com/product/3405

I have seen one work around when using the above model of the Huzzah32. This is a custom SPI constructor which would replace the default code you can try with player_simple.ino.

Code: Select all

#define VS1053_RESET_PIN   	-1 		/* VS1053 reset pin               (not used)	*/
#define VS1053_CS_PIN   	32   	/* VS1053 chip select pin         (output)		*/
#define VS1053_DCS_PIN     	33   	/* VS1053 data/command select pin (output)		*/
#define VS1053_CARDCS_PIN	14		/* VS1053 SD card chip select pin (output)		*/
#define VS1053_DREQ_PIN     15    	/* VS1053 data request pin						*/

#define	SPI_SCK_PIN		 	5		/* hardware SPI SCK pin		*/
#define SPI_MOSI_PIN		18		/* hardware SPI MOSI pin	*/
#define SPI_MISO_PIN		19 		/* hardware SPI MISO pin	*/

Adafruit_VS1053		player( SPI_MOSI_PIN, SPI_MISO_PIN, SPI_SCK_PIN, VS1053_RESET_PIN, VS1053_CS_PIN, VS1053_DCS_PIN, VS1053_DREQ_PIN );

User avatar
Ial_Mazan12
 
Posts: 8
Joined: Wed Nov 16, 2022 8:00 am

Re: Unknown error playing MP3 files on Music Maker

Post by Ial_Mazan12 »

This one is the Huzzah32 I'm using: Adafruit HUZZAH32 – ESP32 Feather Board.

I've replaced this code below with the one you gave me. Is it in the correct place?

Code: Select all

// 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);
Once it starts uploading, it returns to me this error:

Code: Select all

exit status 1
'musicPlayer' was not declared in this scope
I was following this other post of the forum and, as it is said there, i tried removing interrupt functions in "feather_play" example and this way playFullFile() function started working. However, startPlayingFile() function doesn't work yet. Why could it be?

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Unknown error playing MP3 files on Music Maker

Post by mikeysklar »

Here is the full code I've modified player_simple.ino with the suggested software SPI pin changes for Huzzah32 compatibility and interrupts disabled.

Code: Select all

/*************************************************** 
  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>

#define VS1053_RESET_PIN     -1    /* VS1053 reset pin               (not used)  */
#define VS1053_CS_PIN     32    /* VS1053 chip select pin         (output)    */
#define VS1053_DCS_PIN      33    /* VS1053 data/command select pin (output)    */
#define VS1053_CARDCS_PIN 14    /* VS1053 SD card chip select pin (output)    */
#define VS1053_DREQ_PIN     15      /* VS1053 data request pin  

#define	SPI_SCK_PIN		 	5		/* hardware SPI SCK pin		*/
#define SPI_MOSI_PIN		18		/* hardware SPI MOSI pin	*/
#define SPI_MISO_PIN		19 		/* hardware SPI MISO pin	*/

Adafruit_VS1053_FilePlayer musicPlayer( SPI_MOSI_PIN, SPI_MISO_PIN, SPI_SCK_PIN, VS1053_RESET_PIN, VS1053_CS_PIN, VS1053_DCS_PIN, VS1053_DREQ_PIN, VS1053_CARDCS_PIN );
  
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");

  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"));
  
   if (!SD.begin(VS1053_CS_PIN)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  // list files
  printDirectory(SD.open("/"), 0);
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // Timer interrupts are not suggested, better to use DREQ interrupt!
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
  
  // Play one file, don't return until complete
  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("/track001.mp3");
  // Play another file in the background, REQUIRES interrupts!
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
}

void loop() {
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
  if (Serial.available()) {
    char c = Serial.read();
    
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
    
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else { 
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }

  delay(100);
}


/// 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();
   }
}


User avatar
Ial_Mazan12
 
Posts: 8
Joined: Wed Nov 16, 2022 8:00 am

Re: Unknown error playing MP3 files on Music Maker

Post by Ial_Mazan12 »

Hi,

Thank you for the code.
I've tried it again and the SD card was not detected. Reading it, I realized that there was a mistake: To detect the SD card, VS1053_CS_PIN was written. After changing it with VS1053_CARDCS_PIN the code keeps going.

But, even if the Serial output is OK, Music Maker doesn't reproduce any sound.

Code: Select all

VS1053 found
System Volume Information/
	WPSettings.dat		12
	IndexerVolumeGuid		76
track001.mp3		481280
track002.mp3		481280
Playing track 001
Playing track 002
Done playing music
In addition, in the last three lines, 4 seconds pass until the next line appears, as if the audios lasted those 4 seconds. However, the audios that I loaded in the uSD are 30 seconds long.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Unknown error playing MP3 files on Music Maker

Post by mikeysklar »

Try another pair of headphones. Those look like apple with their own extra mic pin.

Please post your full code again with the correct variable. That will be helpful to other ESP32 Huzzah users.

User avatar
Ial_Mazan12
 
Posts: 8
Joined: Wed Nov 16, 2022 8:00 am

Re: Unknown error playing MP3 files on Music Maker

Post by Ial_Mazan12 »

Thank you for your answer.

I have tried now with a pair of hedphones that haven't microphone pin and the result is exactly the same.

Ok. I'm going to post used code now, which is the "feather_player" example of the "Adafruit VS1053 Library" library, but with a couple of comented lines:

Code: Select all

// Specifically for use with the Adafruit Feather, the pins are pre-set here!

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

// These are the pins used
#define VS1053_RESET   -1     // VS1053 reset pin (not used!)

// Feather ESP8266
#if defined(ESP8266)
  #define VS1053_CS      16     // VS1053 chip select pin (output)
  #define VS1053_DCS     15     // VS1053 Data/command select pin (output)
  #define CARDCS          2     // Card chip select pin
  #define VS1053_DREQ     0     // VS1053 Data request, ideally an Interrupt pin

// Feather ESP32
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
  #define VS1053_CS      32     // VS1053 chip select pin (output)
  #define VS1053_DCS     33     // VS1053 Data/command select pin (output)
  #define CARDCS         14     // Card chip select pin
  #define VS1053_DREQ    15     // VS1053 Data request, ideally an Interrupt pin

// Feather Teensy3
#elif defined(TEENSYDUINO)
  #define VS1053_CS       3     // VS1053 chip select pin (output)
  #define VS1053_DCS     10     // VS1053 Data/command select pin (output)
  #define CARDCS          8     // Card chip select pin
  #define VS1053_DREQ     4     // VS1053 Data request, ideally an Interrupt pin

// WICED feather
#elif defined(ARDUINO_STM32_FEATHER)
  #define VS1053_CS       PC7     // VS1053 chip select pin (output)
  #define VS1053_DCS      PB4     // VS1053 Data/command select pin (output)
  #define CARDCS          PC5     // Card chip select pin
  #define VS1053_DREQ     PA15    // VS1053 Data request, ideally an Interrupt pin

#elif defined(ARDUINO_NRF52832_FEATHER )
  #define VS1053_CS       30     // VS1053 chip select pin (output)
  #define VS1053_DCS      11     // VS1053 Data/command select pin (output)
  #define CARDCS          27     // Card chip select pin
  #define VS1053_DREQ     31     // VS1053 Data request, ideally an Interrupt pin

// Feather M4, M0, 328, ESP32S2, nRF52840 or 32u4
#else
  #define VS1053_CS       6     // VS1053 chip select pin (output)
  #define VS1053_DCS     10     // VS1053 Data/command select pin (output)
  #define CARDCS          5     // Card chip select pin
  // DREQ should be an Int pin *if possible* (not possible on 32u4)
  #define VS1053_DREQ     9     // VS1053 Data request, ideally an Interrupt pin

#endif


Adafruit_VS1053_FilePlayer musicPlayer = 
  Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);

void setup() {
  Serial.begin(115200);

  // if you're using Bluefruit or LoRa/RFM Feather, disable the radio module
  //pinMode(8, INPUT_PULLUP);

  // Wait for serial port to be opened, remove this line for 'standalone' operation
  while (!Serial) { delay(1); }
  delay(500);
  Serial.println("\n\nAdafruit VS1053 Feather Test");
  
  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(10,10);
  
#if defined(__AVR_ATmega32U4__) 
  // Timer interrupts are not suggested, better to use DREQ interrupt!
  // but we don't have them on the 32u4 feather...
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int
#else
  // If DREQ is on an interrupt pin we can do background
  // audio playing
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
#endif
  
  // Play a file in the background, REQUIRES interrupts!
  Serial.println(F("Playing full track 001"));
  musicPlayer.playFullFile("/track001.mp3");

  delay(1000);
  
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
  
}

void loop() {
  
  Serial.print(".");
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
  if (Serial.available()) {
    char c = Serial.read();
    
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
    
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else { 
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }
  delay(100);
  
}



/// 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();
   }
}
However, it's not correct yet. Only the playFullFile() function works, not as startPlayingFile() one: it only makes the fist soun of the track and then it keeps silent while many points are printed on the Serial Monitor, as if it would be waiting to the end of the track. Do you know how to fix it? In my project, I need this second fuction.

Iñigo

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”