snapshot
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# 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 a Webserver!
|
||||
|
||||
## 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
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
- https://github.com/pschatzmann/arduino-audio-tools
|
||||
- https://github.com/pschatzmann/TinyHttp.git
|
||||
- Arduino SD library
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Disk/AudioSourceSD.h"
|
||||
#include "AudioTools/Communication/AudioServerEx.h"
|
||||
#include "AudioTools/AudioCodecs/CodecCopy.h"
|
||||
|
||||
#define PIN_AUDIO_KIT_SD_CARD_CS 13
|
||||
#define PIN_AUDIO_KIT_SD_CARD_MISO 2
|
||||
#define PIN_AUDIO_KIT_SD_CARD_MOSI 15
|
||||
#define PIN_AUDIO_KIT_SD_CARD_CLK 14
|
||||
|
||||
const char *ssid = "SSID";
|
||||
const char *password = "PWD";
|
||||
const char *startFilePath="/";
|
||||
const char* ext="mp3";
|
||||
|
||||
AudioSourceSD source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
|
||||
AudioServerEx out;
|
||||
AudioPlayer player(source, out, *new CopyDecoder());
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
HttpLogger.setLevel(tinyhttp::Warning);
|
||||
|
||||
// setup SPI for SD card
|
||||
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);
|
||||
|
||||
|
||||
// setup output - We need to login and serve the data as audio/mp3
|
||||
auto cfg = out.defaultConfig();
|
||||
cfg.password = password;
|
||||
cfg.ssid = ssid;
|
||||
cfg.mime = "audio/mp3";
|
||||
out.begin(cfg);
|
||||
|
||||
// setup player
|
||||
player.setVolume(1.0);
|
||||
player.begin();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
player.copy();
|
||||
out.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user