2
\$\begingroup\$

Having never worked with mic and speakers in the past, I am experimenting with these. I already made a simple circuit with a mic (electret condenser microphone) and speaker. I used the above mic with simple amplifier stage and then computer speaker. It works well.

Now, I am thinking of building a simple microphone, speaker and microcontroller circuit. The idea is basically to feed in the input from mic to microcontroller and then output the audio signal to the speaker.

For that I think I need to first convert the analog signal from the mic to digital values using AVR's ADC. After that I need to output the analog values to the speaker. Since this is my first time, I need advice on how to build a working circuit. What should be the sampling and playback rate? Do I have to worry about codecs, etc? (I don't know how large raw audio data can be.)

I am planning on using Arduino first since it's easy and quick for prototyping.

Any help is appreciated as always! :)

\$\endgroup\$
3
\$\begingroup\$

Your sample rate must be twice the maximum frequency of interest. This is the Nyquist–Shannon sampling theorem. If you want hi-fidelity audio, your maximum frequency is the limit of human hearing, about 20kHz. Human voice is less demanding: telephone networks work up to about 3400 Hz.

You will find that the AVR's ADC isn't terribly fast, and you don't have much resources to process the data. So probably, your hardware limitations will dictate the sample rate for you.

You probably don't need to worry about codecs. A codec encodes and decodes an audio stream. A common thing to do is compress the audio for more efficient storage or transmission, but it doesn't sound like you are doing either. There are codecs that encode and decode for reasons other than compression, but I can't think of any that would be relevant here. Your computing resources are very limited on the microcontroller anyway, and you won't have much time for encoding or decoding anyway.

\$\endgroup\$
  • \$\begingroup\$ Just read today-Arduino Uno has an ADC sampling frequency of about 10kHz max. \$\endgroup\$ – Jay Greco Jun 21 '13 at 21:18
3
\$\begingroup\$

If you use a 10bit ADC (most (or a lot) of MCUs have them) you could sample at 8kHz for basic audio/speech and output at the same rate. You could even output at half (or quarter etc.) the rate to get funky sounding aliasing effects.

If you are thinking of digital effects then you will need to store up to 100msecs of samples so you need to store and retrieve nearly a kbyte of data.

Keep to sampling input and output at same rate if your learning digital filtering or effect techniques for a start-off.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.