0
\$\begingroup\$

I would like to play multiple audio samples (wav files) simultaneously using an Arduino microcontroller. Is this possible by use of external (audio procesing) hardware?

I read about the Adafuit Wave Shield:

https://www.adafruit.com/products/94

But from what I could understand, it seems possible only to play one sound at a time using this board.

What is a good way to playback multiple sounds simultaneously using Arduino?

\$\endgroup\$
  • \$\begingroup\$ You can add the wav sample by sample (signed) and the result is a mixed wav. Make sure you have enough digital head room in the wav's to prevent clipping. \$\endgroup\$ – jippie Nov 11 '12 at 4:39
  • \$\begingroup\$ Thanks. I am wondering if the Arduino will be able to keep up, as the start times of the samples will be different, and this cannot be precomputed. The Arduino has to do other things as well, like monitor sensors. There is a max of 5 audio samples. This is why I was looking at external hardware. \$\endgroup\$ – M-V Nov 11 '12 at 4:52
  • \$\begingroup\$ Do you mean you have 5 prerecorded sounds you wish to play together, with varying start times? \$\endgroup\$ – Oli Glaser Nov 11 '12 at 12:11
  • \$\begingroup\$ @OliGlaser - yes. And the start times are triggered by 5 sensors. \$\endgroup\$ – M-V Nov 11 '12 at 13:28
  • 1
    \$\begingroup\$ Realize that the sum cost of an Arduino + wavshield is more than something like a Raspberry Pi which has orders of magnitude more memory. Though getting basic audio output from a pi is surprisingly complicated. \$\endgroup\$ – Chris Stratton Nov 11 '12 at 18:19
2
\$\begingroup\$

The AVR microcontroller used on Arduinos is easily fast enough to do the audio mixing. The problem will instead be reading the data from SD. The SD protocol permits reading only in sector sizes (512 bytes on current cards), and you generally don't have much RAM to store the data in. At 22kHz 16bit mono audio, that corresponds to 11.6ms so you can probably permit joining the samples on a sector basis, but that still means reading 430 sectors per second over an SPI port that cannot do DMA. It is absolutely possible but may present a notable coding challenge. If your set of samples is fairly small and static, it could be better to load them into an SPI NOR flash which is more easily read.

\$\endgroup\$
0
\$\begingroup\$

Use a more powerful micro-controller with audio shield. An example is a Teensy 3.2 and it's audio shield can do simultaneous playback and mixing of multiple sound files. Better yet, they're arduino compatible so you can use the same programming environment.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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