In working on an ESP32 audio project, I followed the I2S page example from here:
https://docs.espressif.com/projects/esp ... the-driver
There's an important struct in setting this up of the type i2s_config_t . One of the fields in that struct is dma_buf_len. There's no mention of the units for that variable. I assumed it was bytes since many other ESP-IDF length variables are in units of bytes.
After debugging, and looking at the ESP-IDF source code, it's clear that that variable is in units of audio 'frames' or samples. I determined this by looking at this line of code:
https://github.com/espressif/esp-idf/bl ... i2s.c#L592
Code: Select all
int sample_size = p_i2s_obj[i2s_num]->bytes_per_sample * p_i2s_obj[i2s_num]->channel_num;
https://github.com/espressif/esp-idf/bl ... i2s.c#L609
Code: Select all
dma->buf[bux_idx] = (char*) heap_caps_calloc(1, dma_buf_len * sample_size, MALLOC_CAP_DMA);
Warm regards,
Dave