## Diode ladder filter

42 posts
• Page

**1**of**3**•**1**, 2, 3- KVRist
- 237 posts since 6 Apr, 2008

Hi everybody,

in my untamable obsession with emulation of analog filter circuits and my recent rediscovery of the simple beauty of 303 acid sequences I looked into the analysis of the diode ladder lowpass filter as found in the 303 or the EMS VCS3. I found the relevant system of differential equations presented by mystran in the Open303 thread:

http://www.kvraudio.com/forum/viewtopic ... 95#3794095

As you might be aware, compared to the Moog transistor cascade which has been discussed to death, modeling the diode ladder is much more complex due to the inherent coupling between filter stages. In the course of the above thread, several digital implementations were presented using classic methods like backward Euler, 1-sample delay in feedback path and corresponding tuning heuristic for correcting cutoff frequency/resonance gain.

During the (still ongoing) development of my synth Charlatan, I have made myself familiar with digital filter designs with zero-delay feedback paths which allows perfect tuning and accurate time-varying behavior. So, out of curiosity, I looked into applying this technique to the diode ladder. However, while this is relatively straight forward to apply to te Moog cascade with decoupled stages, the diode ladder becomes much more sophisticated. With the help of Mathematica, I eventually came up with a rather scary looking set of equations to solve the system of difference equations I had obtained via trapezoid integration rule. In contrast to the original differential equations, I figured it was enough to incorporate a single tanh-like clipper at the filter input. Long story short, I can present you a ready-canned C++ implementation you can use in your project (MIT license):

http://pastebin.com/THe5JG5f

In spite of zero-delay feedback, I strongly recommend at least 2x oversampled to avoid frequency warping and aliasing. To my pleasent surprise, the code is only slightly more CPU intensive than my Moog filter code which is much simpler. I hope you have some use for this! Enjoy! Of course, feedback is much appreciated!

BTW, I'm looking into extending the code to incoporate a HPF in the feedback path which is supposed to be present in the original 303 filter.

Update 04/05/2012

Version 0.2: greatly simplified equations; add highpass filter in feedback path

in my untamable obsession with emulation of analog filter circuits and my recent rediscovery of the simple beauty of 303 acid sequences I looked into the analysis of the diode ladder lowpass filter as found in the 303 or the EMS VCS3. I found the relevant system of differential equations presented by mystran in the Open303 thread:

http://www.kvraudio.com/forum/viewtopic ... 95#3794095

As you might be aware, compared to the Moog transistor cascade which has been discussed to death, modeling the diode ladder is much more complex due to the inherent coupling between filter stages. In the course of the above thread, several digital implementations were presented using classic methods like backward Euler, 1-sample delay in feedback path and corresponding tuning heuristic for correcting cutoff frequency/resonance gain.

During the (still ongoing) development of my synth Charlatan, I have made myself familiar with digital filter designs with zero-delay feedback paths which allows perfect tuning and accurate time-varying behavior. So, out of curiosity, I looked into applying this technique to the diode ladder. However, while this is relatively straight forward to apply to te Moog cascade with decoupled stages, the diode ladder becomes much more sophisticated. With the help of Mathematica, I eventually came up with a rather scary looking set of equations to solve the system of difference equations I had obtained via trapezoid integration rule. In contrast to the original differential equations, I figured it was enough to incorporate a single tanh-like clipper at the filter input. Long story short, I can present you a ready-canned C++ implementation you can use in your project (MIT license):

http://pastebin.com/THe5JG5f

In spite of zero-delay feedback, I strongly recommend at least 2x oversampled to avoid frequency warping and aliasing. To my pleasent surprise, the code is only slightly more CPU intensive than my Moog filter code which is much simpler. I hope you have some use for this! Enjoy! Of course, feedback is much appreciated!

BTW, I'm looking into extending the code to incoporate a HPF in the feedback path which is supposed to be present in the original 303 filter.

Update 04/05/2012

Version 0.2: greatly simplified equations; add highpass filter in feedback path

Last edited by karrikuh on Thu Apr 05, 2012 12:35 pm, edited 1 time in total.

- KVRAF
- 2372 posts since 4 Sep, 2006, from 127.0.0.1

hi ;]

at this very moment, i was working on the 303 filter for my synth too

and i think i'm finished

i used kunn's transfere function (which is a few posts down from where you linked)

with 1 nonlinearity only

i am monitoring/comparing the output of my synth with the output of my x0xb0x (which is a tb-303 clone) .. using sonogram and oscilloscope

i added a few hacks around my filter in order to get the same behaviour as the x0xb0x

but the filter itself has 1 sample delay in the feedback

a few weeks ago, inspired by neotec's thread about delayless feedback, i tryied to turn my ladder filter into delayless feedback

but, it failed

otherwise, i have quite good approximations for the a0 and k coefficients (works near perfectly for 4x oversampling)

and my nonlinearity is simply a hard clipper, so nothing too special there

my impression about the filter, the way it sits in the 303 is quite nasty

there are lots of things going on, i needed at least 4 HP filters around it, 2 gain compensations (one for compensating the loss in gain due to high resonance on high freqs, the other is part of the real synth, resonance pot to vca)

so uhm, i don't understand your code, but i'm interested for sure

i really want to understand how this delayless feedback works

at this very moment, i was working on the 303 filter for my synth too

and i think i'm finished

i used kunn's transfere function (which is a few posts down from where you linked)

with 1 nonlinearity only

i am monitoring/comparing the output of my synth with the output of my x0xb0x (which is a tb-303 clone) .. using sonogram and oscilloscope

i added a few hacks around my filter in order to get the same behaviour as the x0xb0x

but the filter itself has 1 sample delay in the feedback

a few weeks ago, inspired by neotec's thread about delayless feedback, i tryied to turn my ladder filter into delayless feedback

but, it failed

otherwise, i have quite good approximations for the a0 and k coefficients (works near perfectly for 4x oversampling)

and my nonlinearity is simply a hard clipper, so nothing too special there

my impression about the filter, the way it sits in the 303 is quite nasty

there are lots of things going on, i needed at least 4 HP filters around it, 2 gain compensations (one for compensating the loss in gain due to high resonance on high freqs, the other is part of the real synth, resonance pot to vca)

so uhm, i don't understand your code, but i'm interested for sure

i really want to understand how this delayless feedback works

It doesn't matter how it sounds..

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

- u-he
- 19208 posts since 7 Aug, 2002, from Berlin

antto wrote:with 1 nonlinearity only

don't.

Understanding the diode ladder is about understanding how multiple non-linearities in series are used to actually replace the "cutoff coefficients" in transistor ladders. The "cutoff coefficient" becomes an offset to the input signal (yes, the control voltage is basically mixed into the audio signal). This moves the input signal to a region where the non-linearities have an average delta that matches the cutoff coefficient in transistor ladder. Kind of. Look at it.

A single non-linearity may sound like it at certain settings, but the behavior will be completely off once modulating the cutoff.

- u-he
- 19208 posts since 7 Aug, 2002, from Berlin

karrikuh wrote:http://pastebin.com/i2c8ddh7

So you use the linear case for the feedback estimate? I'm not quite sure if I correctly understand...

- KVRAF
- 10640 posts since 7 Dec, 2004, from Vancouver, Canada

antto wrote:... the other is part of the real synth, resonance pot to vca)

while there may be some small effects due to the particular implementation, it would also make sense just to directly compensate loss due to the negative feedback.

that was, after all, the intention of that element in the circuit. any other effect it has is unintentional. (modelling the effect it has on the vca stage is fairly insignificant if you're not modelling the vca stage...)

the highpass filters in-circuit however have a significant effect so you do need those.

the non-linearity of the vca and the sziklai buffer ("mixer") have a significant effect though too.

- KVRist
- 237 posts since 6 Apr, 2008

Urs wrote:karrikuh wrote:http://pastebin.com/i2c8ddh7

So you use the linear case for the feedback estimate? I'm not quite sure if I correctly understand...

Exactly! In principle, to correctly solve the nonlinear feedback loop, you could do a few iterations

- Code: Select all
`y0 = fast_tanh(x - k*y4);`

y4 = g*y0 + s;

- KVRist
- 237 posts since 6 Apr, 2008

Urs wrote:A single non-linearity may sound like it at certain settings, but the behavior will be completely off once modulating the cutoff.

Urs, do you have some audio demo available to compare a digital filter implementation with a single clipper vs full implementation? I did a lot of experiments in this regard but did not find a notable improvement of the overall sound by using many nonlinearities but surely noted the higher CPU usage!

- KVRAF
- 2372 posts since 4 Sep, 2006, from 127.0.0.1

from what i know, in the 303, the VCO output is biased, BUT there is a HP filter right before the VCF stage, so it effectively kills that

the cutoff frequency to the VCF comes from R69 (the current) it gets mixed with the input signal in there, the input being very tiny, compared to the cutoff freq signal

my gut tells me, the input doesn't clip much (at all) when there's no resonance

Urs: do you suggest that cutoff and input should be put together like in the real filter?

karrikuh, maybe i should try your filter in my synth? i already got 4x oversampling going on for other reasons..

the cutoff frequency to the VCF comes from R69 (the current) it gets mixed with the input signal in there, the input being very tiny, compared to the cutoff freq signal

my gut tells me, the input doesn't clip much (at all) when there's no resonance

Urs: do you suggest that cutoff and input should be put together like in the real filter?

karrikuh, maybe i should try your filter in my synth? i already got 4x oversampling going on for other reasons..

It doesn't matter how it sounds..

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

- u-he
- 19208 posts since 7 Aug, 2002, from Berlin

karrikuh wrote:Urs wrote:A single non-linearity may sound like it at certain settings, but the behavior will be completely off once modulating the cutoff.

Urs, do you have some audio demo available to compare a digital filter implementation with a single clipper vs full implementation? I did a lot of experiments in this regard but did not find a notable improvement of the overall sound by using many nonlinearities but surely noted the higher CPU usage!

Well, we don't have anything exactly, but in Diva you can compare "ladder" to "cascade" where cascade has the interesting property of a single dominant non-linearity in the feedback path. Ladder sounds "creamy" while cascade sounds more "acidic", for the lack of better words. Mind you, cascade still has loads of non-linearities in-between, but they're not driven as hot.

- KVRAF
- 2372 posts since 4 Sep, 2006, from 127.0.0.1

aciddose wrote:while there may be some small effects due to the particular implementation, it would also make sense just to directly compensate loss due to the negative feedback.

that was, after all, the intention of that element in the circuit. any other effect it has is unintentional. (modelling the effect it has on the vca stage is fairly insignificant if you're not modelling the vca stage...)

the highpass filters in-circuit however have a significant effect so you do need those.

the non-linearity of the vca and the sziklai buffer ("mixer") have a significant effect though too.

when i say "vca" i don't mean much.. neither do i understand what happens in the vca circuit or the mixer

i just read the labels on the circuit diagram which says "VCF" and "VCA"

i've been told the output of the VCF is off C14, and C14 goes to two places:

1) to the "VCA" section into C21

2) to the resonance pot, after which it splits into two, one going back into the filter (C15) the other going to the "VCA" section into C21

i guess C21 and C20 are HP filters, so i've set them to 60 and 180 Hz respectively

It doesn't matter how it sounds..

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

- KVRian
- 683 posts since 11 Apr, 2002

I have found a way to solve those equations in a rather elegant way by hand, which possibly results in simpler solution formulas and more elegant implementation than the ones obtained with Mathematica. Multiple nonlinearities are not a problem there either, as you basically preserve the entire topology. Not sure how much detail I can reveal here without breaking my contractual obligations thoughkarrikuh wrote:With the help of Mathematica, I eventually came up with a rather scary looking set of equations to solve the system of difference equations I had obtained via trapezoid integration rule.

Edit: actually not sure if I really tried multiple nonlinearties there. It was a while back

Regards,

{Z}

Last edited by Z1202 on Wed Apr 04, 2012 12:54 am, edited 2 times in total.

- KVRAF
- 2372 posts since 4 Sep, 2006, from 127.0.0.1

i think it's very important to take into account the HPF effect inside the feedback.. i cannot get my head around that part of the circuit, it's complicated (and i'm not so smart)

It doesn't matter how it sounds..

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

..as long as it has BASS and it's LOUD!

irc.freenode.net >>> #kvr

- u-he
- 19208 posts since 7 Aug, 2002, from Berlin

antto wrote:Urs: do you suggest that cutoff and input should be put together like in the real filter?

I'm not sure. We haven't done that yet, but we can't wait to get all the boring stuff done to get started with this.

- u-he
- 19208 posts since 7 Aug, 2002, from Berlin

antto wrote:i think it's very important to take into account the HPF effect inside the feedback.. i cannot get my head around that part of the circuit, it's complicated (and i'm not so smart)

That's true for pretty much all filter topologies. It needs bit of brain wrecking, but it's worth looking at.