1

I am working with Arduino which activates a box which is similar to a Skinner Box. Some of the output sound stimuli are sine waves with duration of less then 5 milliseconds. I output the sounds using the MP3 module DFR0299.

However there are too much problems using this module: it seems like the module has a wakening delay of around 100 ms, so it is not working well with this duration and below (the response time of the module is important).

So, I was thinking of buying a better module. However, I am far from being an expert in these things..

I can look for other modules in the internet, but, just from looking at the datasheets, I cant tell if the quality of the module is what I need.

I would be grateful if any of you could give me names of modules that might feet my requirements (or even advice me at what to look in the datasheets)

Thanks!

3
  • 1
    Why do you want to use MP3 for this? Are your sounds complex or just simple sine waves? (The complexity of the sound is rather limited in a time of 5ms) In that case it is easier and faster to generate them on the Arduino without using something as complex as MP3
    – chrisl
    Commented Jul 29, 2019 at 19:27
  • I think the OP is referring to a hardware module for replay of the mp3 file, which effectively uses arduino only as a control mechanism rather than a processing device.
    – Mark
    Commented Jul 30, 2019 at 5:09
  • @chrisl, for now I use simple sine waves using a function generator, triggered by the Arduino. However, in the future I will need to switch to more complex waves.. Thanks
    – user135172
    Commented Jul 30, 2019 at 10:01

2 Answers 2

1

I'm going to suggest that you stay away from these mp3 modules. It is perfectly reasonable to use a stand-alone arduino unit to directly generate sound using the digital output pins with a low-pass filter RC circuit. This is the most efficient way of doing this and will give you a very low activation latency.

https://playground.arduino.cc/Code/PwmFrequency/

The other option is to connect a DAC circuit and simply build a sample table for the wave outputs you need for each tone.

1
  • OK thanks I will have a look. I tried a similar thing (I think), I created the basic arduino square wave and added resistors and capacitors to "smooth" it to a sine form, But somehow the result (shown in the scope) looked very noisy.. maybe will give it another shot. Thanks
    – user135172
    Commented Jul 30, 2019 at 10:04
1

MP3 modules are way to complex for this project. Tracks of 5ms at max may even be stored directly on the Arduino in raw wave format (without any compression)(depending on the resolution and sample frequency), and then outputted by it.

Since the PWM with low-pass filter method is rather noisy and not very accurate (especially for higher frequencies), you may want to use an external DAC chip. These are available with parallel input port or with SPI. I would suggest using SPI, which is fast and does only need 3 pins (+1 for slave select, if needed). Put the raw wave values into an array and send them to the DAC to output. Depending on available memory and number and size of your tracks you may be able to save them directly on the Arduino. If not, you may want to use an SD card, to save a library of tracks, which then get loaded onto the Arduino and played. This way you would only need to hold 1 or 2 (if double buffered) tracks in the Arduino's RAM.

1
  • If you have an Arduino with a SAMD21 on it: I have written a small library for doing just that using the built-in DAC. Early days and version yet, but it works. It's here and it's free: github.com/ocrdu/Arduino_SAMD21_Audio_Player
    – ocrdu
    Commented Sep 4, 2020 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.