tigoe / SoundExamples

A collection of sound examples for Arduino
https://tigoe.github.io/SoundExamples
MIT License
51 stars 12 forks source link

Not able to play sound using esp32 #3

Open rjrajbir opened 1 year ago

rjrajbir commented 1 year ago

I am having custom board that has esp32 Wrover-E installed and also SD card and Vs1053b. So I have tested all the peripherals are working fine. track001.zip

I have tested VS1053b using ESP_VS1053_Library and its playing sound. but I want play the .mp3 file present in the SD card. I am using below code and its running but not playing sound. Also could you please provide the SOUND001.MP3 file.

I am attaching the audio files I am using. Here is the code

/*
  VS1053 example
  using SparkFun MP3 shield
  and Adafruit VS1053 library
  in beatiful harmony

  A potentiometer controls the volume.

  circuit:
    VS1053 module attached to the pins described below
    Potentiometer attached to pin A0

   note: on the MKR Zero, use the SD card on the MKR rather than
   one on the sound player module. To do this, set CARDCS to SDCARD_SS_PIN

  created 30 Nov 2018
  modified 14 Dec 2018
  by Tom Igoe

*/
#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>

// the VS1053 chip and SD card are both SPI devices.
// Set their respective pins:

#define SCK 14 
#define MISO 12 
#define MOSI 13
//#define CS   25

#define VS1053_RESET    32     // VS1053 reset pin
#define VS1053_CS       27     // VS1053 chip select pin 
#define VS1053_DCS      5     // VS1053 Data/command select pin 
#define CARDCS          25     // SD card chip select pin
#define VS1053_DREQ     2     // VS1053 Data request

// make an instance of the MP3 player library:
Adafruit_VS1053_FilePlayer mp3Player =
  Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);

// sound file name must be 8 chars .3 chars:
const char soundFile[] = "track002.MP3";//"SOUND001.MP3";

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

  // reset the VS1053 by taking reset low, then high:
  pinMode(VS1053_RESET, OUTPUT);
  digitalWrite(VS1053_RESET, LOW);
  delay(10);
  digitalWrite(VS1053_RESET, HIGH);

  // initialize the MP3 player:
  if (!mp3Player.begin()) {
    Serial.println("VS1053 not responding. Check to see if the pin numbers are correct.");
    while (true); // stop
  }

  // initialize the SD card on the module:
  if (!SD.begin(CARDCS)) {
    Serial.println("SD failed, or not present");
    while (true);  // stop
  }

  // Set volume for left and right channels.
  // 0 = loudest, 100 = silent:
  mp3Player.setVolume(50, 50);

  // use the VS1053 interrrupt pin so it can
  // let you know when it's ready for commands.
  mp3Player.useInterrupt(VS1053_FILEPLAYER_PIN_INT);

  // play file:
  mp3Player.startPlayingFile(soundFile);
  Serial.println("playing");
}

void loop() {
  // read a potentiometer (0-1023 readings) and
  // map to a range from 100 to 0:
  //int loudness = map(analogRead(A0), 0, 1023, 100, 0);
  // set the volume:
  mp3Player.setVolume(50, 50);

  // loop the player:
  if (mp3Player.stopped()) {
    Serial.println("repeating");
    mp3Player.startPlayingFile(soundFile);
  }
}

Here is the output

playing
repeating
repeating
repeating
repeating
repeating
repeating
repeating

the code is running but no sound playing. Could you please help me out.

Regards Rajbir

rjrajbir commented 1 year ago

Hi thank you for your reply, I just sent a message on the above link, but no reply

rjrajbir commented 1 year ago

I just did that multiple time, but haven't got any support