Fast Modulation of Filter Parameters

DSP, Plug-in and Host development discussion.
User avatar
S0lo
KVRian
705 posts since 31 Dec, 2008

Post Sat May 18, 2019 4:57 pm

mystran wrote:
Sat May 18, 2019 2:28 pm
Off-topic: every time you say CPS my brain parses it as "continuation-passing style" and get's really confused. :D
Could be "Chronic Pain Syndrome". :hihi:

May be we should add one to these: https://en.wikipedia.org/wiki/CPS

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Mon May 20, 2019 3:11 am

In regards to CPS, I didn't really read the text, but from the name and TF I would guess that it's probably related to the 1-poles used in the Jordan normal form. Although, since the connection is serial, it possibly doesn't suffer from the ill-conditioning present in parallel connection ;)

The problem compared to the parallel form though is that the states of the two conjugate complex sections are not conjugate. On one hand this means we can't share the state (which is the trick used in the real Jordan normal form). Also, in fact I'm even not sure if a serial connection can guarantee a real output in time-variant case. Did you check that? Your argument seems to apply to time-invariant case only.

User avatar
S0lo
KVRian
705 posts since 31 Dec, 2008

Re: Fast Modulation of Filter Parameters

Post Mon May 20, 2019 1:22 pm

Z1202 wrote:
Mon May 20, 2019 3:11 am
In regards to CPS, I didn't really read the text, but from the name and TF I would guess that it's probably related to the 1-poles used in the Jordan normal form. Although, since the connection is serial, it possibly doesn't suffer from the ill-conditioning present in parallel connection ;)
I haven't looked deeply into Jordan normal forms TBH. But from a 10 minute browse here and there. Apparently it's different. At least thats the impression I got from Figure 7.2 in your book.

Fortunately, a fellow member directed me recently to Max Mathews paper, which uses what seams to be a similar approach to CPS.

https://ccrma.stanford.edu/~jos/smac03m ... maxjos.pdf

Albeit, being taged the name "phasor filters" or "complex resonators" vaguely in other few references. I had no knowledge of such usage TBH when I posted this article, so I had to give it some name to go with.
Z1202 wrote:
Mon May 20, 2019 3:11 am
Also, in fact I'm even not sure if a serial connection can guarantee a real output in time-variant case. Did you check that? Your argument seems to apply to time-invariant case only.
O the real output (with zero imaginary) is guaranteed only by the designer of the filter him self. If he designs prefect conjugate pairs he will get a pure real output. If he wants an imaginary output he can get that too. Yet in both cases stability in time variant case is guaranteed with the proof presented in the last section of the article. (As long as R<1). The "time in-variant case" is just a special case of the "time variant case" where the parameters don't change.

Also, I surely tested it. The imaginary parts do cancel out when designed as such.

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Mon May 20, 2019 11:15 pm

S0lo wrote:
Mon May 20, 2019 1:22 pm
Albeit, being taged the name "phasor filters" or "complex resonators" vaguely in other few references. I had no knowledge of such usage TBH when I posted this article, so I had to give it some name to go with.
Complex resonator (as much as I can tell from Julius O. Smith's page) is pretty much the same (up to a gain coefficient) as a Jordan 1-pole. Except that in VAFilterDesign they are continuous-time, but you can do the same in digital form. Jordan normal form is just a matrix form, so it's applicable to discrete-time state-space form in the same way as to continuous-time state-space.
S0lo wrote:
Mon May 20, 2019 1:22 pm
Z1202 wrote:
Mon May 20, 2019 3:11 am
Also, in fact I'm even not sure if a serial connection can guarantee a real output in time-variant case. Did you check that? Your argument seems to apply to time-invariant case only.
Also, I surely tested it. The imaginary parts do cancel out when designed as such.
Let me get this clear. You implemented a serial connection of two complex resonators and modulated both and the imaginary part is always 0? Maybe you're right, but it'd be nice to have a proof of that. The proof you mention is about stability, not about purely real output in the time-varying case, right?

mystran
KVRAF
5291 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Fast Modulation of Filter Parameters

Post Mon May 20, 2019 11:54 pm

Z1202 wrote:
Mon May 20, 2019 11:15 pm
S0lo wrote:
Mon May 20, 2019 1:22 pm
Z1202 wrote:
Mon May 20, 2019 3:11 am
Also, in fact I'm even not sure if a serial connection can guarantee a real output in time-variant case. Did you check that? Your argument seems to apply to time-invariant case only.
Also, I surely tested it. The imaginary parts do cancel out when designed as such.
Let me get this clear. You implemented a serial connection of two complex resonators and modulated both and the imaginary part is always 0? Maybe you're right, but it'd be nice to have a proof of that. The proof you mention is about stability, not about purely real output in the time-varying case, right?
Why would you even do this?

If you want real-valued output, you need a complex conjugate pair. If you take a single complex one-pole and throw away the imaginary part of the output, you'll get a real-valued two-pole thanks to aliasing. So trying to use two complex resonators only to form a complex conjugate pair anyway sounds like complete waste of CPU to me.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 12:05 am

mystran wrote:
Mon May 20, 2019 11:54 pm
Why would you even do this?

If you want real-valued output, you need a complex conjugate pair. If you take a single complex one-pole and throw away the imaginary part of the output, you'll get a real-valued two-pole thanks to aliasing. So trying to use two complex resonators only to form a complex conjugate pair anyway sounds like complete waste of CPU to me.
I'm not sure what exactly Ammar is aiming at, but as to your remark, throwing out the imaginary part works only if the conjugate pair is "strongly complex", that is the imaginary part is sufficiently far away from zero. It gets ill-conditioned (with practical transfer functions) as the poles move close to each other and stops working as you want to real poles.

On the other hand, sure, connecting two complex 1-poles sequentially essentially means a 4-pole filter :D

mystran
KVRAF
5291 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 1:08 am

Z1202 wrote:
Tue May 21, 2019 12:05 am
mystran wrote:
Mon May 20, 2019 11:54 pm
Why would you even do this?

If you want real-valued output, you need a complex conjugate pair. If you take a single complex one-pole and throw away the imaginary part of the output, you'll get a real-valued two-pole thanks to aliasing. So trying to use two complex resonators only to form a complex conjugate pair anyway sounds like complete waste of CPU to me.
I'm not sure what exactly Ammar is aiming at, but as to your remark, throwing out the imaginary part works only if the conjugate pair is "strongly complex", that is the imaginary part is sufficiently far away from zero. It gets ill-conditioned (with practical transfer functions) as the poles move close to each other and stops working as you want to real poles.
Jordan normal form also gets ill-conditioned when the poles are close to each other and it's also where you need a second-order term in a partial fractional expansion (ie. parallel implementation).

That said, the trivial rotation formula for complex one-poles is numerically poorly behaved no matter what. In fact, the O(n) error growth is so bad that trying to uses those for FFT twiddles makes the whole thing completely blow up even with double precision arithmetic somewhere around a million points [edit: there are better recurrences though and you could certainly build a filter out of those as well]. In a damped filter it'll certainly "work" just like direct form filters "work" ... but honestly I'd suggest using something more accurate ... like the trapezoidal SVF for example.

:)
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 2:22 am

mystran wrote:
Tue May 21, 2019 1:08 am
In a damped filter it'll certainly "work" just like direct form filters "work" ... but honestly I'd suggest using something more accurate ... like the trapezoidal SVF for example.
I wouldn't compare that to direct form. The complex 1-poles have really nice transient behavior under cutoff and resonance changes. At least for the internal state of the filter. For SVF you have a decaying circle morphing into a decaying ellipse (which is also rotating as resonance changes), which is already not so nice. OTOH, with practical TFs it gets more complicated.

matt42
KVRian
1110 posts since 9 Jan, 2006

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 6:45 am

Hi Solo,

I have done a quick test of the complex sections. (Disclaimer: I'm working nights and I could be discombobulated). I found that modulating the filter does result in imaginary output. However if it then becomes static the imaginary content quickly drops below the noise floor (although higher than if the filter was never modulated in the first place, it's still negligible). Perhaps this explains the nasty/aggressive sound you describe? Dropping the imaginary content during modulation would cause some frequency response aliasing as mystan describes?
mystran wrote:
Mon May 20, 2019 11:54 pm
Why would you even do this?

If you want real-valued output, you need a complex conjugate pair. If you take a single complex one-pole and throw away the imaginary part of the output, you'll get a real-valued two-pole thanks to aliasing. So trying to use two complex resonators only to form a complex conjugate pair anyway sounds like complete waste of CPU to me.
Nice optimisation. But this solution doesn't work completely as the filter will collapse to one pole as the poles become real.

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 7:04 am

matt42 wrote:
Tue May 21, 2019 6:45 am
Hi Solo,

I have done a quick test of the complex sections. (Disclaimer: I'm working nights and I could be discombobulated). I found that modulating the filter does result in imaginary output. However if it then becomes static the imaginary content quickly drops below the noise floor (although higher than if the filter was never modulated in the first place, it's still negligible).
That's exactly what I was kinda expecting. Modulation creates a transient which is not fully real. OTOH a static (LTI) part of the signal of course should be real since the global transfer function is real.

matt42
KVRian
1110 posts since 9 Jan, 2006

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 7:11 am

Z1202 wrote:
Tue May 21, 2019 7:04 am
matt42 wrote:
Tue May 21, 2019 6:45 am
Hi Solo,

I have done a quick test of the complex sections. (Disclaimer: I'm working nights and I could be discombobulated). I found that modulating the filter does result in imaginary output. However if it then becomes static the imaginary content quickly drops below the noise floor (although higher than if the filter was never modulated in the first place, it's still negligible).
That's exactly what I was kinda expecting. Modulation creates a transient which is not fully real. OTOH a static (LTI) part of the signal of course should be real since the global transfer function is real.
It seems that the filter is stable, so I guess the question is how does it sound when modulated? I've only looked at the output values, so I still have no idea in that regard.

User avatar
S0lo
KVRian
705 posts since 31 Dec, 2008

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 8:08 am

Ok, I have to first correct what I said above regarding the zero imaginary part. I've checked it before without modulation and the result was in the 10^-16 range, so it's practically zero. But now I checked it during very fast modulation, and YES, there is a significant imaginary part!! like in the range 0.3 to 0.6 or so. So you are right guys.

Still the filter is stable. And I'm not surprised it's still stable because the 1-pole section itself is stable regardless weather it produces imaginary parts or pure real parts.

@mystran
Regarding droping the imaginary part after a one pole. Good idea!!. From what I can check in 10 minutes, It will yield a 2-pole, but not the 2-pole I've designed. I just tried it. It works but has a very different characteristics. It attenuates bass frequencies hardly. And you just gave me a good a idea ;) Thanks.

Z1202
KVRian
1059 posts since 12 Apr, 2002

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 9:29 am

S0lo wrote:
Tue May 21, 2019 8:08 am
@mystran
Regarding droping the imaginary part after a one pole. Good idea!!. From what I can check in 10 minutes, It will yield a 2-pole, but not the 2-pole I've designed. I just tried it. It works but has a very different characteristics. It attenuates bass frequencies hardly. And you just gave me a good a idea ;) Thanks.
As mentioned, this works only if resonance is sufficiently high so that the imaginary parts of the poles are away from zero. Particularly see 7.9 and 7.11 of you know which book ;) (dropping the imaginary part is equivalent to averaging with a conjugate filter's output).
Actually it should be possible to construct any resonating 2-pole this way.
On the other hand, serial connection probably doesn't suffer from this ill-conditioning, but doubles (effectively) the filter order and has complex transients.

User avatar
S0lo
KVRian
705 posts since 31 Dec, 2008

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 5:13 pm

Z1202 wrote:
Tue May 21, 2019 9:29 am
As mentioned, this works only if resonance is sufficiently high so that the imaginary parts of the poles are away from zero. Particularly see 7.9 and 7.11 of you know which book ;) (dropping the imaginary part is equivalent to averaging with a conjugate filter's output).
Actually it should be possible to construct any resonating 2-pole this way.
On the other hand, serial connection probably doesn't suffer from this ill-conditioning, but doubles (effectively) the filter order and has complex transients.
I have skimmed through 7.11 very briefly to get the top lines. But let me take it from you before I decide to go deep into this or not. Is it possible to design a single CPS (or Complex resonator, or..etc) where we would simply drop the imaginary part and get exactly the desired 2-pole without ill-conditioned problems at any resonance value?

mystran
KVRAF
5291 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Fast Modulation of Filter Parameters

Post Tue May 21, 2019 6:35 pm

S0lo wrote:
Tue May 21, 2019 5:13 pm
Z1202 wrote:
Tue May 21, 2019 9:29 am
As mentioned, this works only if resonance is sufficiently high so that the imaginary parts of the poles are away from zero. Particularly see 7.9 and 7.11 of you know which book ;) (dropping the imaginary part is equivalent to averaging with a conjugate filter's output).
Actually it should be possible to construct any resonating 2-pole this way.
On the other hand, serial connection probably doesn't suffer from this ill-conditioning, but doubles (effectively) the filter order and has complex transients.
I have skimmed through 7.11 very briefly to get the top lines. But let me take it from you before I decide to go deep into this or not. Is it possible to design a single CPS (or Complex resonator, or..etc) where we would simply drop the imaginary part and get exactly the desired 2-pole without ill-conditioned problems at any resonance value?
Not really. What we have is essentially a parallel implementation by partial fractional decomposition... but since we know the outputs of the two terms are conjugate for Q>.5 we can just compute one and take the real part and pretend we did a parallel sum.

For Q=.5 you have a pole of multiplicity 2 and hence the PFD necessarily has a second order term. In general, for whatever multiplicity you have you end up needing a term of equal order, which really limits the applicability of PFD where poles can stack in the same place: in this case parallel implementation by 1st order sections is just not possible, no matter what.

For Q<.5 the parallel decomposition works again, but now the poles are both real rather than conjugate, so the trick of computing just one no longer works and you need two (real) one-poles. This is typically cheaper than computing a single complex resonator though.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Return to “DSP and Plug-in Development”