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 @@
# Decoding a MP3 file
In this example we decode a MP3 file into RAW output and send it the analog output pins.
Currently we provide multiple mp3 decoders
- libhelix
- tinymp3
Unfortunatly non of those are currently stable in all environments....
### Output Device: Piezo Electric Element
To test the output I am using piezo electric elements
![DAC](https://pschatzmann.github.io/Resources/img/piezo.jpeg)
It should also be possible to connect a headphone to the output pins.
| PIEZO Left | ESP32
| ------------| --------------
| + | GPIO25
| - | GND
| PIEZO2 Rigt | ESP32
| ------------| --------------
| + | GPIO26
| - | GND

View File

@@ -0,0 +1,44 @@
/**
* @file stream-memory_mp3-analog.ino
* @author Phil Schatzmann
* @brief decode MP3 stream and output as out signal
* @version 0.1
* @date 2021-01-24
*
* @copyright Copyright (c) 2021
*/
// install https://github.com/pschatzmann/arduino-libhelix.git
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
#include "BabyElephantWalk60_mp3.h"
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
AnalogAudioStream analog; // Analog output
EncodedAudioStream out(&analog, new MP3DecoderHelix()); // output to decoder
StreamCopy copier(out, mp3); // copy in to out
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
analog.begin(analog.defaultConfig(TX_MODE));
// begin processing
out.begin();
}
void loop(){
if (mp3) {
copier.copy();
} else {
auto info = out.decoder().audioInfo();
LOGI("The audio rate from the mp3 file is %d", info.sample_rate);
LOGI("The channels from the mp3 file is %d", info.channels);
out.end();
stop();
}
}