lowpass resonant filter sweeping and peak equalization?
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
lowpass resonant filter sweeping and peak equalization?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
tpytel
Guest





Posted: Fri Dec 10, 2004 8:08 am    Post subject: lowpass resonant filter sweeping and peak equalization? Reply with quote

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...
Back to top
Jon Harris
Guest





Posted: Sat Dec 11, 2004 12:41 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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...
Quote:
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...
Back to top
Stephan M. Bernsee
Guest





Posted: Sat Dec 11, 2004 12:55 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

On 2004-12-10 20:41:00 +0100, "Jon Harris" <goldentully@hotmail.com> said:

Quote:
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
Back to top
tpytel
Guest





Posted: Sat Dec 11, 2004 5:06 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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:
Quote:
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
Back to top
Jon Harris
Guest





Posted: Sat Dec 11, 2004 5:44 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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...
Quote:
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
Back to top
robert bristow-johnson
Guest





Posted: Sat Dec 11, 2004 5:56 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

in article 1102723574.822892.136160@c13g2000cwb.googlegroups.com, tpytel at
tompytel@yahoo.com wrote on 12/10/2004 19:06:

Quote:
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.


Quote:
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.

Quote:
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
Back to top
Jon Harris
Guest





Posted: Sat Dec 11, 2004 6:41 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

"robert bristow-johnson" <rbj@audioimagination.com> wrote in message
news:BDDFAFD2.2FEA%rbj@audioimagination.com...
Quote:
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.
Back to top
Randy Yates
Guest





Posted: Sat Dec 11, 2004 7:34 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

"Jon Harris" <goldentully@hotmail.com> writes:

Quote:
"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
Back to top
tpytel
Guest





Posted: Sat Dec 11, 2004 9:48 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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:
Quote:
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
Back to top
tpytel
Guest





Posted: Sat Dec 11, 2004 12:51 pm    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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:
Quote:
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
Back to top
Jon Harris
Guest





Posted: Sat Dec 11, 2004 7:29 pm    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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...
Quote:
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

Back to top
Jon Harris
Guest





Posted: Sat Dec 11, 2004 8:02 pm    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

"Randy Yates" <yates@ieee.org> wrote in message news:acslftr4.fsf@ieee.org...
Quote:
"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.
Back to top
tpytel
Guest





Posted: Sat Dec 11, 2004 9:58 pm    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

Jon Harris wrote:
Quote:
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 :)
Back to top
Erik de Castro Lopo
Guest





Posted: Sun Dec 12, 2004 10:19 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

tpytel wrote:
Quote:

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.
Back to top
Jon Harris
Guest





Posted: Mon Dec 13, 2004 6:59 am    Post subject: Re: lowpass resonant filter sweeping and peak equalization? Reply with quote

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...
Quote:

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 :)
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB