Using Arduino to Digitaly Filter Audio.

That sounds more suited to my needs. Do you know of any good examples of using this algorithm?

None that I can publish :slight_smile: You will probably find some good code examples if you look for DTMF (touch-tone telephone) decoding as that's a common way to decode which buttons are pressed.

It is quite possible to use an Arduino, though you will need to do floating-point math (or be VERY good at implementing fixed-point algorithms). Basically, every time you read an A/D value from your audio you will run equations of the type:

y1 = inputvalue - 2*cos(theta)*y2 + y3;
y2 = y1;
y3 = y2;

So because of the floating point math and multiplication you cannot read new input values too quickly or the algorithm can't keep up, though 8 kHz should be doable (125us between samples).

The value theta is 2pik/N where N is the number of samples you're going to read before making a decision as how to energetic the signal is, and k is an integer from 0 to N-1 indicating which "bin" of frequency you're interested in.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

I fear this maths may be slightly to over my head and out performing my A level maths lol.

Do you, personaly, think it is best to use an arduino or can you buy specially designed digital variable filters?

Cheers, Phil.

Well, you can buy devices like the MAX275:

But these are "programmable" with resistors, so you'd have to fake it out with digital pots or such. And if your A-levels aren't up to understanding trig then reading the MAX275 datasheet won't be that easy either :wink:

Perhaps someone can suggest an all-in-one solution.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

Does anyone know any good informtaion about Switched Capacitor Filters? This seems the best choice, im just strugeling to find a good example. Cheers.

Here is a choice of switched capacitive filters:-

In general an arduino is not the best machine for implementing digital filter algorithms because of lack of floating point support. You are better going for one of the TI DSP chips.
However, if your maths are only A level then you are going to struggle big time. I did teach DSP to an MSc class years ago and they struggled with the maths.

Rats. Im really keen to use a switched capacitor filter, but cant find any good examples, or guides to help me.

My maths is good A level, but that is all, Sadly.

Cheers, Phil.

but cant find any good examples,

Have you downloaded the data sheets attached to the chips in the last link?
These will have recommended schematics in them which will be enough to get you started.
As you haven't mentioned what your application is, it is hard to recommend anything more specific. For example in the graph you showed a brick wall response, in practice this is not going to happen and you will get a slope. You also showed an unfeasibly large attenuation of unwanted signals.

Ye I downloaded the datasheet, im currently reading over it.

Ok here is my situation:

I need to build a device that plugs into a cars knock sensor to be able to listen for knock whilst mapping cars.

The knock is in the audioable range and sounds like a pinging or static hissing noise.

The knock sensor is a pezio sensor and has a peak output of around 30mV.

I need to be able to filter out all of the background noise bar the frequency of the knock.

Thanks, Phil.

OK that is a whole lot more complicated that the original question. You have two problems:-

  1. Remove as much background noise as possible
  2. Identify the noise when it comes.
    but:-

and sounds like a pinging or static hissing noise.

Pinging and static hiss noises are wide bandwidth noises, therefore you need a wide bandwidth filter. That is bound to add in a lot of background noise.
Next you have the problem of the pattern recognition of your noise, this is not at all easy and will be computationally heavy. Coupled that with the filtering you want to do and I don't think the arduino is the processor for this project.

I would proceed by getting a recording of your noise on some form of digital media. Then look at the waveform on an oscilloscope or do some analysis / graphs on the numbers. Try and spot the difference between the background noise and the sound. Only when you can spot it in the waveform will you be able to detect it in a program. However, you will need at least a knowledge of Fourier Transforms which the last time I looked is way beyond A level.

A appriciate your help.

Can I just clarify that I dont want to filter out everything but the pinging, I just want to be able to select that area of sound, even if it still contains noise (eg i might still hear alternator wine, but wouldnt here the injectors) etc.

I would just like to here to the region that contains the pinging, which can very from car to car, hence it having to be adjustable.

Cheers, Phil.

Yes understood. The problem is that the human brain is so good at doing those sorts of things you think it will be easy getting a computer to do it but it is not.
If you do a google search for "pattern recognition sound" you will see all the work and complexity that it involves.

Ok, so I may have bitten off more than I can chew :frowning:

Is there no filter chip that can be controlled digitally, eg by clock frequency or voltage? any sort of commercialy available chip?

I spent the last few days spending all day serching the net. I thaught Switched Capacitor filters were my answer?

Cheers Mike.

You need an 32bit DSP to do it, if you only want to pass a band of frequencies, you can use a band-pass filter made with op-amps or switched caps filters.

I understnad that. And actualy planned to use op amps originaly instead of RC filters, along with pots to adjust the cuttoff frequeuncys but wasnt sure if that was possible.

Cheers, Phil.

Is there no filter chip that can be controlled digitally,

Your on the right track with switched capacitive filters but it is the rest of the project that is a killer.

ok. I think I will just have to go back to basics and have a set frequency filter. Thanks for all the help mike.

Phil.

Hi!
There are several ways you can achieve this. First you need to know how tight you want the band pass filter. RC band pass filters are the widest band pass. LC filters will perform at 12dB per octave. Active filters (using OP amps) can achieve ever closer bandwidth 24dB per octave. You could use an OP build a band pass filter with several resistors and capacitors switched in and out by using a bi-directional switch such as a 4066. This type of switches has on and off line for each switch. The control lines for each switch are TTL compatible

I cannot figure out how to attach files to this. If you are interested let me know and I can e-mail you documents with schematic on each type of filters.

As a thought, I am planning on experimenting with analog in and analog out lines and filtering areas out by programming the 328

[timestamp=1284556183]

LC filters will perform at 12dB per octave. Active filters (using OP amps) can achieve ever closer bandwidth 24dB per octave.

A simple LC filter gives you a second order filter, that is 6dBs / per octave. An op amp with R & C gives you the same a second order filter.

To achieve 24dB per octave you will need a filter consisting of 4 op-amps.

Has physics chanced since I used to design active filters for the Admiralty Underwater Weapons establishment?

You are not talking about close in band performance here are you where you can achieve what ever cut of rate you want at the expense of long term stop band performance?

Would you like to see supporting documents? I have sipply offered my input.