Sound Messages with AVR MCUs

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey all,

Please i would like to ask about some matter which i need to achieve and i miss some data which i wish to acquire from your experience.

I want to store some sound messages on the memory of an AVR mcu and then make a program which makes some sort of control and outputs these sounds for different cases ..

The questions here are :

1- how can i store a sound data on the memory (flash or eeprom) ?! - i mean i need to know the sound structure first

2- is the microcontroller is capable of doing such task (knowing that the sound length is no more than 10 secs) ?! and if not, why and what are the alternate solution !?

Thanks in Advance,

Ahmad El-Saeed

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1) I've done something along these lines. I actually store ADPCM encoded sound data in an AT45 Dataflash attached to the AVR but it could just as easily have been just raw PCM (though I wouldn't fit so much in, in that case). I'm effectively just using 8bit samples.

2) Sure it's capable. Because I'm using ADPCM which needs to be decompressed at playback time and because I'm just running the AVR at 8MHz I actually use 8000 samples per second for an audio range of about 0-4KHz. That is certainly fine for speech and actually delivers quality well in excess of telephone quality. However it might not be that great for "CD quality" audio. For that you need an audio range of 0-22KHz with samples at 44,000 samples per second.

Maybe you'd like to tell us more about the actual audio - is it music, speech or something else and what kind of quality level are you looking for 4KHz, 10KHz, 15KHz, 22KHz... ?

Cliff

PS With a chip like an AT45DB161D (16Mbit = 2MByte) and 8 bit PCM data with 8,000 samples per second you'd get 262seconds of storage. So for your ten seconds you could go for a much smaller flash chip and maybe increase to 16 bit samples (though the PWM you'll use to play it back won't be able to use all 16 bits) and a higher sample rate (maybe clocking the AVR faster if necessary - you need the PWM frequency to be WELL above the audio range so it can be easily filtered out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And as a second example, I've done PCM at 11kHz using 8bit samples. Sounds quite nice actually. I also stored my data in an at45 flash.

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Was that 11KHz sample rate or audio frequency (which, because of Nyquist, will be half the sample rate)?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

so .. how much memory i would use if i have for example 5 messaged and each message is 10 seconds ?!

and another request, if any one has a tutorial on the ADPCM please share .. as i am a beginner to this matter actually !!

and would a simple microcontrollers like mega16 or mega32 function properly with this type of applications ?!

Thanks in advance again

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mine was on a mega16 so definitely "yes" to that question.

As for ADPCM it's a possibly unwanted overhead but can help to save component costs as it means less storage space is required. (16 bit PCM is reduced to 4 bit so you can get 4:1 compression)

As for the device size. It's very easy for you to calculate this yourself. So you want 5 messages of 10 seconds. OK, that's 50 seconds.

Now you have to decide on the sampled audio rate. Like I say, for 4KHz audio range you need 8000 samples per second.

So 50 second * 8000 samples per second means you need room for 400,000 samples. The next question is whether you want to use 8-bit or 16-bit samples. For 8 bit then it's a sample per byte so that means 400,000bytes. For 16-bit it's two bytes per sample so you need 800,000bytes.

As memory devices go up in binary multiples (128K, 256K, 512K, 1M, 2M, 4M...) then if you went with 8-bit you could easily fit the 400,000 into a 512K memory chip. If you used 16bit you'd need to use a 1MB chip. But if you used ADPCM you could squeeze it to 1/4 of this and use a 256KB chip.

But your first decision is sample rate and 8/16bit samples. The rest comes from those decisions.

To make those decisions you probably need to make up a prototype first (and buy the biggest memory chip for that while experimenting) then try various sample rate and switch between 8 and 16 bit and see what you think sounds "acceptable".

Only worry about ADPCM later when you are concerned about the mass produced component costs.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
2- is the microcontroller is capable of doing such task (knowing that the sound length is no more than 10 secs) ?! and if not, why and what are the alternate solution !?

You can put phonetics in memory and produce speech, just like the old speechchips from the 70's / 80's.

RES

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Was that 11KHz sample rate or audio frequency (which, because of Nyquist, will be half the sample rate)?

That was sample rate.

And you might want to check out the file format for .wav files. It's a great way to get "samples" for testing. :lol: (you can imagine what kind of wav files I was able to download to test my circuitry)

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi RES
I played with the sound chips in mid 80's.
Maybe you can get english to work, but NOT danish!

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
Hi RES
I played with the sound chips in mid 80's.
Maybe you can get english to work, but NOT danish!

Jens

:? Yes. You have to record your own voice, and cut out the phonetics perhaps? Or search the net on Danish phonetics.. you might find something.
And Ahmad El-Saeed sounds like an Arabic name to me, even more difficult.

H-E-L-L-O W-O-R-L-D (in Danish)

RES

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

and another request, if any one has a tutorial on the ADPCM please share .. as i am a beginner to this matter actually !!

There's the Atmel application note AVR336: ADPCM Decoder. You can get it from the Atmel website at:
http://www.atmel.com/dyn/products/app_notes.asp?family_id=607

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

something to check out-
http://www.romanblack.com/picsou...

that's on my list of things to try.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Playing phonemes back to back without smoothing is going to result in horrible clicking and other noisy artifacts.

To hear it in action, download me ChipTalk software.

Ken
www.speechchips.com

www.speechchips.com
SP0256-AL2, SpeakJet & Text to Speech IC's