snapshot
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# SD Player
|
||||
|
||||
We just play a mp3 file (using the Arduino SD library) and output the result via I2S to an external DAC.
|
||||
|
||||
An ESP32 was used to test this sketch.
|
||||
|
||||
### External DAC:
|
||||
|
||||

|
||||
|
||||
|
||||
I am just using the default pins defined by the framework. However I could change them with the help of the config object. The mute pin can be defined in the constructor of the I2SStream - by not defining anything we use the default which is GPIO23
|
||||
|
||||
DAC | ESP32
|
||||
-----|----------------
|
||||
VCC | 5V
|
||||
GND | GND
|
||||
BCK | BCK (GPIO14)
|
||||
DIN | OUT (GPIO22)
|
||||
LCK | BCK (GPIO15)
|
||||
FMT | GND
|
||||
XMT | 3V (or another GPIO PIN which is set to high)
|
||||
|
||||
- DMP - De-emphasis control for 44.1kHz sampling rate(1): Off (Low) / On (High)
|
||||
- FLT - Filter select : Normal latency (Low) / Low latency (High)
|
||||
- SCL - System clock input (probably SCL on your board).
|
||||
- FMT - Audio format selection : I2S (Low) / Left justified (High)
|
||||
- XMT - Soft mute control(1): Soft mute (Low) / soft un-mute (High)
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file streams-sd_mp3-i2s.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief decode MP3 file and output it on I2S
|
||||
* @version 0.1
|
||||
* @date 2021-96-25
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*/
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
|
||||
|
||||
const int chipSelect=10;
|
||||
I2SStream i2s; // final output of decoded stream
|
||||
EncodedAudioStream decoder(&i2s, new MP3DecoderHelix()); // Decoding stream
|
||||
StreamCopy copier;
|
||||
File audioFile;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup file
|
||||
SD.begin(chipSelect);
|
||||
audioFile = SD.open("/Music/Conquistadores.mp3");
|
||||
|
||||
// setup i2s
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
i2s.begin(config);
|
||||
|
||||
// setup I2S based on sampling rate provided by decoder
|
||||
decoder.begin();
|
||||
|
||||
// begin copy
|
||||
copier.begin(decoder, audioFile);
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (!copier.copy()) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user