Pages: [1]   Go Down
Author Topic: Multiple simultaneous sounds  (Read 936 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have a project that potentially needs to play up to 8 simultaneous sounds.

I plan to store short audio samples on my Arduino board's flash memory. I believe I can expand the flash memory if required. Am I correct in thinking the sound samples can be converted into ASCII hex and made into a PROGMEM table, that can be stored on the flash memory?

Then the Arduino triggers the samples that need to play and they are sent into some kind of digital hardware adder (I don't know the technical term for this component), that adds the sounds together in real time and sends them into a DAC. The reason for the 'adder' is because I don't think the Arduino itself has the processing power to make all those calculations without any time delay.

I'd also like to ask how to load/delete sound files from the flash memory. Is it just a case of including the converted ASCII hex into the code itself?

Please can someone help me get on the right track with this? Thanks!
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can look at our BeatVox product for inspiration. It basically does what you are trying to do. You can look at the software and tools associated with it for ideas on how to load sounds into Arduino FLASH memory.

--
The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you don't want to invest in some audio playing hardware you will be storing uncompressed samples.

The first question is: How much total audio do you need to store?

The second question is: How much audio bandwidth do you need?

Together those would determine how much storage space you need.  If you want phone-quality audio you'll need about six thousand bytes per second.  If you want music quality you will need more like forty thousand bytes per second.  If you have a minute of audio that comes to 360 Kb to 2.4 Mb.  The Atmega328p has  32 Kb of FLASH so it looks like there is no sense in even attempting to store audio there unless: A) Your total audio is very short and B) you don't mind crappy audio quality.  I think you should go straight to an SD card or, perhaps, an add-on EEPROM chip.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Edison Member
*
Karma: 8
Posts: 1250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sub'ing to thread.

I have a project in the works.. that I am hoping will play audio (.wav) files from an SD card.. to a LM386 amp/buffer/DAC

hoping to learn bits-n-pieces.. smiley
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for your help guys.

You can look at our BeatVox product for inspiration. It basically does what you are trying to do. You can look at the software and tools associated with it for ideas on how to load sounds into Arduino FLASH memory.

--
The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins


Thanks, I'll take a look now. It's good to know that this is possible.

If you don't want to invest in some audio playing hardware you will be storing uncompressed samples.

The first question is: How much total audio do you need to store?

The second question is: How much audio bandwidth do you need?

Together those would determine how much storage space you need.  If you want phone-quality audio you'll need about six thousand bytes per second.  If you want music quality you will need more like forty thousand bytes per second.  If you have a minute of audio that comes to 360 Kb to 2.4 Mb.  The Atmega328p has  32 Kb of FLASH so it looks like there is no sense in even attempting to store audio there unless: A) Your total audio is very short and B) you don't mind crappy audio quality.  I think you should go straight to an SD card or, perhaps, an add-on EEPROM chip.

Hi John,

Thanks for your reply. I was originally planning to use the waveshield for this project. However it does not support multiple sound files being played simultaneously. I was under the impression that this was due to the time taken to read data off of the SD card. Hence why I was hoping to store my samples on flash memory, maybe I have that wrong?

I am aware that I'll be requiring uncompressed samples, my samples are very small so hopefully it wont be an issue. The project is a drum sequencer with 10 samples. Only 1 sample will be longer than a second, the rest will be smaller than half a second. The total duration is less than 4 seconds and mono will be fine.

How much total audio do you need to store? 4 seconds

I would like as close to CD quality sound as I can get, although I'm happy to make a trade off if bandwidth is restricted. I'm afraid I don't quite understand the calculation you used for bandwidth. I guess it will be affected by how many samples are playing at once. I would ideally like 10 but can work with 3. Please could you explain how I calculate the bandwidth required?



« Last Edit: March 07, 2012, 08:54:36 am by loww » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Four seconds of audio at 42k 8-bit samples per second = 168k bytes of memory (1.344 megabits).  I was going to suggest an Atmel SPI EEPROM chip but they only go up to 65k bytes (less than half what you need).  Perhaps the 2-Mbit (or larger) Atmel DataFlash chip (AT45DB021D) would do the trick.  DigiKey.com has them for $1.08 each.  A 16MHz Arduino can do SPI at 8MHz so I would think that would be fast enough for simultaneous audio samples.  You will need to write a sketch to load data into the FLASH but after that you can treat them as a big ROM.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: