Audio playback (prerecorded audio)

Hello, I'm providing two versions of my problem, in order not to bore whoever is trying to help.

Short version How can I possibly play some wave/sound file (data stored onto an external EEPROM/flash memory) using arduino (and a speaker)? The best way would be not to use a shield if possible. Thanks

Long version Well a friend of mine told me he'd like to add audio effects to a costume he's going to wear on his cosplay on hallowe'en. Before trying and make this wearable, I'd like to master some of the techniques with the arduino, and later shrink everything to a bare Mega or Tiny chip, and try that. The problem is that the only thing I know regarding the topic, is chapter 18 of Make: Programming AVR, which I certainly do not master, and which I have to strongly modify to meet my "use-case". I'd like to know if there is a better way to do this, and what am I expected to do/know.

Thank you so much

Short answer - you can write code to create some noises, but there is not enough memory to store a sound file. Audio sampled at 8 bits and a playback rate of 8000 samples per second (perhaps sounding a bit like a telephone) will need 8000 bytes per second. So with a 328P you'd have a max of 4 seconds of sound stored, and then write code to send that to an 8-bit DAC based on button push.

Long answer - use something like an MP3 sound module to play back files from SD card. A Promini can easily control one with just a couple signals typically sending serial commands, and sounds can be as long and as high quality as you want.

CrossRoads: Short answer - you can write code to create some noises, but there is not enough memory to store a sound file. Audio sampled at 8 bits and a playback rate of 8000 samples per second (perhaps sounding a bit like a telephone) will need 8000 bytes per second. So with a 328P you'd have a max of 4 seconds of sound stored, and then write code to send that to an 8-bit DAC based on button push.

Long answer - use something like an MP3 sound module to play back files from SD card. A Promini can easily control one with just a couple signals typically sending serial commands, and sounds can be as long and as high quality as you want.

Thanks, I'll look into this, especially the long answer!

ilfuria: How can I possibly play some wave/sound file (data stored onto an external EEPROM/flash memory) using arduino (and a speaker)? The best way would be not to use a shield if possible. Thanks

Simple low-quality audioplayback is based on 8-bit PCM with 8000 samples per second, so you have to privide this:

Minimum EEPROM size in bytes = total playing time in seconds multiplied by 8000.

Please be aware that EEPROM sizes in "kb" DOES NOT mean kilo bytes, but kilo bits only! (8 bits = 1 byte) So a 256 kb ("kilo bits") EEPROM can only dstore 32 kilo bytes = roughly 4 seconds total playing time of 8KB/s PCM sound.

And the continous read rate from the EEPROM must be at least 8000 bytes per second.