snapshot
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Stream URL to I2S external DAC
|
||||
|
||||
We are reading a raw audio file from the Intenet and write the data to the I2S interface. The audio file must be available using 16 bit integers with 2 channels. I used a sampling rate of 8000.
|
||||
|
||||
[Audacity](https://www.audacityteam.org/) might help you out here: export with the file name audio.raw as RAW signed 16 bit PCM and copy it to the SD card. In my example I was using the file [audio.raw](https://pschatzmann.github.io/Resources/audio/audio.raw).
|
||||
|
||||
|
||||
### 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,51 @@
|
||||
/**
|
||||
* @file url_raw-I2S_external_dac.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/url_raw-I2S_externel_dac/README.md
|
||||
* @author Phil Schatzmann
|
||||
* @copyright GPLv3
|
||||
*/
|
||||
|
||||
#include "WiFi.h"
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Communication/AudioHttp.h"
|
||||
|
||||
URLStream music; // Music Stream
|
||||
I2SStream i2s;// I2S as Stream
|
||||
StreamCopy copier(i2s, music, 1024); // copy music to i2s
|
||||
|
||||
|
||||
// Arduino Setup
|
||||
void setup(void) {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// connect to WIFI
|
||||
WiFi.begin("network", "pwd");
|
||||
while (WiFi.status() != WL_CONNECTED){
|
||||
Serial.print(".");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// open music stream
|
||||
music.begin("https://pschatzmann.github.io/Resources/audio/audio-8000.raw");
|
||||
|
||||
// start I2S with external DAC
|
||||
Serial.println("\nstarting I2S...");
|
||||
auto cfg = i2s.defaultConfig(TX_MODE);
|
||||
cfg.sample_rate = 8000;
|
||||
i2s.begin(cfg);
|
||||
}
|
||||
|
||||
// Arduino loop - repeated processing: copy input stream to output stream
|
||||
void loop() {
|
||||
int len = copier.copy();
|
||||
if (len){
|
||||
Serial.print(".");
|
||||
} else {
|
||||
delay(5000);
|
||||
i2s.end();
|
||||
Serial.println("\nCopy ended");
|
||||
stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user