VS1053 found
and a file list of the SD card, and then:
Playing track 001
Playing track 002
Done playing music
But there is no sound. There are seconds passed during playing, but not the full time of the mp3 files.
I am able to get the VS1053 to stream internet radio, with no SD card, and that (mostly) works and has sound.
The SD card has the appropriate mp3 files at a 128k bitrate. I have tested it through many iterations of the ESP32 SD_Test example.
Here is the code:
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.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#define VS_CS 4 // chip select (other spi is defined in the screen spi)
#define VS_DCS 5 // dcs
#define VS_RST 6 // reset
#define SD_CS 21 // SD chip select was 7
// DREQ should be an interrupt pin, see http://arduino.cc/en/Reference/attachInterrupt
#define VS_DREQ 15 // VS1053 Data request, all ESP32 GPIO pins are interrupt-capable pins
#define VS_SCLK 16
#define VS_MOSI 17
#define VS_MISO 18
SPIClass SPI2(0);
Adafruit_VS1053_FilePlayer musicPlayer =
// create breakout-example object!
Adafruit_VS1053_FilePlayer(VS_MOSI, VS_MISO, VS_SCLK, VS_RST, VS_CS, VS_DCS, VS_DREQ, SD_CS);
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"));
SPI2.begin(VS_SCLK, VS_MISO, VS_MOSI, SD_CS);
if (!SD.begin(SD_CS, SPI2)) {
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...
}
}
}
Anyone have any ideas as to what the problem is? Thanks