-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
streams-i2s-serial.ino
40 lines (32 loc) · 1.04 KB
/
streams-i2s-serial.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file streams-i2s-serial.ino
* @author Phil Schatzmann
* @brief see https:/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-i2s-serial/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
AudioInfo info(44100, 2, 32);
I2SStream i2sStream; // Access I2S as stream
CsvOutput<int32_t> csvStream(Serial);
StreamCopy copier(csvStream, i2sStream); // copy i2sStream to csvStream
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
auto cfg = i2sStream.defaultConfig(RX_MODE);
cfg.copyFrom(info);
cfg.i2s_format = I2S_STD_FORMAT; // or try with I2S_LSB_FORMAT
cfg.is_master = true;
// this module nees a master clock if the ESP32 is master
cfg.use_apll = false; // try with yes
cfg.pin_mck = 3;
i2sStream.begin(cfg);
// make sure that we have the correct channels set up
csvStream.begin(info);
}
// Arduino loop - copy data
void loop() {
copier.copy();
}