Using audio raw file in Arduino project

Hey there,
I have a new application I want to add some audio speech. I try to avoid using any library. So the audio data is stored in a raw file (unsigned 8 bit PCM, frequency of 8000Hz). I edited it with Audacity. The audio data was first displayed in ASCII (in text editor), then I converted it into a HEX array (hex values only comma separated) using an online ASCII to HEX converter. I stored the hex-data on flash in my Avr and use a R2R to convert them into analog values (one array index every 125 uS). The problem now is that the tone is not that accuracy. It's a little rushing and not so clearly. Can anyone help me? Is that the right way to convert and add the audio file to my Avr? I am looking to forward to your replies.

Best regards

Maurice

iciwi:
separated) using an online ASCII to HEX converter. I stored the hex-data on flash in my Avr and use a R2R to convert them into analog values (one array index every 125 uS). The problem now is that the tone is not that accuracy. It's a little rushing and not so clearly.

8-bit/8kHz PCM sound is a low quality audio only.
Sound quality is like on a telephone line about fourty years ago.
Good enough to understand human speech only, but NOT crystal clear high fidelity sound.

Did you try playing your data using the code provided here:
http://playground.arduino.cc/Code/PCMAudio

Is there a difference in audio quality using that code and connecting aspeaker directly to the Arduino output pin or using your R2R simulation of a DAC?

How does the 8-bit audio sound in Audacity? Of course, you're not going to get better than that. The R2R DAC might give you nearly the same quality if you follow the DAC with a good-active low-pass filter. (The 8kHz clock is in the audible range and with the "un-clocked" R2R filter you're going to get some nasty glitches when all of the output-pins switch with each new sample.)

I try to avoid using any library. So the audio data is stored in a raw file (unsigned 8 bit PCM, frequency of 8000Hz). I edited it with Audacity. The audio data was first displayed in ASCII (in text editor), then I converted it into a HEX array (hex values only comma separated) using an online ASCII to HEX converter.

You lost me there... The raw PCM audio file is already "hex" (actually binary) data.

You can read it as a "number" in C++ and "print" it as decimal or hex, but like all integers (and everything else in memory) it's stored as binary.

You probably don't need to use hex... i.e. Writing 0A hex to the DAC is the same as writing 10 decimal... If you do it right, they will both write 00001010 to the I/O pins.

And, you don't need the commas between the values... That's just wasting space.

The only difference between a raw file and a WAV file is the header. The [u]header[/u] is 44 bytes, and with an 8-bit mono WAV, everything following the header is just a sequence of bytes (unsigned 8-bit integers) representing the audio samples. You don't need the header (since the software knows the format), but the header takes-up less space than all those commas! :wink: