Filter + DSP literature

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

Post

Hi people,

I'm pretty sure there has been already a discussion about this, but I can't find it at the moment.

Can anyone recommend a good book about how to develop filters? A cookbook or whatever?

Thanks in advance
Sören
und doch, doch, und doooooch!

Post

at what level? :)

http://ccrma.stanford.edu/~jos/pubs.html

www.dspguide.com chap. 19 ~ about 24 is ~canonical i think

advanced filter design by anders johannson?? haven't read it. i usually search by topic and find at ccrma or h.u.t.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

xoxos wrote:at what level? :)
I've got a diploma in Media Engineering and do have some basic knowledge about digital filters.
But I'd like some fine book that tells me for examle about bilinear transformation, z-plane design and stuff as well as gives me some nice little formulae(iaeiae??s!) I can just type in, when I need, for example, a 12dB bandpass with certain features...

Thanks so far
Sören
und doch, doch, und doooooch!

Post

musicdsp.org and the dspguide are best references for basics.. arf a mo..
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

being comparatively ignorant, here are some borrowed filter implementations i've selected for their cpu/features...

sv filter (instability in some param ranges requires param bounding)

Code: Select all

Type : 12db resonant low, high or bandpass
References : Effect Deisgn Part 1, Jon Dattorro, J. Audio Eng. Soc., Vol 45, No. 9, 1997 September

Notes : 
Digital approximation of Chamberlin two-pole low pass. Easy to calculate coefficients, easy to process algorithm.

Code : 
cutoff = cutoff freq in Hz
fs = sampling frequency //(e.g. 44100Hz)
f = 2 sin (pi * cutoff / fs) //[approximately]
q = resonance/bandwidth [0 < q <= 1]  most res: q=1, less: q=0
low = lowpass output
high = highpass output
band = bandpass output
notch = notch output

scale = q

low=high=band=0;

//--beginloop
low = low + f * band;
high = scale * input - low - q*band;
band = f * high + band;
notch = high + low;
//--endloop
a low cpu peak filter

Code: Select all

	float ur, uf, ul, um, pi, a0, a1, a2, uo, ua, ub;	// peak filter


	//*in10 cutoff *in11 slope *in12 peak amt o2 = input of course

	if (*in10 != ul) {
		ul = *in10;
		uf = cos(pi * *in10);
	}
	if (*in11 != um) {
		um = *in11;
		ur = *in11;
		a0 = (1.f - ur) * sqrt(ur * (ur - 4.f * (uf * uf) + 2.f) + 1.f);
	}
	a1 = 2.f * uf * ur;
	a2 = -(ur * ur);
	uo = o2 + a1 * ua + a2 * ub;
	ub = ua;
	ua = uo;

	o2 += uo * *in12;
the naive 6db lp/hp

Code: Select all

Slope: 6dB/Oct
Reference: www.dspguide.com 

Code : 
Process loop (lowpass):
out = a0*in - b1*tmp;
tmp = out;

Simple HP version: subtract lowpass output from the input (has strange behaviour towards nyquist):
out = a0*in - b1*tmp;
tmp = out;
hp = in-out;

Coefficient calculation:
x = exp(-2.0*pi*freqinsamples/samplerate);
a0 = 1.0-x;
b1 = -x;

or straight x=[0-1] user coeff if it's not a big deal
i'd use biquads (google for pdfs) for anything fancier, check the recent 'do the work for me' thread for an allpass filter with phase calculation.. it's rather handy to have when making tuned models.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

xoxos wrote:... check the recent 'do the work for me' thread for an allpass filter with phase calculation.. it's rather handy to have when making tuned models.
I did one of my own (which I'm very proud of ;) ), thanks...

Yeah and thanks for the other source code!
und doch, doch, und doooooch!

Post

Oh, and by the way...

Is there a way to convert coefficients to another samplerate?
Example: I take the vowel filter at musicdsp.org (given coefficients for 44.1kHz) and want to use it at an arbitrary samplerate. Is there a way to convert them?

Cheers
Sören
und doch, doch, und doooooch!

Post

i didn't look at the algorithm - phonemes are arbitrary and i wouldn't promote the distribution of one set :)

praat is free and does f0 - f4 analysis (check the manual.. it has easy, explicit instructions on using praat for this and shouldn't take more than ~2 minutes :)

for amplitude data (if you need it) i used either wavosaur or audacity and visually esimated amplitude from spectral analysis.

(tip - if you record your voice and find a good vowel, cut out the wavecycle and paste it a few times into a new file - this makes a single wavecycle an 'absolute' reference for your data and will work better with fft analysis without the terminii presented by a single wavecycle).
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

virtualinsanity wrote:
xoxos wrote:at what level? :)
I've got a diploma in Media Engineering and do have some basic knowledge about digital filters.
But I'd like some fine book that tells me for examle about bilinear transformation, z-plane design and stuff as well as gives me some nice little formulae(iaeiae??s!) I can just type in, when I need, for example, a 12dB bandpass with certain features...
Funny... I personally find that I usually keep needing filters where the "certain features" are some features that are not free variables in any standard parameterization, so I usually just end up having to specify the "certain features" on Z-plane, and then give Maxima a set of equations to crunch (so I get a symbolic result with my own parameterization, that I can then convert into code). And about 9 times of the 10 there's no solution for whatever I initially tried, and I end up having to rethink my "certain features." :D

As for the actual subject, what level is your mathematics? Can you handle basic complex analysis and Fourier? If not, it might be helpful to start with those, if you want to develop a "deeper understanding" of filters as fast as possible (and once you do, you shouldn't need any formulas other than for reference maybe.. like I said, I personally keep trying to search for suitable formulas and more often than not end up having to solve it myself, so such "deeper understanding" might be useful if you want to do anything fancy).

Post

mystran wrote: As for the actual subject, what level is your mathematics? Can you handle basic complex analysis and Fourier? If not, it might be helpful to start with those, if you want to develop a "deeper understanding" of filters as fast as possible (and once you do, you shouldn't need any formulas other than for reference maybe.. like I said, I personally keep trying to search for suitable formulas and more often than not end up having to solve it myself, so such "deeper understanding" might be useful if you want to do anything fancy).
Yep, basic understanding of complex mathematics and Fourier analysis existent...
The thing is, I'm often too lazy (or anxious) to use it.
Hmm, so you develop everything by placing poles an zeroes on the z-plane and writing down equations describing them? Maybe I should just start doing it myself and look what comes out? ;)
What about given coefficients? Can you reverse-engineer them and alter them according to your needs?

Argghh so many questions. One Problem I have is that the things we did at University were so basic that I am a bit afraid of messing around with all those poles and stability criteria and whatever. Which is why I need some good literature that tells me ALL about it.

Thanks for all your answers
Cheers
Sören
und doch, doch, und doooooch!

Post

virtualinsanity wrote: Hmm, so you develop everything by placing poles an zeroes on the z-plane and writing down equations describing them? Maybe I should just start doing it myself and look what comes out? ;)
Well, it depends on how you look at it. I don't usually place any poles or zeroes directly, and I definitely don't "look for what comes out" in the sense that I wouldn't know what kind of curve I'm after.. rather what I mean is that I usually have some sort of constraints for the filter I need (this gain at this frequency, compared to maximum gain at this frequency, with a minima here, and certain sorts of slopes in between) at which point I come up with some equations that describe my constraints (which usually still have some free variables at this point that would become the parameters in the algorithm) and solve for the pole/zero placement (the number of constraints gives you directly the number of variables in the transfer function that you can solve for).. and then I plot the resulting filter, typically as either a function for gain or phase, and 3D surface plot with one of the design parameters on one axis, frequency on another (after selecting the stable one if there are multiple solutions, like usually happens if there are no constraints on phase), and if it looks fine I write it in code and start listening (and hope that I actually managed to pick a causal one.. one makes mistakes, you know). If it doesn't look fine (which almost always happens with the first try, because usually it's easy to come up with ill-defined constraints) it's time to either reformulate the original constraints, or add some more constraints and try again with a higher order filter (say, the low order forced some undesirable features on the filter because that was the only way to satisfy your constraints).

So.. if you mean like "let's put a pole here, and a zero here" then no, I almost never do that anymore (though you might want to try it to get better intuition about what to expect), but if you mean like implictly placing them like "let's put a zero at Nyquist to get lowpass response, and then place the pole such that 6dB gain is at this frequency" then yeah, that's the idea..

Anyway, I find that once you know exactly what you need (in the mathematical sense), and it turns out that it's actually possible (with the filter order you want; one can do pretty much anything linear with a long enough filter), coming up with the exact formula for your design parameters is just a matter of letting your favorite math program work for you (I use Maxima, though I wonder if I should learn to use something like Octave as well.. and I admit sometimes using Mathematica at uni, but once Maxima can't solve something, the result that Mathematica gets you often turns out like "wtf?" and more often than not there was some mistake in the original question.. but hey, Mathematica can pretty much give you an analytical solution anyway, as long as the relevant math exists.. it just might not be a pretty one).

Argghh so many questions. One Problem I have is that the things we did at University were so basic that I am a bit afraid of messing around with all those poles and stability criteria and whatever. Which is why I need some good literature that tells me ALL about it.
Stability is really easy. As long as all the poles are inside the unit circle it's stable (and if you put them close, make sure they stay on the right side when you need to round/truncate numbers because of finite word length). That's all there is, really.

Often if you solve constraint systems without constraints on phase (or something else that forces the poles inside unit circle), you'll get multiple solutions (most often with any of the possible combinations of causal and anti-causal poles), but for low-order filters it's not much of a problem to pick the right one (or you could use a tool that lets you specify additional constraints on the solutions and discard unstable ones automatically, but usually I don't bother).

Post

you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

This looks quite good. Have you read it yet?
mystran wrote: ... but if you mean like implictly placing them like "let's put a zero at Nyquist to get lowpass response, and then place the pole such that 6dB gain is at this frequency" then yeah, that's the idea..
Yep, that's what I meant.

Again, well, THANKS!!!

And now, I'll retreat into seclusion and try designing some filters ;)

Sören
und doch, doch, und doooooch!

Post Reply

Return to “DSP and Plugin Development”