6 #include "AudioTools/CoreAudio/AudioI2S/I2SConfig.h"
7 #include "AudioTools/CoreAudio/AudioLogger.h"
9 #define IS_I2S_IMPLEMENTED
42 LOGE(
"i2s_rxtx_begin failed");
49 void end() { i2s_end(); }
52 int available() {
return I2S_BUFFER_COUNT * I2S_BUFFER_SIZE; }
67 uint16_t frame_count = size_bytes / frame_size;
69 result = i2s_write_buffer((int16_t *)src, frame_count) * frame_size;
77 size_t writeExt(
const void *src,
size_t size_bytes) {
83 for (j = 0; j < size_bytes; j += cfg.
channels) {
84 int8_t *data = (int8_t *)src;
86 frame[0] = data[j] * 256;
88 frame[1] = data[j] * 256;
90 frame[1] = data[j + 1] * 256;
92 uint32_t *frame_ptr = (uint32_t *)frame;
93 if (i2s_write_sample(*frame_ptr)) {
100 for (j = 0; j < size_bytes / 2; j += cfg.
channels) {
101 int16_t *data = (int16_t *)src;
107 frame[1] = data[j + 1];
109 uint32_t *frame_ptr = (uint32_t *)frame;
110 if (i2s_write_sample(*frame_ptr)) {
117 for (j = 0; j < size_bytes / 3; j += cfg.
channels) {
120 int32_t value = data[j];
126 frame[1] = value / 256;
128 uint32_t *frame_ptr = (uint32_t *)frame;
129 if (i2s_write_sample(*frame_ptr)) {
136 for (j = 0; j < size_bytes / 4; j += cfg.
channels) {
137 int32_t *data = (int32_t *)src;
139 frame[0] = data[j] / 65538;
141 frame[1] = data[j] / 65538;
143 frame[1] = data[j + 1] / 65538;
145 uint32_t *frame_ptr = (uint32_t *)frame;
146 if (i2s_write_sample(*frame_ptr)) {
157 size_t result_bytes = 0;
159 size_t frames = size_bytes / frame_size;
160 int16_t *ptr = (int16_t *)dest;
162 for (
int j = 0; j < frames; j++) {
164 int16_t *right = ptr + 1;
165 bool ok = i2s_read_sample(
171 result_bytes += frame_size;
177 using I2SDriver = I2SDriverESP8266;
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition: AudioTypes.h:28