Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

4-Channel PCM Audio Data via I2S on ESP32-S3 in Arduino-IDE #8665

nileshvyas started this conversation in Show and tell
Discussion options

Hello Everyone,

I'm currently working on a project where I want to read 4-channel 32-bit PCM audio data through the I2S interface on an ESP32-S3 MCU in Arduino IDE environment. I have an ADAU7118 evaluation board that converts data from 4 PDM mics into PCM and feeds it through I2S.
From what I've gathered, the default I2S library in arduino-esp32 predominantly supports 2-channel (stereo) mode. However, my application necessitates reading data from 4 mics, and I'm finding it challenging to configure the I2S to handle this 4-channel data.
I have successfully read 2 channel PCM data with below configuration in code Stereo Mode, 32-bit PCM data read at sample rate 8KHz:

`// Include I2S driver
#include <driver/i2s.h>
#define I2S_WS 6
#define I2S_SD 4
#define I2S_SCK 5

#define BITS_PER_SAMPLE 32
// Use I2S Processor 0
#define I2S_PORT I2S_NUM_0

// Define input buffer length
#define bufferLen 128
int32_t sBuffer[bufferLen];

void i2s_install()
{
// Set up I2S Processor configuration
const i2s_config_t i2s_config = {
.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 8000,
.bits_per_sample = i2s_bits_per_sample_t(32),
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
.intr_alloc_flags = 1, //0
.dma_buf_count = 8,
.dma_buf_len = bufferLen,
.use_apll = false
};
i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin()
{
// Set I2S pin configuration
const i2s_pin_config_t pin_config = {
.bck_io_num = I2S_SCK,
.ws_io_num = I2S_WS,
.data_out_num = -1,
.data_in_num = I2S_SD
};
i2s_set_pin(I2S_PORT, &pin_config);
}

void setup()
{
// Set up Serial Monitor
Serial.begin(115200);
Serial.println("Sample demo for read audio data\n");
// Set up I2S
i2s_install();
i2s_setpin();
i2s_start(I2S_PORT);
delay(500);
}

void loop()
{
int32_t buffer[2];
size_t bytesIn = 0;
esp_err_t result = i2s_read(I2S_PORT, (char*)buffer, BITS_PER_SAMPLE/8 * 2, &bytesIn, portMAX_DELAY);
if(result == ESP_OK)
{
Serial.printf("Left: %d, Right: %d\n", buffer[0], buffer[1]) ;
}
}`

Moreover, I'm curious about the methodologies used to handle multiple channel audio data over I2S, Specifically:

  1. Is there a need to set up a TDM configuration to handle 4-channel data, or is it possible to manage this with standard I2S configuration?
  2. Are there special configuration or setup steps required on the ADAU7118 side to ensure correct data feed to the ESP32-S3?

Has anyone encountered a similar challenge? I'm curious if:

  1. There's a way to modify the current I2S library or directly invoke ESP-IDF functionalities from Arduino to cater to 4-channel audio?
  2. Anyone knows of third-party libraries or tools in the Arduino ecosystem that support multi-channel I2S on the ESP32?

Any guidance, references, or pointers would be immensely appreciated.
Thanks in advance!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /