Reputation: 1
like the title suggests, I am using an esp32 and want to output a mp3 file from an SD-card via the i2s-Amp MAX98357a.
To begin with, I was trying to get an example from the library running, but it just doesn't work.
This is the example sketch:
/**
* @file player-sdfat-i2s.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-i2s/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const char *startFilePath="/";
const char* ext="mp3";
AudioSourceSDFAT source(startFilePath, ext);
I2SStream i2s;
MP3DecoderHelix decoder;
AudioPlayer player(source, i2s, decoder);
void printMetaData(MetaDataType type, const char* str, int len){
Serial.print("==> ");
Serial.print(toStr(type));
Serial.print(": ");
Serial.println(str);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Debug);
// setup output
auto cfg = i2s.defaultConfig(TX_MODE);
/*cfg.pin_bck = 4;
cfg.pin_ws = 2;
cfg.pin_data = 15;*/
i2s.begin(cfg);
// setup player
//source.setFileFilter("*Bob Dylan*");
player.setMetadataCallback(printMetaData);
player.begin();
}
void loop() {
player.copy();
}
I have tried "player-sdfat-i2s", "player-sd-i2s" and "streams-sd_mp3-i2s". I do not get any audio output, so I switched the AudioToolsLogger to "Debug" rather than "Info", and it seems that the watchdog is resetting the ESP32. The title is read correctly from the sd-card, so the SPI-connections are correct, and I have triple checked the i2s connections and tried different power sources. This is an excerpt from the Debugging text via serial:
==> Title: test_track_1
[I] StreamCopy.h : 169 - StreamCopy::copy 1024 -> 1024 -> 1024 bytes - in 1 hops
[D] AudioPlayer.h : 363 - virtual size_t audio_tools::AudioPlayer::copy(size_t)
[D] StreamCopy.h : 106 - copy 1024 bytes
[D] StreamCopy.h : 249 - available: 1898066
[D] StreamCopy.h : 394 - write: 1024
[D] AudioEncoded.h : 188 - EncodedAudioOutput::write: 1024
[D] CodecMP3Helix.h : 108 - virtual size_t audio_tools::MP3DecoderHelix::write(const uint8_t*, size_t): 1024
ets Jul 29 2019 12:21:46
rst:0x8 (TG1WDT_SYS_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:4688
With other examples, I have had errors regarding "Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled."
I have tried for days to get it working and would be greatful for suggestions!
Upvotes: 0
Views: 21