Using a microcontroller as an audio mixer?

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?

Thanks in advance for your replies.

John

Reply to
John - kd5yi
Loading thread data ...

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.

Reply to
slebetman

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.

Reply to
Donald

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

Reply to
J. David

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.

Reply to
slebetman

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

formatting link

Reply to
Joerg

The real problem with sampling not much above nyquist is not a problem of quality of the sampled representation, but rather the difficulty of building the necesssary ant-aliasing filters.

If you take a CD, 20khz max frequency and 44.1 khz sampling means a nyquist limit of 22.050 khz. Somehow you have to build a filter that passes everything at 20 khz and blocks (a sufficient fraction of) everything at 22.050 khz. That's a very tall order - such circuits implemented in analog introduce phase distortion and all sorts of difficulties.

To make filtering easy, you need at least an octave (2x frequency) between your highest desired (unattenuated) frequency and the nyquist limit.

But there is a way to cheat: you can sample at a much higher frequency, raising hte nyquist limit and making filtering easy. Then you implement a very sharp digital filter to cut off at 20khz, allowing you to safely decimate the sampling rate back to 22.050 khz. You can do this on playback to: digitally filter the samples to generate intermediate samples at a much higher frequency, output that, and filter at the higher nyquist limit of the resampled signal. This is good for keeping the sample storage or communication rate low. But you do have to have the ability to process at higher sampling rates - you can play games trading off sample frequency for sample resolution which keeps the task of fast a/d and d/a simpler though. Unfortunately, this trick probably won't help the original poster as his switching rate is software limited, and it seems like it's literally a switch - no capability to do DSP math on the audio data.

You can also decide you don't care about aliasing... If the switching frequency is higher than audible, you might even decide the result is tolerable for hobby projects.

Reply to
cs_posting

Thanks to all for your replies. I might give it a try one of these days.

Cheers, John

Reply to
John - KD5YI

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.