Pages: [1]   Go Down
Author Topic: Using Arduino to play 4 samples of sound  (Read 607 times)
0 Members and 1 Guest are viewing this topic.
Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Student - Game Developer - Entrepreneur
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone! I am very new to all of this, and wish badly for anyone to be kind enough and give me some expert advice on this matter.

In five hours I wish to accomplish the following:
I would like to create the code necessary for an arduino switch installation that does the following:
Have four switches. Each switch enable/disable one of four sound samples each. These sounds loop to infinity.

I wish to know what components to use, and functions I need to use, and also if there is a way to test your code without having an actual arduino board at the moment.

As a thank you, I'll update this thread with my findings, and make it an available case for the community.

PS: I've been googling about arduino emulators/simulators, and I've found software that constantly breaks.
I do know programming..

Sincerely, thank you!
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
Just this guy you know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that up too 4 samples at one time or 4 samples playing only one at a time?

Some links that may help you out.

http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
http://arduino.cc/playground/Code/PCMAudio
http://www.arduino.cc/en/Tutorial/PlayMelody
Logged

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

Your best bet would be the Adafruit Wave shield:
http://www.adafruit.com/products/94
Just attach the 4 buttons and modify the sample sketch. You may be able to achieve it in 5 hours.
Logged

Denmark
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Student - Game Developer - Entrepreneur
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much for replying to this thread.

None of these threads describe how to play a file one has, like if I wanted to play a wave or midi or something..
Maybe I library does that? I'll keep looking.

Do you have to purchase a board and components every time you have an idea you want to execute?
Is there simply no way to work on the program without having to purchase the hardware first?

Thank you for your help once again
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh you could do it in software only, but its going to be a royal ....

here is the basic idea

the arduino can really only have 2 states on a pin, on or off, a speaker is a analog device it can be anywhere tween fully out and fully at rest SO, what you would need to do is get your sounds, 8 bit, 11khz at best, chop off the wav file header and store it in rom (see progmem in the reference) these are going to need to be extremely short due to the limited space

next your going to need a carrier, something that keeps the speaker about in mid flux so plan on generating ~22khz or so, or else your going to hear a high pitched squeak, but not so fast or slow that the sound is going to be played back too fast or slow .. or at all

then your going to need to write up a software DAC, 4-8 bit to convert the data from binary form to an analog value and have that output as PWM on your carrier all while not using every single ounce of power in the chip

not impossible but not exactly a "going to whip it out in 5 hours" type of deal, especially if you have never reproduced audio on this low of a level on this limited hardware

good luck


and no if you think your going to use hardware there is nothing stopping you from going ahead and writing software, though you wont fully know if its working until everything is in place
« Last Edit: January 21, 2012, 10:45:44 pm by Osgeld » Logged


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

Quote
Is there simply no way to work on the program without having to purchase the hardware first?
You can work on the software, even write the functions on paper, but you will never know if it really works.
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
Just this guy you know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there simply no way to work on the program without having to purchase the hardware first?
What your trying todo is not simple so extra hardware is needed to manage the complexity.
If you want some simple beeps or buzzs then you don't need extra hardware.

The memory space on an Arduino Uno is 32kB  -0.5kB for boot loader.  
Your program could easily take up 20kb,  so you would only have 10kB for samples.
A raw 8bit audio sample running at 8kbps means you have space for 10 seconds.
So your 4 samples can not exceed that 10sec limit.

This example is what your looking for http://arduino.cc/playground/Code/PCMAudio
So you will need to convert your wave samples to PCM and then export it into ascii format for including into your code.

A bit of work but it only costs your time.



 
« Last Edit: January 22, 2012, 12:15:30 am by hellonearthis » Logged

Pages: [1]   Go Up
Jump to: