Hi all, it seems like there are some fairly knowledgeable people hanging out here, so I will try my luck after searching high and low on the net. I am working on audio synthesis and am stuck on a couple of things with my 2 pole lowpass resonant IIR filter (it is a standard conjugate pole pair thingy for dealing with real signals of course :) The first thing is peak level equalization. The frequency and resonance inputs are 0 to 1 representing DC to nyquist frequency, and I am normalizing gain at DC. To maintain peak level I am currently doing 'res = pow (res, freq)' - which works pretty well at frequencies below half nyquist (where I am concentration). But the pow function is pretty slow for inner loops, so I would like to know if there is any other standard trick for doing this quickly - and I don't want to introduce zeros to do this as I want to keep very low and high frequencies. The second problem I have is sweeping the frequency - especially from low to high crossing a region where there are strong harmonics: In this case I get a very large transient which causes clipping, which would not exist if I just set the resonance right on the strong frequencies in this region. I know this is due to the fact that the internal state amplitude stays pretty high at low resonance frequencies and 'escapes' when I immediately set a higher resonance frequency (I am DC level after the IIR). I tried scaling the internal coefficients by the ratio of the new DC gain to the old, and that got rid of the transient, but introduced discontinuities (clicks), and produced new transients when going high to low. I restricted the adjustment to low->high transitions, and still got clicks. So I need to know if there is some other standard method for preserving continuity and avoiding transients when sweeping the frequency of a lowpass resonant filter. Thanks in advance for any help...
lowpass resonant filter sweeping and peak equalization?
Started by ●December 9, 2004
Reply by ●December 10, 20042004-12-10
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. "tpytel" <tompytel@yahoo.com> wrote in message news:1102648099.968982.264810@f14g2000cwb.googlegroups.com...> Hi all, it seems like there are some fairly knowledgeable people > hanging out here, so I will try my luck after searching high and low on > the net. I am working on audio synthesis and am stuck on a couple of > things with my 2 pole lowpass resonant IIR filter (it is a standard > conjugate pole pair thingy for dealing with real signals of course :) > > The first thing is peak level equalization. The frequency and resonance > inputs are 0 to 1 representing DC to nyquist frequency, and I am > normalizing gain at DC. To maintain peak level I am currently doing > 'res = pow (res, freq)' - which works pretty well at frequencies below > half nyquist (where I am concentration). But the pow function is pretty > slow for inner loops, so I would like to know if there is any other > standard trick for doing this quickly - and I don't want to introduce > zeros to do this as I want to keep very low and high frequencies. > > The second problem I have is sweeping the frequency - especially from > low to high crossing a region where there are strong harmonics: In this > case I get a very large transient which causes clipping, which would > not exist if I just set the resonance right on the strong frequencies > in this region. I know this is due to the fact that the internal state > amplitude stays pretty high at low resonance frequencies and 'escapes' > when I immediately set a higher resonance frequency (I am DC level > after the IIR). I tried scaling the internal coefficients by the ratio > of the new DC gain to the old, and that got rid of the transient, but > introduced discontinuities (clicks), and produced new transients when > going high to low. I restricted the adjustment to low->high > transitions, and still got clicks. So I need to know if there is some > other standard method for preserving continuity and avoiding transients > when sweeping the frequency of a lowpass resonant filter. > Thanks in advance for any help... >
Reply by ●December 10, 20042004-12-10
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
Reply by ●December 10, 20042004-12-10
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 otherfilter> > forms such > > as lattice/ladder or state-variable. It will probably takeadditional> > effort to > > convert your coefficients to one of these forms, but the resultsshould 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
Reply by ●December 10, 20042004-12-10
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 >
Reply by ●December 10, 20042004-12-10
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.> 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.one of those reflection coefs *is* the same as R^2, i thought.> I will dig some more and attempt > to grok this however and see if it applies, thx for the suggestion.are you processing samples in real-time with this? is it a floating-point DSP? (sorry, i didn't see the original post.) how often do you feel you need to update the coefs? every sample? every 64 samples? r b-j
Reply by ●December 10, 20042004-12-10
"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.
Reply by ●December 10, 20042004-12-10
"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. -- % Randy Yates % "Bird, on the wing, %% Fuquay-Varina, NC % goes floating by %%% 919-577-9882 % but there's a teardrop in his eye..." %%%% <yates@ieee.org> % 'One Summer Dream', *Face The Music*, ELO http://home.earthlink.net/~yatescr
Reply by ●December 11, 20042004-12-11
This stuff is for a real-time high performance audio DSP lib on PC. And yes, I would like to be able to recalc coeffs every sample for FM of the filter. As for DF1 vs. DF2 - I will do some tests at extreme freq/res to see if distortion level is very bad - though those extremes are not a common case for filtering within audible range. The big reason for me for DF2 is that it is much faster and efficient for me to have 4 state variables in the inner loop of a 4 pole 4 zero filter than 8. Though a quick scan of the post you directed me to shows up at least one error with its logic. The 1 vs. 2 summation point thing is true on paper. In practice, the PC floating point proc (I don't know about other hardware) adds numbers one at a time. You have to add all the variables one by one regardless of whether a summation point in a diagram has 2 or 200 inputs. And in DF2 with the b0 scale factor pulled outside the structure, all the adds happen at the same logical time instant effectively making it a 1 summation point on paper anyway, no? Anyways, as for reflection coeffs, I know very little about this so far. But the recursive recipe I found for calculating them from the transfer function coeffs looks very slow for per-sample recalc. I need to dig some more there though... Thx... robert bristow-johnson wrote:> 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 myfilters.> > you should use Direct Form 1, even for floating-point. see > > http://groups-beta.google.com/group/comp.dsp/msg/0fb1458ae9bb89b5 > > for the reason. > > > > I had actually tried just what you suggested - smoothing thefrequency> > 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 implementationas> > suggested. The filter stucture itself is simple enough, butcalculating> > those reflection coefficients looks considerably slower than the > > -2Rcos(f) and R^2 for the direct form. > > one of those reflection coefs *is* the same as R^2, i thought. > > > I will dig some more and attempt > > to grok this however and see if it applies, thx for the suggestion. > > are you processing samples in real-time with this? is it afloating-point> DSP? (sorry, i didn't see the original post.) how often do you feelyou> need to update the coefs? every sample? every 64 samples? > > r b-j
Reply by ●December 11, 20042004-12-11
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 thenconverting> to lattice-ladder. Very general and flexible, but probably not themost> efficient. Maybe you can use some look-up tables to accelerate thecoef> 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 myfilters.> > I had actually tried just what you suggested - smoothing thefrequency> > 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 implementationas> > suggested. The filter stucture itself is simple enough, butcalculating> > those reflection coefficients looks considerably slower than the > > -2Rcos(f) and R^2 for the direct form. I will dig some more andattempt> > 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 theresults> > should be > > > > better. > > > > > > I was about to posting the same suggestion... Along the samelines,> > you > > > could also try limiting the rate of change by smoothing theparameter> > > > > changes (a first order LP should do nicely). That should limitthe> > > 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 > >