# Using a microcontroller as an audio mixer?

Discussion in 'Electronic Design' started by John - kd5yi, Oct 30, 2005.

1. ### John - kd5yiGuest

These questions are for my education rather than for an existing device.

I have a microcontroller containing an analog amplifier whose input can be
switched between pins of the micro. Suppose I have 8 audio inputs. The
amplifier has a gain of 1 and a 5 MHz GBW product. Suppose further that I
now select each of the inputs rapidly (at, say, a 40 kHz rate) so that they
are time-division multiplexed on the output. This is a low-fidelity thing.
There is a filter on the amplifier's output such that the signal is 6dB
down at 4 kHz.

Will it sound crappy? Do I need to mulitplex faster? My thought is that I
must switch at least 8 times faster than my highest audio frequency of
interest. Am I correct?

John

2. ### Guest

16 times faster. That is, each input channel must be sampled at least
twice the frequency of interest. This is the Nyquist frequency. Google
that up for an explanation.

Nyquist frequency is easy to remember since it is simply 2x(frequency
of interest). But this is the minimum really. The rule of thumb for
good sampling is 2.5 to 3 times the highest frequency you want to scan.

4kHz is good for sampling speech so you need to sample it at 8kHz
minimum. If you sample at 4kHz, the played back sound will only be 2kHz
in quality at best.

Also, I think just switching is not enough. You must read all 8 inputs
together every 125us (8kHz) and somehow 'merge' them. Maybe do some
averaging or take the highest value etc. Then output the result.

3. ### J. DavidGuest

I would say you should multiplex a little bit higher than twice the highest
audio frequency. But higher frequency multiplexing would help to filter out
more effectively the aliases if you use 6dB per octave filter.
And your sound will not be crappy as you said.

John

4. ### DonaldGuest

What is a little bit higher ??

If twice is 200% of the highest freq, is 210% OK or 300% a little bit ???

Thanks,

donald

I am not an audio guy or analog guy for that matter.

5. ### Guest

Like in my earlier post, my signal processing lecturers keep repeating
the usual rule of thumb of 250% to 300% of the highest frequency. Of
course, the more sample the better but you'd also need faster/more
capable hardware. And in terms of sampling for recording, you'll end up
with larger file sizes. But it all depends on your application.

For audio you can use even less than 250% since most people can't
really appreciate the tinny sound of the higher frequencies anyway. An
example of this is audible sound is roughly up to 20kHz and what most
people consider good sampling (CDROM, MP3 etc) is at 44kHz. That is
about 220%. Although I've seen recordings using 48kHz which is 240% of
human hearing range.

6. ### JoergGuest

Hello John,
With a uC a totally regular switching might not really work if it has to
do any other jobs (which it usually does). It's not impossible though.
Any imperfections in switching will modulate into the output, along with
some noise from its other innards.

Those SoC controllers have never floated my boat. First, they were
expensive. Then whenever I looked at the performance of the amps and
stuff on them I somehow had to yawn. Often a simple LM324 would run
circles around them.

Regards, Joerg