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,35 @@
# Streaming Radio Player
We just play a streamed radio station which provides the audio as mp3 and output the result via I2S to an external DAC
To decode the data we use the libmad library.
An ESP32 was used to test this sketch.
### External DAC:
![DAC](https://pschatzmann.github.io/Resources/img/dac.jpeg)
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)
### Dependencies
- https://github.com/pschatzmann/arduino-libmad

View File

@@ -0,0 +1,47 @@
/**
* @file streams-url_mp3-i2s.ino
* @author Phil Schatzmann
* @brief decode MP3 stream from url and output it on I2S
* @version 0.1
* @date 2021-96-25
*
* @copyright Copyright (c) 2021
*/
// install https://github.com/pschatzmann/arduino-libmad.git
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3MAD.h"
#include "AudioTools/Communication/AudioHttp.h"
URLStream url("ssid","password");
I2SStream i2s; // final output of decoded stream
EncodedAudioStream dec(&i2s, new MP3DecoderMAD()); // Decoding stream
StreamCopy copier(dec, url); // copy url to decoder
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// setup i2s
auto config = i2s.defaultConfig(TX_MODE);
// you could define e.g your pins and change other settings
//config.pin_ws = 10;
//config.pin_bck = 11;
//config.pin_data = 12;
//config.mode = I2S_STD_FORMAT;
i2s.begin(config);
// setup I2S based on sampling rate provided by decoder
dec.begin();
// mp3 radio
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128","audio/mp3");
}
void loop(){
copier.copy();
}