filter question -> theory & practice

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

hi out there,

i dont like the idea to borrow a code sniplet for my filters so i tried to understand the whole thing.

i read about filters in the "Digital Filter Designer's Handbook". it's quiet academic but i think i understood it.

thats what i got:
(you can correct me in any place)

1. a usefull audio stream filter can't use fft -> because we dont got the complete sound.

2. so we use sample by sample filtering. where you need something like a FIFO where the older inputs and outputs are stored (which are needed for the computation of the new output).

3. the recursion in the formula is the pole count of the filter (2pole=12db,4pole=24db etc.).

4. we need a IIR type filter. (?)

5. the implementation is strait forward.

BUT here the missing link

6. the filter coefficients a1..an, b1..bn have something to do with cutoff and Q. but the book doesn't explain the relationship.

(the bipolar intepolation calculates this things for a given cutoff band, but what about Q)

So my question goes about the practical meaning of these a's and b's.


i am confused, paranoid and sunburned. so help

Post

The way I understand filters is to think about what it is actually doing to the waveform. My maths isn't incredible, and I still don't really understand all of the complex transforms.

Anyway, basically A lowpass wants to reduce the fast changes in in the waveform, and leave the slower changes relatively untouched.

This property reminds me of a heavy object being moved - fast small movements tend to have little effect, but big slow ones tend to work better.

We could model an IIR lowpass filter in this way - by treating the waveform in a mechanical way, using acceleration, and damping. The velocity is persistant, as is the old value out of the filter.

difference = <new input> - <old output>
velocity += difference * acceleration
velocity *= damping
output = <old output> + velocity

The acceleration approximates to your cutoff frequency, and the damping approximates to the Q.

Post

texture,
This property reminds me of a heavy object being moved - fast small movements tend to have little effect, but big slow ones tend to work better.
Cool way of explaining an LPF :)

Paul
__________________________
Paul Chana
Senior Software Engineer
FXpansion Audio UK Ltd

Post

pragmatically, you are trying to use phase shifed (old) sample copies to cancel certain frequences and preserve, or boost, others.

the IIR coefficients would need to be different (recomputed, or fetched from a table) for *each* combination of frequency, cutoff, and Q.

I am guessing that the difficulty with digital filter is that you need to approximate all this with a fixed sample interval. this might make a smooth filter difficult.

another issue is handling the spectral phase shift that the filter introduces.

Post

texture wrote:The way I understand filters is to think about what it is actually doing to the waveform. My maths isn't incredible, and I still don't really understand all of the complex transforms.

Anyway, basically A lowpass wants to reduce the fast changes in in the waveform, and leave the slower changes relatively untouched.

This property reminds me of a heavy object being moved - fast small movements tend to have little effect, but big slow ones tend to work better.

We could model an IIR lowpass filter in this way - by treating the waveform in a mechanical way, using acceleration, and damping. The velocity is persistant, as is the old value out of the filter.

difference = <new input> - <old output>
velocity += difference * acceleration
velocity *= damping
output = <old output> + velocity

The acceleration approximates to your cutoff frequency, and the damping approximates to the Q.
congrats a very unorthodox approach indeed. a new perspective maybe.

did you tried to code this?

Post

pummel wrote: the IIR coefficients would need to be different (recomputed, or fetched from a table) for *each* combination of frequency, cutoff, and Q.
exactly. but look:

the filter has a passband + a stopband. as it is not an ideal filter it has a transition Delta f from passband to stopband (transition band). u can interpolate with delta f and the passband ripple and the stopband ripple the needed coeffs. the delta f is approx, the cuttof freq but where in the heck is the q (resonance). that was the question.

Post

pummel wrote:I am guessing that the difficulty with digital filter is that you need to approximate all this with a fixed sample interval. this might make a smooth filter difficult.
but, what is your alternative. computers for now work definitely digital, so everything mst have a finite discreet value.

in the past some computers actually where analog. (turing machine, enigma coder, targeting computers of ww2 subs etc.)

no, but realy how can i work the problem out.

Post

enfantTerrible wrote: congrats a very unorthodox approach indeed. a new perspective maybe.

did you tried to code this?
Yeah, it works (but it isn't an amazing filter):

Code: Select all

class Lpf
{
public:
	Lpf() : vel_(0.f), old_(0.f) {}

	inline float apply(float in, float damp, float mass)
	{
		vel_ = damp * (vel_ + mass * (in - old_));
		old_ += vel_;

		return old_;
	}

private:
	float vel_;
	float old_;
};
You could make it better by adding more stages to the filter, or oversampling by running it through with your value and then with a number of zeros.

I just understood it this way better than Z-Transforms and the like.

Post

texture wrote:
enfantTerrible wrote: congrats a very unorthodox approach indeed. a new perspective maybe.

did you tried to code this?
Yeah, it works (but it isn't an amazing filter):

Code: Select all

class Lpf
{
public:
	Lpf() : vel_(0.f), old_(0.f) {}

	inline float apply(float in, float damp, float mass)
	{
		vel_ = damp * (vel_ + mass * (in - old_));
		old_ += vel_;

		return old_;
	}

private:
	float vel_;
	float old_;
};
You could make it better by adding more stages to the filter, or oversampling by running it through with your value and then with a number of zeros.

I just understood it this way better than Z-Transforms and the like.
I see it has indeed very different approach. the other filters have a 2 time or a four time feedback (working w. 2 or 4 older values both for in and out). maybe you can integrate it than it could probably sound better.

cheers

Post Reply

Return to “DSP and Plugin Development”