Speed in outputting WAV/MP3 files

Hi! I am looking for some help for the audio output of a digital instrument project. When one of 4 switches is triggered, based on which switch and some extra button inputs, the related audio sample should then be outputted(I don't really care if its mp3 or wave). Because it is part of a digital instrument I want the delay to be as small possible and I am wondering what components or methods to use.
While I am ideally looking for options that involve simple/minimal coding and are cheap, my main priority is that there will not be a (hugely) noticeable delay between triggering the note and hearing it.

The instrument has 4 trigger switches and so needs to be able to play up to 4 notes simultaneously. This seems to be a big issue and as I am a huge beginner, I am more than happy to just process and output the 4 switches separately, even with separate mini speakers if necessary, to avoid things getting complicated.

Here are some options I have found:

adafruit audio fx soundboard 2MB

  • ~£15 a bit expensive if I'm gonna need 4 but we have a pretty high project budget so can get away with it
  • sound delay on specs of ~120ms for WAV which is pretty okay
  • seems very simplified and user friendly, would only need an arduino for the simple signal management (combining the switch and button inputs) and not the actual audio stuff. Then I don't have to stare at code for a couple hours trying to remember how in gods name C works

DFPlayer mini

  • £2.50-£5, much cheaper
  • no details that I can find anywhere on its speed specs but seen in a couple forums of people complaining that its slow
  • only skim read this part of specs but I think it would need arduino and setting up manually

Home brew MP3 player with arduinos and SD card module

  • really can't imagine this is the most fast or efficient way of doing it (especially 4 times) but thought I'd mention it

I'm really not well versed in modules or shields at all, I'm sure there are much better options available and presumably many other MP3/audio player type modules?? So any help or suggestions to help me weed through the options- or different methods all together!- would be very much appreciated.
As an FYI, I have access to one leonardo and a bunch of nanos.

Based on your requirements, the Adafruit Audio FX Sound Board seems like a good option since it is user-friendly and has a relatively low delay. However, if the cost is an issue, you may want to consider using the DFPlayer Mini or building your own MP3 player with an Arduino and an SD card module.

The DFPlayer Mini is a low-cost option, but as you mentioned, there are concerns about its speed. One solution could be to use one DFPlayer Mini per switch, which would allow you to play up to four notes simultaneously. You would still need an Arduino to manage the switch and button inputs, as well as to communicate with the DFPlayer Mini modules.

If you choose to build your own MP3 player, you could use an Arduino with an SD card module and a speaker. You would need to write some code to read the audio files from the SD card and play them through the speaker. This option may be more time-consuming, but it would allow for more flexibility and customization.

Another option to consider is using a dedicated audio board such as the Adafruit MAX98357 I2S Class-D Mono Amplifier. This board can be connected to an Arduino and a speaker, and can play audio directly from the Arduino using the I2S protocol. It is relatively low-cost and has a low delay, making it a good option for a digital instrument project.

Ultimately, the choice depends on your specific requirements and constraints. If cost is not a concern and ease of use is a priority, the Adafruit Audio FX Sound Board may be the best option. If cost is a concern, but you don't want to sacrifice too much on performance, using multiple DFPlayer Mini modules may be a good option. Finally, if you want more flexibility and customization, building your own MP3 player or using a dedicated audio board may be the way to go.

@hiibrarahmad Wow thank you! I really appreciate this response.

With respect to this, if it is connected 'directly' to the arduino, does that mean that the note audio samples would have to be stored directly on the arduino? I don't think it would have enough memory for this. And presumably outsourcing to external memory would increase the delay?

You are correct that storing the audio samples directly on the Arduino may not be feasible due to the limited memory available on the microcontroller. It is possible to use an SD card module to store the audio samples externally, but as you mentioned, accessing the data from an external memory source such as an SD card can increase the delay.

To mitigate this delay, you can consider using a buffering technique, where you load a small portion of the audio data into a buffer on the Arduino and then play it while simultaneously loading the next portion of data from the SD card into the buffer. This can help to minimize the delay and allow for smoother playback.

Another option is to use a higher-end microcontroller with more memory or a dedicated audio processing unit that can handle the audio playback and storage more efficiently. However, these options may be more expensive and require more advanced programming skills.

Overall, it is important to consider the trade-offs between cost, performance, and complexity when selecting an audio playback solution for your project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.