Integrator filter with delayless feedback path

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Since I started doing DSP (somewhere in 2005 or so) I was looking for an analogue sounding resonant lowpass filter. And just before any discussion about 'analogue sounding' starts, I define what I mean: It's not about the filtering itself, it's about the resonance.
Everybody who has listened to any of the great analogue synths from the past should know what I mean.

The 'standard' filter architectures (biquads, SVF, ...) all lack 'real resonance'. Other filters need freaking parameters to correct for resonance issues (and still don't give me what I want).

So I started again using a simple ladder filter build from leaky integrators ( out += f * (in - out) ) using 4 poles. In the analogue world the feedback path is just: connect output with input and use some gain control ... and of course this works, because there's practically no delay for current traveling from 'output' to filter 'input'.

In the digital world, this does not work (as we all know) because of the nasty thing called 'unit delay'. But we can remove that unit delay. The trick is to know the output before it gets calculated.

In pseudo code it would look like this (r is resonance factor):

Code: Select all

out = lastout;
DO
 copyRealFilterBuffersToTemp();
 newout = tempFilter(input - out * r);
 IF ABS(newout - out) < epsilon THEN
  copyTempBuffersToFilter();
  out = newout;
  BREAK    // we're done, exit the loop
 ENDIF
 // epsilon was not reached, continue iteration
 out = newout;
LOOP
lastout = out;
A maximum number of iterations should be specified ... and this thing should be oversampled!

Here's an audio example using the above filter with following specifications:
- 4 integrators
- first integrator gets hard clipped to [-1, 1]
- fs = 512kHz
- f = tan(PI * fc / fs)
- r = q * (10 * fc / fs + 1)
- q is in [0.0, 5.0] and filter self oscillates at q == 4.0

You can also use: r = q * (1.0 + f * PI);

It uses less CPU resources than I expected, and the only optimization I can think of at the moment is a nice prediction function for calculation of the initial iteration value.

Nevertheless I love this one ... this is what I call resonance.

Anyways, here is the audio sample (mp3/320).

Feedback appreciated, questions also^^
Last edited by neotec on Tue Nov 15, 2011 12:11 pm, edited 1 time in total.
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post

Are you aware of this: http://www.native-instruments.com/filea ... pology.pdf

There has also been several discussions on KVR (basically every time someone has talked about filters in the past few years).

Yeah, it works...

Post

Yep, I know the 'KeepTopology' stuff ... I just wanted to present a different approach (simple and hopefully understandable) which doesn't involve lots of other calculations and feels like a 'normal' integrator filter. And this solution also copes with every kind of non linearities without redesigning the whole stuff.
You just have to find some other resonance mapping function.
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post

Thanks for posting this. I've seen the paper on this stuff but, like most DSP literature, it obscures the central idea with an overly (IMO) formal presentation. I accept that the more formal treatments have their purpose but a lot of these ideas are really not that difficult when explained in a more straightforward way with a code example.

Post

Yep, this is exactly what we're doing in DIVA:

http://www.kvraudio.com/forum/viewtopic.php?t=302792

We've added a shitload of different nonlinearities into each filter type, and the iterative approach works brilliantly.

;) Urs

Post

neotec wrote:

Code: Select all

 IF ABS(newout - out) < epsilon THEN
Probably missing something obvious (and if i do probably others do as well) but what happens if that line doesn't evaluate to true ?
kuniklo wrote:Thanks for posting this. I've seen the paper on this stuff but, like most DSP literature, it obscures the central idea with an overly (IMO) formal presentation. I accept that the more formal treatments have their purpose but a lot of these ideas are really not that difficult when explained in a more straightforward way with a code example.
100% agreement here.

Post

Then it continues after the 'ENDIF' with out=newout and restarts the iteration at 'DO'.
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post

neotec wrote:Yep, I know the 'KeepTopology' stuff ... I just wanted to present a different approach (simple and hopefully understandable) which doesn't involve lots of other calculations and feels like a 'normal' integrator filter. And this solution also copes with every kind of non linearities without redesigning the whole stuff.
You just have to find some other resonance mapping function.
Yeah ok. We've discussed the iterative approach (and various simplifications of the same) before, but probably mostly hidden in random threads about filters.

Post

mystran wrote: Yeah ok. We've discussed the iterative approach (and various simplifications of the same) before, but probably mostly hidden in random threads about filters.
Hehe, yep, it's hard to follow all the filter threads scattered around the DSP forum. So apologies for reposting an already heavily discussed idea, but I was just to excited about the simplicity of this method and the sound of it :D
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post

Urs wrote:Yep, this is exactly what we're doing in DIVA:

http://www.kvraudio.com/forum/viewtopic.php?t=302792

We've added a shitload of different nonlinearities into each filter type, and the iterative approach works brilliantly.
I guess the only real downside is that since one needs plenty of oversampling to combat aliasing, and nice non-linearities (especially if you go one per stage) aren't really that cheap to begin with, it can get pretty nasty on CPU. :P

Post

mystran wrote:
Urs wrote:Yep, this is exactly what we're doing in DIVA:

http://www.kvraudio.com/forum/viewtopic.php?t=302792

We've added a shitload of different nonlinearities into each filter type, and the iterative approach works brilliantly.
I guess the only real downside is that since one needs plenty of oversampling to combat aliasing, and nice non-linearities (especially if you go one per stage) aren't really that cheap to begin with, it can get pretty nasty on CPU. :P
Of course. But it sounds great.

A positive thing is that prediction gets easier with oversampling factor. Thus oversampling 16 times does not cost twice as much cpu as oversampling 8 times.

;) Urs

Post

Urs wrote: Of course. But it sounds great.

A positive thing is that prediction gets easier with oversampling factor. Thus oversampling 16 times does not cost twice as much cpu as oversampling 8 times.

;) Urs
Yep, using higher oversampling reduces 'f' and also the signal changes between samples, so the difference in CPU power usage isn't that heavy.

and +1 to 'but is sounds great' :D
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post

Just wondering... how many loop iterations are we talking about here, typically?
Is the approach 'lighter' than, say, 4x oversampling (which I recently fiddled with on a ladder-type)?
How'd you specify epsilon? Like -90dB or so? Isn't that frequency-dependent, btw.?

I would also guess the crucial part is optimising the iteration part for parallel calculations (for instance, 4 voices), as there's branch prediction involved, right?
Sascha Eversmeier
drummer of The Board
software dev in the studio-speaker biz | former plugin creator [u-he, samplitude & digitalfishphones]

Post

sascha wrote:Just wondering... how many loop iterations are we talking about here, typically?
Is the approach 'lighter' than, say, 4x oversampling (which I recently fiddled with on a ladder-type)?
How'd you specify epsilon? Like -90dB or so? Isn't that frequency-dependent, btw.?

I would also guess the crucial part is optimising the iteration part for parallel calculations (for instance, 4 voices), as there's branch prediction involved, right?
With a good prediction you can get 2-5 iterations typically. At high resonance and a lot of drive we're seeing up to 20 or so.

Post

sascha wrote:Just wondering... how many loop iterations are we talking about here, typically?
Is the approach 'lighter' than, say, 4x oversampling (which I recently fiddled with on a ladder-type)?
How'd you specify epsilon? Like -90dB or so? Isn't that frequency-dependent, btw.?

I would also guess the crucial part is optimising the iteration part for parallel calculations (for instance, 4 voices), as there's branch prediction involved, right?
Epsilon can be chosen in a very wide range, but I can't give any recipe. I'm using 1e-8 as epsilon. Just run some test to check the stability.

The less oversampling you use the more iterations it takes and the more you have to adjust the resonance gain for higher frequencies (which can get really nasty).

In my setup (filter at 512kHz) and cutoff in full audio range I see iteration counts from 1 to 5 using q > 4 (without non-linearities and without any prediction).
... when time becomes a loop ...
---
Intel i7 3770k @3.5GHz, 16GB RAM, Windows 7 / Ubuntu 16.04, Cubase Artist, Reaktor 6, Superior Drummer 3, M-Audio Audiophile 2496, Akai MPK-249, Roland TD-11KV+

Post Reply

Return to “DSP and Plugin Development”