Audio Play (MP3 or Wav file) with I2s MAX98357A codec

Hi,

I'm using nRF52840 DK with ncs V 2.6.0. I plan to create an mp3 or WAV audio player. I tried using the MAX98357A with the i2s nRF52840 DK board, building a project i2s example, and feeding converted sound data into a 16-bit array. The audio isn't clear. Can you help me how to play a wav or mp3 file using the MAX93857A codec? for file storing I am using external spi flash also required 
How can I configure the file system for Flash and need to read files from external flash and play audio files?

Thanks,

Parth

  • Hello,

    So you need to likely combine a flash example with an I2S example.

    For reading and writing plain data on an external flash, you can use this example for the nrf52840 DK. If you are planning to use a file system, you can use these file system examples as reference. If you are planning to use a file system on an external flash you can try to use littleFs. However, these examples do not specifically made for reading audio files from flash. You would likely need to implement additional logic to parse the audio file format (such as WAV or MP3) after reading the file data from flash.

    The nRF Connect SDK provides a few examples of how to use the I2S driver to play audio. You can for instance check out the I2S echo example: This sample demonstrates how to use an I2S driver in a simple processing of an audio stream. It configures and starts both the RX and TX streams and then mixes the original signal with its delayed form that is buffered, providing a simple echo effect.

    Kenneth

  • Hi Kenneth,

    Thank you for your reply. I've already tried the I2S echo example and provided sine wave data (found in some examples) to the TX stream. But I'm not sure how to convert such a file into a supported codec format, such as uint16 byte array, which i2s accepts. How to stream MP3 or WAV files in an uin16_t array. It would be more useful if there were a standard conversion function or an example available.

    Thanks,

    Parth

Related