Go Down

Topic: Play multiple audio files? Polyphony? (Read 170 times) previous topic - next topic

TobiasRipper

Sep 22, 2016, 05:28 am Last Edit: Sep 22, 2016, 06:02 am by TobiasRipper
There's a project that needs to have more than one audio file to play at the same time > music and sound effects triggered by an arduino. I've been looking at this:

Mini MP3 Player Module

It only plays a single audio file at a time though (monophonic) and to get poly, I'd need to make an analog mixer circuit and have several of these run at once.

Are the any polyphonic (multiple simultanious voices) solutions out there?
Habeeb!!! Clean up on aisle four!!!

Grumpy_Mike

Quote
Are the any polyphonic (multiple simultanious voices) solutions out there?
Never seen one.
There is a library that will do more than one audio file but the quality is low.

TobiasRipper

Never seen one.
There is a library that will do more than one audio file but the quality is low.
Ah I see. That's unfortunate. There is indeed also the limit of only having one file open at once if a barebone arduino is used to produce the sound.
Habeeb!!! Clean up on aisle four!!!

Grumpy_Mike

Quote
here is indeed also the limit of only having one file open at once
That is true. This is the link I was talking about:-
https://github.com/TMRh20/TMRpcm
This gets over that by reading sections of a file into buffers and playing from the buffers.

TobiasRipper

I guess I might have to go with multiple audio modules then. I wonder if there is a way to wire 2 or 3 of the player modules to read from the same card as long as they are not reading the same file?
Habeeb!!! Clean up on aisle four!!!

Grumpy_Mike

Sorry but no. The one file only is a restriction of the SD card technology, nothing else.

TobiasRipper

Do you by any chance know if an Attiny has enough memory to play audio from a buffer?
Habeeb!!! Clean up on aisle four!!!

CrossRoads

Ha ha,
Attiny2313: 128 Bytes Internal SRAM
Attiny 24/44/84: 128/256/512 Bytes of Internal SRAM
Attiny 25/45/85: 128/256/512 Bytes Internal SRAM

Atmega328P: 2Kbytes SRAM
Atmega2560: 8K bytes SRAM
Atmega1284P: 16 Kbytes SRAM

8-bit audio, 5K max frequency playback for 1 second: needs 10 Kbyte SRAM
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

#8
Sep 26, 2016, 04:57 am Last Edit: Sep 26, 2016, 04:57 am by CrossRoads
You can have one Arduino command several MP3 modules via serial commands and have each module playback a different file from its SD card:

http://www.mdfly.com/search.php?search_query=mp3
Mix the outputs into an analog mixer, can be as simple as having outputs combined thru 10K resistors into a Computer speaker, see this schematic:

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Paul Stoffregen

#9
Sep 26, 2016, 12:14 pm Last Edit: Sep 26, 2016, 12:39 pm by Paul Stoffregen
Sorry but no. The one file only is a restriction of the SD card technology, nothing else.
Oh Mike, you should know better than this.

With a more powerful board and more sophisticated library design, of course 2 or more files can be played simultaneously from a SD card.  My audio library for Teensy does it easily, with two stereo files at 44.1 kHz sample rate.  Here's video evidence, if you or anyone else is skeptical (start viewing at 9:06, if this link doesn't automatically begin 9 minutes into the video).

https://youtu.be/wqt55OAabVs?t=9m6s

The restriction isn't SD card technology at all.  It's the limited performance of 8 bit AVR and its lack of sophisticated peripherals & DMA, with well designed libraries to efficiently stream with those peripherals.

When your processor is just barely fast enough to read one audio file and it consumes nearly 100% of its CPU time (and most of its RAM) doing so, without any way to efficiently process and output that data other than tightly synchronized to output the samples as they're read, then of course you can't play more files simultaneously.  But that's not the SD card technology holding you back.  It might seem that way if you only ever work with such very limited microcontrollers and fixed-function modules which support 1 file at a time (or the simplistic example code Arduino publishes for Due & Zero), but in fact that very capable SD card is just sitting there responding to the very slow read speed and limited software of regular AVR-based Arduino.

So much more is actually possible with SD cards, and audio in general, when using more capable hardware.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy