Welcome, Guest. Please login or register.

Author Topic: Is this feasable?  (Read 3983 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Is this feasable?
« on: July 13, 2003, 09:25:05 PM »
Hi all,

Whilst working on something today, I had an idea I thought I'd bounce off people here.

I was recording some sound and cleaning it up. Then I had an idea.

Many moons ago I wrote a simple FIR bandpass filter for samples based on example source in a Zilog DSP evaluation kit. It simply cuts frequencies above and below the range you specify.

I started thinking. If you split a sample into windows and analyse each window with a fourier transform to identify the regions containing the most frequencies, could that not be used to program the FIR filter automatically?

Basically an adaptive filter of sorts that cuts the top (and bottom) frequencies based on an intensity threshold.

Overlap the windows and gradually modify the FIR response curve and you might get a very nice adaptive noise filter for samples...

Has anybody here done anything like this already?
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #1 on: July 14, 2003, 12:47:59 AM »
What I meant by modifying the FIR filter was calculating the coefficeints based on each unique window - ie each window is filtered seperately based on the low and high frequency limits determined by the FT analysis of that window.

I also imagined that to avoid sharp changes in the filtering across windows, the windows could be overlapped say 50 % with a crossfading function of some sort.

Ie window 0 is from sample 0 - 1000, window 1 is from 500 to 1500, window 2 is from 1000-2000 and so on.

Each window would be seperately analysed and filtered and the output mixed together with a crossfade.

At least that was the thought :-) DSP isn't my strongest area...
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #2 on: July 15, 2003, 01:22:33 PM »
Right, lets see

My basic assumptions were as follows

1) We analyse a window of sound to get the frequency spectrum for that window.

2) We identify the lowest and highest frequencies for which the intensity (contribution to the overall signal strength) is greater than a threshold set by the user.

3) We use those frequencies as the limits to build an FIR filter and process the original window samples to eliminate as much of those frequencies above and below as possible.

By doing this for each window in the sample we get an adaptive filtering for the sound as it changes over time.
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #3 on: July 15, 2003, 11:43:03 PM »
Hi Matt,

Quote

Still not sure what effect you're tring to achive!!!


Oops!
 
Ok, its an adaptive noise filter that depends on the signal itself.

-edit-

It's pretty much what Wittgenstiend described in that latter post

-end edit-

Instead of uniformly removing set frequencies from a whole sample (as JoannaK mentioned) it does analysis of the sound as it changes over time (by using Fourier Analysis on windows of a certian size).

The analysis determines the frequency region (using an intensity threshold) where the signal is located and uses these parameters to build a FIR filter pair (high and low pass) to eliminate the frequencies above and below the signal region.

By splitting the sample into windows, the filtering adapts over time (each window is seperately analysed and filtered).

I was thinking to make a realtime double buffered setup for this (using very small windows of a few milliseconds) to clean up live inputs such as guitars and mics and the like...
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #4 on: July 16, 2003, 12:31:54 AM »
Quote

Wittgenstein wrote:

4) Develop some kind of method to change the parameters of the filter as a function of time (position). This is probably the hardest part and it depends on the windowing technique we want to use. It is important that the filter parameters doesnt change too much (highly nonlinear filters can give rise to unwanted results).



I was planing to cheat on this part by using overlapping windows and a crossfade :-)

So each window is discretely analysed and filtered as a finite sample. The output has a fade in (beginning to centre) and fade out (centre to end) volume envelope applied and is mixed from the middle point of the previous output.

The fade out of the previous output window will thus overlap with the fade in of the current one (the 50% overlap I mentioned earlier).

This way we remove the complexity of a true time dependent filter and approximate the desired effect.

-edit-

I should point out that that this is just an idea I have bouncing around at the moment but cant afford to work on it just yet...
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #5 on: July 16, 2003, 01:14:51 AM »
The idea as I imagined it was that the filter would behave as if it were smoothly gated. Sudden changes in filter response would be smoothed away via the crossfade.

So considering your example again:

lets say our window size is 1000 samples and we have a 50% crossfade.

We have 1000 samples of f1 followed by 1000 samples of f2

A) We analyse input samples 0-999, get a filter that passes only f1 and apply (to a copy of the samples). The result 1000 output samples are faded out from 500-999...

B) We analyse input samples 500-1499, get a filter that passes both f1 and f2 and apply (to a copy). The resultant output samples are faded in from 0-499 and faded out from 500-999. The result is then mixed onto A (starting at output offset 500)...

C) We analyse input samples 1000 - 1999, get a filter that passes f2 only and apply (to a copy). The resultant output samples are faded in from 0-499 and faded out from 500-999. The result is then mixed onto B (starting at output offset 1000)...

The effect is that the output just begins to pass f2 at 500 and just begins to reject f1 at 1000. The transition is gradual. In reality the degree of 'gating' would be user selectable.

For the example you set, a non overlapping filter would be perfect since we are dealing with a very specific case of 2 frequencies that change exactly on a window border.

In reality I want to process natural sounds such as instruments and speech for which sudden changes in the filter would probably produce unwanted effects.
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #6 on: July 16, 2003, 01:48:53 AM »
Quote

Wittgenstein wrote:

For example, at sample 749, you will get 50% of the signal filtered with a filter using the info of the first window, and 50% of the signal filtered with a filter using the info of the second window (that is the window from smaple 500 to 1499).


Well yes, but sample 749 (f1) will a mix of 50% from a filter that passes f1 and a 50% from filter that passes both  f1 and f2 (however there is no f2 present at this position yet)

So hopefully you'll still get 100% of f1 through at this point :-)

Quote

But I dont have any alternative method so it can be a good starting point to try it out.


Yeah. If I do get around to it I'll let you know how it turned out :-)
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Is this feasable?
« Reply #7 on: August 13, 2003, 02:10:20 AM »
@Wittigstein...

Been a while but I thought you might be interested to know that the idea sort of worked :-)

One thing I overlooked was the FIR filter algorithm has a N-1 latency in that for a 63 tap filter, you get 63 less samples out than went in - bit of a problem for the window length.

Some small corrections in the overlapping sorted that out, but I dont think the FFT is too accurate on smallerwindows..

Maybe I'll take another look later, right now I dont have the time  :-)
int p; // A