design help for choosing AVR for audio project

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

For my application, I only need about five seconds of audio to play from a speaker, but it has to be high quality, so I don't want to use a cheap microcontroller with a low sampling rate. It seems like the higher sampling rate microcontrollers that are good for audio have more capability than I need, and I want the microcontroller to be as cheap as possible. Any suggestions?
 

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

dontbyte wrote:
it has to be high quality

So what, exactly, does that mean?

 

The way to approach this is to define what you require in terms of storage, code, speed, cost, etc - and then look for parts which fit those requirements.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By high quality I mean at least a 32 kHz sampling rate...

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

By "sampling" do you mean the micro will be recording? (presumably using an ADC?).

 

Or are you just going to play pre-recorded samples that were captured using something else?

 

In either case the playback could be an issue - the temptation with AVRs is to fake a DAC using PWM through a filter but it's difficult to hit the sample rates you are talking of. So you probably need an R2R or a real DAC.

 

Another alternative is Xmega - they have DACs in silicon and can do reasonably high rates.

 

EDIT sorry, just realised this is in "General Electronics" - so it might not even be Atmel you were looking at?

Last Edited: Mon. Aug 3, 2015 - 06:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The audio will be a short duration, pre-recorded sound. I'm looking at Atmel but I'm not sure what the best option is and I'm open to anything that would be good for this application.

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

dontbyte wrote:
By high quality I mean at least a 32 kHz sampling rate...

That's still not saying much:

  • How many bits per sample ?
  • How many channels ?
  • Any MP3 or suchlike processing ?
  • etc, etc

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think 16 bits would be sufficient, single channel, the format doesn't matter...I'm looking for a general direction to know where to start, it doesn't have to be precise.

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

Is your gizmo recording the sound, then replaying, or is the sound clip canned, from some outside source?

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

dontbyte wrote:
I'm looking for a general direction to know where to start

So why are you even thinking about a specific chip at this stage?

 

The choice of chip is an implementation detail - you have a whole lot of analysis & design to do before you reach that point!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The audio will be a short duration, pre-recorded sound.

Now, this may not fit into your parameters.  But in several apps, we use an "answering machine" chip.  In our experience, it gives very acceptable voice playback in applications such as restaurant drive-up window greetings.

 

Search the forums for "nuvoton" or "winbond", and look for threads discussing the "isd" product line.  Also "chipcorder".

https://www.avrfreaks.net/forum/i...

https://www.avrfreaks.net/forum/v...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Playback of 44KHz is easy with almost any micro. Doing it at 16 bits resolution ( and being meaningful) is a whole different ball game... 10 or 12 bits is fairly simple and will give good results and be relatively easy to achieve. There's plenty of 10/12 bit SPI DACs out there, along with single chip digital filters. As said above, there's more to this than simply choosing a processor...

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

The gizmo will not record or do voice playback. It will just play a nature sound (to be determined, leaves rustling for example!) for about five seconds. It seems so simple it would be nice if just a single microcontroller could accomplish this, so if this is possible then the choice of chip would be the implementation...would a separate DAC really be necessary?

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

Try using only 8-bit samples.  Even at 15,000 samples per second, it should sound fine on a small speaker.    Where are you planning to store this 75,000 bytes of audio?  On a couple of serial EEPROMs?
 

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

I don't have experience with this, so I'm not sure how to answer! I guess my question is whether there is a cheap Atmel chip (or another suggestion) that is well suited for audio, and whether an external DAC is necessary...

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

Since its a 'nature sound', a 1 second loop could be played forever it you edited the loop cleverly. An Arduino mega has 256K of flash, so you could have a 6k playback program and 250k of data to play back in the flash. 8 bit sounds played back at 11KHz sample rate lets you have 22 sec of stuff to play back. Got an example of a couple of the sounds? If they don't have a lot of hi freq content, you don't need a hi playback sample rate.

 

Imagecraft compiler user

Last Edited: Fri. Aug 7, 2015 - 03:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I don't have sounds yet. As for the Arduino Mega, it seems overboard to have 54 I/O pins and 16 analog inputs since I only want to use about four pins in the project. I found this tutorial about playing sound from an Arduino: http://highlowtech.org/?p=1963 is there a better way to do this?

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

How about one of these:

 

Audio FX Sound Board + 2x2W Amp - WAV/OGG Trigger - 2MB diagonal view

 

https://www.coolcomponents.co.uk...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://elm-chan.org/works/sd8p/report.html
I built one in a few minutes using ATtiny45 and SD card adapter as socket for uSD.

It all starts with a mental vision.

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

So lets argue about processor selection based on these requirements: enough flash to hold and play several sounds at some bit depth and playback sample rate. Mega2560: good! has 256K of flash! Smaller AVR with an SD card: also good, if you can get the sd working. Much more complicated in my opinion, since I havent been able to get one working yet. (different compiler. Baaaaah.). You dont like the mega2560 because you are 'wasting' all those IOs and analog ins. I would agree if this was a commercial product idea where the cost of 10000+ AVRs gets pricy. Is this R&D and proof of concept or, almost ready for production phase? Adafruit has a music card that plays stereo 12bit at 44.1 I think on an uno. http://www.adafruit.com/product/94

 

Imagecraft compiler user

Last Edited: Sun. Aug 16, 2015 - 02:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The above suggestions are all good ones.

 

Another option, which would be my approach, would be t use an Xmega E5 with its built-in DAC.

 

I'd get the DAC up and running with some simple audio signals, (software sin wave, for example), and then look at the audio sample storage, (SD, EEPROM, etc.).

 

Know that getting "clean" audio on a small PCB next to a uC has a few underlying challenges.

You will need to pay close attention to your power supply, signal routing, and the layout of the amplifier.

I think 16 bits on a small, inexpensive, PCB is a bit over the top.

 

Start with the DAC on the Xmega and listen to the sound quality you obtain.

It doesn't sound like your project will require 16 bit quality.

 

JC

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

Ok, thank you for the suggestions!! I'll have to try things out...I can never seem to get away from Arduino! Right now I want a proof of concept, but I was thinking that it would be good to have something suited for production.

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

You're really going to have to start with hammering out this statement:

Quote:
but it has to be high quality
That is by definition a qualitative statement, requiring a qualitative measure.

 

Who is your audience?  What is the purpose of the device?  What precisely will the sound be?  My 'Music and Technology' professor back at school used the phrase 'Good enough to fool the cat' in reference to playback systems.

 

Who is the 'cat' here?  If he is a listener wearing studio-quality over-the-ear headphones fed by your gizmo, then 'high quality' will mean something very different from the 'cat' who is casually walking by motion-activated exhibit with a 2-inch speaker in a noisy art gallery opening.

 

I've hacked one of these by replacing the stock pcb with a custom pcb holding only a 328p and a 2n2222 to drive the built-in speaker.  Wrote code to convert any arbitrary WAV file into a C array to be included into my project code.  Sample-rate was computed based upon the length of the audio clip.   I could get about 4 seconds of 8 ksps 8-bit audio.  The quality was 'high enough' for 'my needs'.

 

So, what are 'your needs'?  Simply saying 'at least 32ksps' has no direct relationship to 'high quality'.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

dontbyte wrote:

The gizmo will not record or do voice playback. It will just play a nature sound (to be determined, leaves rustling for example!) for about five seconds. It seems so simple it would be nice if just a single microcontroller could accomplish this, so if this is possible then the choice of chip would be the implementation...would a separate DAC really be necessary?

 

The various Atmel (and others) ARMs support the I2S digital-audio interface, which is what pretty much all audio converters use. It's a simple three-wire interface. The processor may also be able to generate the modulator clock required by the converters, too. Trailing-edge DACs are probably a buck apiece, too.

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

DocJC wrote:
Start with the DAC on the Xmega and listen to the sound quality you obtain.
Olimex's XMEGA prototype board has audio in and out.

An alternate is to add an audio board on an Xplained Pro header.


www.olimex.com

https://www.olimex.com/Products/AVR/Proto/AVR-PX128A1/

http://www.atmel.com/tools/ATXMEGAA1U-XPRO.aspx 

"Dare to be naïve." - Buckminster Fuller

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

Not much options with a std. AVR.  Sigma-delta sounds a more realistic approach. 

With a bit of creativity, you may also emulate a fast PWM with a SPI stream and look-up tables.

You may also use oversampling and dithering to emulate a 13 or 14-bit ADC, but I doubt the AVR will be fast enough for that.

Get ready for some in-line assembly.

while(!solution) {patience--;}

Last Edited: Sun. Aug 16, 2015 - 04:06 AM