This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
# A Simple SdFat Audio Player
The example demonstrates how to implement an __MP3 Player__: which provides the data from a SD drive and provides the audio via A2DP (e.g. to a Bluetooth Speaker): The __AudioSourceSdFat class__ builds on the [SdFat Library](https://github.com/greiman/SdFat) from Bill Greiman which provides FAT16/FAT32 and exFAT support.
## SD Card
Here is the information how to wire the SD card to the ESP32
| SD | ESP32
|-------|-----------------------
| CS | VSPI-CS0 (GPIO 05)
| SCK | VSPI-CLK (GPIO 18)
| MOSI | VSPI-MOSI (GPIO 23)
| MISO | VSPI-MISO (GPIO 19)
| VCC | VIN (5V)
| GND | GND
![SD](https://www.pschatzmann.ch/wp-content/uploads/2021/04/sd-module.jpeg)
## Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/arduino-libhelix
- https://github.com/greiman/SdFat
- https://github.com/pschatzmann/ESP32-A2DP

View File

@@ -0,0 +1,46 @@
/**
* @file player-sdfat-a2dp.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
//remove this, to find issues regarding mp3 decoding
#define HELIX_LOGGING_ACTIVE false
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
#include "AudioTools/Disk/AudioSourceSDFAT.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const char *startFilePath="/";
const char* ext="mp3";
AudioSourceSDFAT source(startFilePath, ext); // , PIN_AUDIO_KIT_SD_CARD_CS);
A2DPStream out;
MP3DecoderHelix decoder;
AudioPlayer player(source, out, decoder);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup player
// Setting up SPI if necessary with the right SD pins by calling
// SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
player.setVolume(0.1);
player.begin();
// setup output - We send the test signal via A2DP - so we conect to a Bluetooth Speaker
auto cfg = out.defaultConfig(TX_MODE);
cfg.silence_on_nodata = true; // prevent disconnect when there is no audio data
cfg.name = "LEXON MINO L"; // set the device here. Otherwise the first available device is used for output
//cfg.auto_reconnect = true; // if this is use we just quickly connect to the last device ignoring cfg.name
out.begin(cfg);
}
void loop() {
player.copy();
}