Pages: [1]   Go Down
Author Topic: audio input and output  (Read 1192 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[I realize that a micro-controller is not meant for audio processing]

I've wrote a simple program to do an analogRead and then pass that value to analogWrite. I expected to get a lo-fi version of input. I also tried to first divide the analogRead value by 4 to keep in in the range of values that analogWrite can output.

Neither gives me what I expect.

I get a lot of noise and a constant tone through-out.

Should this be working?

Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont think this will work.

if the tone you hear is around 500Hz it is most likely the PWM frequency.

How fast are you reading / writing the analog pins ? If i'm not wrong,  it would have to be several 1000 times a second to achieve something that would remotely resemble the input, and then there is the whole issue with scaling the values (divide by 4).  Add to that the fact that the analog out is PWM.
« Last Edit: November 12, 2007, 11:08:40 am by MikMo » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can actually sample fast enough to get audio in (although 1k or RAM is going to fill up in .25 seconds at 4k sampling rate), with PROGMEM you might get 1 or 2 seconds of sound.

As mentioned analogWrite is going to be useless for output though and you'll have to do some AVR coding to make this work.

David F at uchobby was working on this. You might email him and see if he has any code he could share.

PaulB
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey tr909,

if you don't need recording seacrh the forum for "resistor ladder". if got satisfying 4-bit audio thruput using 4 arduino pins hooked to 4 digital pins. i amplify the mic input with a single transistor. I tried doing audio recording but paul is totally right: 1k is nothing.
i didn't get very far doing any kind of "real-time" manipulation, but  something should be possible.

kuk
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And the PROGMEM is read-only, I think, although I've not tried writing to it.  You probably want external storage, e.g. using the dataflash library (though I haven't tried it, so I don't know if it would work well in this application).  You can also get chips that do audio recording and playback, and I'm sure there are lots that do signal manipulation.
Logged

Pages: [1]   Go Up
Jump to: