snapshot
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Digital output via I2S to a external DAC
|
||||
|
||||
Somtimes we want to store the sound file in memory. [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 the example I was just using one channel to save memory!.
|
||||
|
||||
Then you can convert the file with xxd into a C file that contains the data in an array. In the Sketch I am using the __MemoryStream class__ which turns the array into a Stream.
|
||||
|
||||
Please note that you must compile this sketch with the __Partition Scheme: Huge App__!
|
||||
|
||||
|
||||
### External DAC:
|
||||
|
||||

|
||||
|
||||
For my tests I am using the 24-bit PCM5102 PCM5102A Stereo DAC Digital-to-analog Converter PLL Voice Module pHAT
|
||||
|
||||
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)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file streams-memory_raw-i2s.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Compile with Partition Scheme Hughe APP!
|
||||
* @version 0.1
|
||||
* @date 2021-01-24
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "StarWars30.h"
|
||||
|
||||
AudioInfo info(22050, 1, 16);
|
||||
I2SStream i2s; // Output to I2S
|
||||
MemoryStream music(StarWars30_raw, StarWars30_raw_len);
|
||||
StreamCopy copier(i2s, music); // copies sound into i2s
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
config.copyFrom(info);
|
||||
i2s.begin(config);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (!copier.copy()){
|
||||
i2s.end();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user