Forums

lowpass resonant filter sweeping and peak equalization?

Started by tpytel December 9, 2004
Sorry, I should have been more specific.  What you need is the "normalized" 
lattice-ladder filter structure. The regular lattice won't help you that much, 
but adding the normalization is what keeps the internal nodes from going crazy. 
Of course, it is more computationally complex.  This paper has some good 
information as well:
http://www.jamminpower.com/PDF/48-bit%20Audio.jsp
(the web site seems to be done right now, so you can also try here: 
http://www.sonicstudio.com/pdf/papers/48-bitAudioPaper.pdf)
(Figure 2 shows the filter form I'm talking about.)

Limiting yourself to 2nd order sections is always a good idea.  You can build 
larger more complex filters by first factoring them into 2nd order sections.  In 
fact, that's a pretty standard technique to avoid all kinds of numerical 
precision issue.

"tpytel" <tompytel@yahoo.com> wrote in message 
news:1102751493.990409.295290@z14g2000cwz.googlegroups.com...
> Just a quick followup post. Figured out the reflection coefficients and > implemented the lattice filter (it wasn't too bad after all when I > limited myself to order 2 sections :). But it still has the same > problem. As I feared, the transient has nothing to do with the filter > structure, but needs a method for normalizing the temporary internal > state when changing frequency :( > > Thx for the suggestion though, at least I learned another new filter > form :) > > Jon Harris wrote: >> I've used the approach of calculating the direct form coifs and then > converting >> to lattice-ladder. Very general and flexible, but probably not the > most >> efficient. Maybe you can use some look-up tables to accelerate the > coef >> calculations if they are too slow? Good luck. >> >> "tpytel" <tompytel@yahoo.com> wrote in message >> news:1102723574.822892.136160@c13g2000cwb.googlegroups.com... >> > I am using a direct form 2 with floating point math for all my > filters. >> > I had actually tried just what you suggested - smoothing the > frequency >> > sweep with a 1 pole LP, but the transition time is too long for an >> > acceptable attenuation of the transient. >> > >> > Also I dug up some info on the net on lattice-ladder implementation > as >> > suggested. The filter stucture itself is simple enough, but > calculating >> > those reflection coefficients looks considerably slower than the >> > -2Rcos(f) and R^2 for the direct form. I will dig some more and > attempt >> > to grok this however and see if it applies, thx for the suggestion. >> > >> > Stephan M. Bernsee wrote: >> > > On 2004-12-10 20:41:00 +0100, "Jon Harris" > <goldentully@hotmail.com> >> > said: >> > > >> > > > Are you using the direct form implementation of the filter? >> > Regarding >> > > > sweeping, >> > > > I have found that much better results are obtained using other >> > filter >> > > > forms such >> > > > as lattice/ladder or state-variable. It will probably take >> > additional >> > > > effort to >> > > > convert your coefficients to one of these forms, but the > results >> > should be >> > > > better. >> > > >> > > I was about to posting the same suggestion... Along the same > lines, >> > you >> > > could also try limiting the rate of change by smoothing the > parameter >> > >> > > changes (a first order LP should do nicely). That should limit > the >> > > explosive dynamics you're observing but it may depend on the >> > > application whether the response time of the filter changes is >> > > acceptable... >> > > -- >> > > Stephan M. Bernsee >> > > http://www.dspdimension.com >> > >
"Randy Yates" <yates@ieee.org> wrote in message news:acslftr4.fsf@ieee.org...
> "Jon Harris" <goldentully@hotmail.com> writes: > >> "robert bristow-johnson" <rbj@audioimagination.com> wrote in message >> news:BDDFAFD2.2FEA%rbj@audioimagination.com... >>> in article 1102723574.822892.136160@c13g2000cwb.googlegroups.com, tpytel at >>> tompytel@yahoo.com wrote on 12/10/2004 19:06: >>> >>> > I am using a direct form 2 with floating point math for all my filters. >>> >>> you should use Direct Form 1, even for floating-point. see >>> >>> http://groups-beta.google.com/group/comp.dsp/msg/0fb1458ae9bb89b5 >>> >>> for the reason. >> >> Agreed DF1 is better than DF2 in terms of measurable distortion with >> "extreme" >> filter settings. I've also had good success with DF2T, i.e. director form 2 >> transposed. But the lattice forms are much better for smoothing when using >> time-varying filters. > > Why? Why would this matter at all? We're talking about implementation issues, > and I would think the time-varying-ness is a theoretical issue.
It may be true that the DF1 won't perform better than the DF2 in a time-varying filter situation (they should give identical "lousy" results with infinite precision). But other filter forms do produce significantly better time-variant responses. See the Moorer paper I referenced in another post on this thread.
Jon Harris wrote:
> Sorry, I should have been more specific. What you need is the
"normalized"
> lattice-ladder filter structure. The regular lattice won't help you
that much,
> but adding the normalization is what keeps the internal nodes from
going crazy.
> Of course, it is more computationally complex. This paper has some
good
> information as well: > http://www.jamminpower.com/PDF/48-bit%20Audio.jsp > (the web site seems to be done right now, so you can also try here: > http://www.sonicstudio.com/pdf/papers/48-bitAudioPaper.pdf) > (Figure 2 shows the filter form I'm talking about.) > > Limiting yourself to 2nd order sections is always a good idea. You
can build
> larger more complex filters by first factoring them into 2nd order
sections. In
> fact, that's a pretty standard technique to avoid all kinds of
numerical
> precision issue.
Hey, that did the trick, no more transient on sweep. Though the inner loop will be a good bit slower with all the extra multiplies. Those references really helped. As for order of filter, I originally thought to optimize the code this way, completely ignoring precision in the process. That was silly, I will go back to 2nd order sections. Thx much again :)
tpytel wrote:
> > I am using a direct form 2 with floating point math for all my filters. > I had actually tried just what you suggested - smoothing the frequency > sweep with a 1 pole LP, but the transition time is too long for an > acceptable attenuation of the transient.
The 1 pole LP can work, but I've had better results with linear interpolation of the frequency and resonance parameters over 100 or more samples. This works for even the most radical step responses in the parameters. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ When aiming for the common denominator, be prepared for the occasional division by zero.
Glad to here things are working for you.  Yes, the "4-multiply lattice ladder" 
filter is more expensive than direct forms or other non-normalized forms, but as 
the saying goes "you get what you pay for"!  :-)
-Jon

"tpytel" <tompytel@yahoo.com> wrote in message 
news:1102784303.727730.25380@z14g2000cwz.googlegroups.com...
> > Jon Harris wrote: >> Sorry, I should have been more specific. What you need is the > "normalized" >> lattice-ladder filter structure. The regular lattice won't help you > that much, >> but adding the normalization is what keeps the internal nodes from > going crazy. >> Of course, it is more computationally complex. This paper has some > good >> information as well: >> http://www.jamminpower.com/PDF/48-bit%20Audio.jsp >> (the web site seems to be done right now, so you can also try here: >> http://www.sonicstudio.com/pdf/papers/48-bitAudioPaper.pdf) >> (Figure 2 shows the filter form I'm talking about.) >> >> Limiting yourself to 2nd order sections is always a good idea. You > can build >> larger more complex filters by first factoring them into 2nd order > sections. In >> fact, that's a pretty standard technique to avoid all kinds of > numerical >> precision issue. > > Hey, that did the trick, no more transient on sweep. Though the inner > loop will be a good bit slower with all the extra multiplies. Those > references really helped. > > As for order of filter, I originally thought to optimize the code this > way, completely ignoring precision in the process. That was silly, I > will go back to 2nd order sections. > > Thx much again :) >
"Erik de Castro Lopo" <nospam@mega-nerd.com> wrote in message 
news:41BBD4C6.B67A297C@mega-nerd.com...
> tpytel wrote: >> >> I am using a direct form 2 with floating point math for all my filters. >> I had actually tried just what you suggested - smoothing the frequency >> sweep with a 1 pole LP, but the transition time is too long for an >> acceptable attenuation of the transient. > > The 1 pole LP can work, but I've had better results with linear > interpolation of the frequency and resonance parameters over 100 > or more samples. This works for even the most radical step responses > in the parameters. > > Erik
Interesting. I usually interpolate the filter coefficients themselves as this is much less computationally demanding that re-calculating them from frequency/resonance data for each point along the way. But perhaps that would work better.
in article 324rfoF3h15l6U1@individual.net, Jon Harris at
goldentully@hotmail.com wrote on 12/13/2004 01:34:

> the "4-multiply lattice ladder" filter is more expensive than direct forms or > other non-normalized forms, but as the saying goes "you get what you pay for"!
i dunno if that is the case all the time. for the purpose of accomplishing something, you get less than what you pay for if your design is inefficient. with either fixed or floating-point processors, i am not sure what the advantage of the normalized ladder or lattice other than they both decouple Q from the one coefficient ("k2" i think). the normalized ladder does put a L2 norm limit on the amplitude of all of its nodes, but it doesn't guarantee against clipping. i still think DF1 or maybe the transposed DF2 are just as good as anything else, even if you have to calculate coefficients on the fly. r b-j
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message
news:BDE3051A.309B%rbj@audioimagination.com...
> in article 324rfoF3h15l6U1@individual.net, Jon Harris at > goldentully@hotmail.com wrote on 12/13/2004 01:34: > > > the "4-multiply lattice ladder" filter is more expensive than direct forms
or
> > other non-normalized forms, but as the saying goes "you get what you pay
for"!
> > i dunno if that is the case all the time. for the purpose of accomplishing > something, you get less than what you pay for if your design is inefficient. > > with either fixed or floating-point processors, i am not sure what the > advantage of the normalized ladder or lattice other than they both decouple > Q from the one coefficient ("k2" i think). the normalized ladder does put a > L2 norm limit on the amplitude of all of its nodes, but it doesn't guarantee > against clipping. i still think DF1 or maybe the transposed DF2 are just as > good as anything else, even if you have to calculate coefficients on the > fly.
Have you ever tried sweeping the coefs of a DF1 and a normalized lattice-ladder and listening to the results? The DF1 sounds _much_ worse! Keep in mind that a time-variant filter is the main concern of the OP. Here is an article that does analysis on the transient behavior of various filter forms for the case of time-variant filters: http://www.sonicstudio.com/pdf/papers/48-bitAudioPaper.pdf My intuitive explanation: since the normalization tends to keep the state variables at "reasonable" values, you don't end up with problems where the filter coefficients and the state variables are "way out of whack" with each other like you can with direct forms. If you are strictly considering the case of a static filter, then I agree with everything you wrote and the normalized lattice-ladder is probably a waste of DSP cycles. But its behavior both in terms of low noise with extreme filter settings and "good behavior" with time-variant filters make it the Cadillac* of filters IMHO. YMMV. -Jon *luxury features but high price
Jon Harris wrote:
> Glad to here things are working for you. Yes, the "4-multiply
lattice ladder"
> filter is more expensive than direct forms or other non-normalized
forms, but as
> the saying goes "you get what you pay for"! :-) > -Jon
4 multiply? Don't you mean 7 multiplies for a two pole (6 for the lattice part + 1 for the final normalization)? Anyway, it does get good results for slow frequency sweeps even with high frequency FM of the filter freq :) At some point I will also try to find some info on the state-variable form, but for now this form works quite well. Seeing as you have been so helpful with this particular detail, would you mind if I pick your brain on the other original question I had? The peak normalization I am doing now is that I am raising the original resonance value to the power of the normalized frequency: res = pow (res, freq). This works pretty well, but the power function is about 20x slower than a mul or add. I tried other formulas based on specifically trying to set a resonance dB gain, but they all wound up being more costly in terms of cycles due to painful trig operations. What do you do to maintain a constant peak level across the frequency spectrum?
"tpytel" <tompytel@yahoo.com> wrote in message 
news:1102994475.154973.16390@f14g2000cwb.googlegroups.com...
> > Jon Harris wrote: >> Glad to here things are working for you. Yes, the "4-multiply > lattice ladder" >> filter is more expensive than direct forms or other non-normalized > forms, but as >> the saying goes "you get what you pay for"! :-) >> -Jon > > 4 multiply? Don't you mean 7 multiplies for a two pole (6 for the > lattice part + 1 for the final normalization)? Anyway, it does get good > results for slow frequency sweeps even with high frequency FM of the > filter freq :) At some point I will also try to find some info on the > state-variable form, but for now this form works quite well.
That terminology threw me when I first heard it too. It refers to the number of multiplies required by the lattice section for a first order (not second order) filter. It is a "four-multiply" filter as opposed to the non-normalized version (or direct form) which is "two-multiply". It's kind of confusing terminology, but it's common in the industry, for example: D. C. Massie, "An Engineering Study of the Four-Multiply Normalized Ladder Filter," J. Audio Eng. Soc., vol. 41, pp. 564-582 (1986 July/Aug.).
> Seeing as you have been so helpful with this particular detail, would > you mind if I pick your brain on the other original question I had? The > peak normalization I am doing now is that I am raising the original > resonance value to the power of the normalized frequency: res = pow > (res, freq). This works pretty well, but the power function is about > 20x slower than a mul or add. I tried other formulas based on > specifically trying to set a resonance dB gain, but they all wound up > being more costly in terms of cycles due to painful trig operations. > What do you do to maintain a constant peak level across the frequency > spectrum?
What platform are you on? My experience has been with the formulas found here: http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt I've always had the luxury of time to compute the coefficients directly since they don't change very often in my case. But I have used approximations to a power function by breaking the power into integer and fractional parts then using a shift to do the integer part and a power series approximation for the fractional part. This was on a floating-point SHARC DSP. However, this might not be applicable to the case where the base is not constant. General optimization principles such as using look-up tables possibly with interpolation may be applicable as well.