Audio filtering

Hey guys,

I'm in the process of building up a prototype for a project at the moment and I'm after a bit of advice from you more knowledgeable folk.

I'm currently working on a subsystem that reads in an audio signal (0-10kHz) and band pass filters a certain frequency range (yet to be determined), say between 4kHz and 8kHz.

I'm unsure if I should go down a hardware filtering route or digital filtering? I have my doubts that an Arduino would be capable of real time audio filtering, so I'm leaning more towards the hardware filter but thought I'd jump on and get some other peoples opinion.

Any tips/points/words of advice are greatly appreciated, thank you very much for your time.

There are a few "issues" that could make a hardware filter or different processor more appropriate. You can get special-purpose filter chips, or you can make filters with op-amps, or you can use DSP chips (or a computer).

People have made some nice audio spectrum analyzers using FFT (or FHT) and you can Google to see what's been done. But, I have a "feeling" that they are not processing audio continuously.

I'm currently working on a subsystem that reads in an audio signal (0-10kHz) and band pass filters a certain frequency range (yet to be determined), say between 4kHz and 8kHz.

Then what? Do you need the analog audio out? The regular Arduino doesn't have a DAC.

The (regular) Arduino's ADC is only 10-bits and above a certain sample rate (maybe above 14kHz?) you loose resolution. If you want to dig into that, check the ATmega datasheet. 10kHz would be "pushing it".

And in case you don't know this, the audio/signal is limited to half the sample-rate. Also from sampling theory, if there are signal frequencies above the Nyquist limit (half the sample rate) they have to be filtered-out to prevent aliasing (false frequencies). So if your audio is not otherwise frequency-limited (and if you need quality/accuracy) you need a hardware filter in front of the ADC. (So that kinda' defeats the purpose of trying to do it all in software.)

And if you need analog-out, might also need an analog "reconstruction filter" following the DAC. You're supposed to have one, but I was looking at the output from my "cheap soundcard" on an oscilloscope once and I was surprised to see very-clear stair-steps. (The sound was fine... At 44.1kHz or higher the harmonics are above the audible range and the speaker will act as a "mechanical" filter if those squarish waves get through the amplifier.)

You might want to have a look at switched capacitor filters. They are easy to implement with a few additional components, and can be controlled from an Arduino's timer outputs.

The basics are described on this page here:

http://www.swarthmore.edu/NatSci/echeeve1/Ref/FilterBkgrnd/SwitchedCap.html

I'm currently working on a subsystem that reads in an audio signal (0-10kHz) and band pass filters a certain frequency range (yet to be determined), say between 4kHz and 8kHz.

To emphasize the above points you MUST sample the input at a frequency of 20 kHz or greater, and make certain that no signal content with frequency above one half the sample frequency is present in the input.

To accomplish the latter you will likely need a good low pass filter between the signal source and the Arduino input.

Hey guys, I really appreciate the hasty replies!

I know a bit about signal analysis, understand Nyquist theorem and whatnot from my signal analysis courses. Though I don’t need to audio output, only need to know what frequency is approximately lies, so I could get away with a lower sampling frequency.

So what this subsystem is doing is essentially setting off an alarm if a signal is heard between a certain frequency band.

Sampling at around 100Hz will probably give me enough resolution to determine whether a signal lies within a certain bandwidth.

I essentially want something like this:

if (sampledFreq) >lowerBound && <upperBound {
PIN5 = HIGH;
}

and then when PIN5 is high, that will trigger another event.

If you need to make an FFT, you can do that with this Library:

If you need to make some digital filtering over an audio signal, this tutorial may help you (Google translate is your firend):

http://www.f-legrand.fr/scidoc/docmml/sciphys/arduinodue/filtrage/filtrage.html

The FFT tells you how much energy is in each of the frequency bins. A white-noise signal has equal energy in all bands. A loud white noise will have high energy in your detection band, setting off your detector. But a human listening to it will just say "That's a loud noise and definitely NOT the frequency I want."

So how you detect the frequency of interest is very important. What is it about this signal that the computer can identify to the exclusion of other noises?

Pretty much anything you can dream of can be done with digital filtering. That's how telescopes are now able to see planets around nearby stars - the human eye can't see Mercury in its orbit near our sun so just imagine looking at a sun many light years away and spotting the planet. So the usual method is to do the minimum analog filtering to get under the Nyquist limit and then do everything else on the digital signal.

The Teensy series can be programmed with the Arduino IDE and there is a very neat system online for designing audio processing programs for the Teensy. I would start there.

Sampling at around 100Hz will probably give me enough resolution to determine whether a signal lies within a certain bandwidth.

Shows that you don’t

understand Nyquist theorem

Sampling at that frequency can only tell you about frequencies BELOW 50Hz.

I would use a tone detector chip for this.