Which serial protocol to output audio using a DAC?

Hello,

I am trying to play (real) music using my Arduino Uno.

I use a DIY SD card module : https://nathan.chantrell.net/20111128/diy-micro-sd-shield-for-arduino/ . I store the audio file in a raw format (samples only, no header) in the SD card.
For the output, I use an I2C 12 bits DAC module MCP4725 and an LM386 based amplifier.
But I can not manage to output sounds above 2 or 3 kHz, which is much to slow for audio.
I have read on the web that it comes from the I2C protocol. Seemingly, a solution is to use a DAC with the SPI protocol.

My questions :

  1. Which DAC using SPI? I have found the 16 bits MAX541. Is this a good choice?
  2. I have also read in on the web esp8266 - DAC to play audio samples - Arduino Stack Exchange :
    “you should investigate I2S on the ESP8266. This is designed specifically for audio, although it's much harder to set up owing to the increased number of special clocks you need to provide ("master" clock, "bit" clock and "l/r" clock).”
    Is it worth trying to investigate this I2S protocol?

Thank you in advance for your help.

Is it worth trying to investigate this I2S protocol?

Yes, but not many Arduinos support this. It is just the things like the Zero and the MKR seriese, but the quality is better.

Why not use a .wav file, that is the same samples as a raw file but with the header giving the file length and the sample rate.

You tell if a chip has an SPI interface by looking in the data sheet or by using the filters you get on sites like DigiKey Mouser and Farnell.

Hello Grumpy_Mike,

Thank you for your answer!
I will follow your advice and go for a chip with a SPI interface.
Concerning the .wav file, I thought it would be easier with raw data and I have not checked on the web how to process the header. Again you are probably right!

Thanks.

I will follow your advice and go for a chip with a SPI interface.

Be aware that an SPI interface might have to be bit banged if you have an SD card being read at the same time.

Look at the code for the Adafruit wav shield for an example of this.

This is because the SPI interface on the SD card shuts down and closes the file when enable pin is un asserted. On the AVR type Arduinos this means the maximum sample rate is arround 22KHz

You should get a more capable board than Arduino Uno. Use a 32 bit board with proper I2S and support for DMA. Nearly all good quality audio DACs use I2S protocol.

SPI access to SD cards is also much better on faster 32 bit boards. For example, on Teensy 3.2 the SD card access by SPI is easily capable of playing 2 WAV files simultaneously at full 44.1 kHz 16 bit quality. To see a demo, skip to 9:06 in this tutorial video.