Play PCM raw data on NRF5340

Hello,

I want to play a .wav audio file on nRF5340 audio dk.

I convert the wav file into raw data and store it in an array.

After that, I play it using nrfx_i2s_start, but the output sound is very noisy.

Here is my code:

uint8_t raw_data[] = {/*RAW DATA*/}

const int raw_size = sizeof(raw_data);

const nrfx_i2s_buffers_t i2s_buf = { .p_rx_buffer = (uint32_t *)raw_data,
					     .p_tx_buffer = (uint32_t *)raw_data};
nrfx_i2s_start(&i2s_buf, raw_size, 0);

The PCM raw data size is about 100000 bytes, I am not sure whether nrfx_i2s_start has a buffer size limit.

In addition, I found that the sound is worse if p_rx_buffer is set to NULL.

Since I only want to play once, I did not use nrfx_i2s_next_buffers_set to set the buffer for the next transmission.

I'm very confused about the process of I2S transmission now. If there are any suggestions, I would be very grateful.

Related