Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
Diode ladder filter
Goto page 1, 2, 3  Next
karrikuh
KVRist
- profile
- pm
PostPosted: Tue Apr 03, 2012 12:47 pm reply with quote
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.php?p=3794095#379409 5

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
----
Official Charlatan home page: www.blaukraut.info
Official Charlatan thread on KVR

Last edited by karrikuh on Thu Apr 05, 2012 12:35 pm; edited 1 time in total
^ Joined: 06 Apr 2008  Member: #177841  
antto
KVRAF
- profile
- pm
- www
PostPosted: Tue Apr 03, 2012 3:45 pm reply with quote
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
----
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
Urs
KVRAF
- profile
- e-mail
- www
PostPosted: Tue Apr 03, 2012 4:10 pm reply with quote
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.
^ Joined: 07 Aug 2002  Member: #3542  Location: Berlin
Urs
KVRAF
- profile
- e-mail
- www
PostPosted: Tue Apr 03, 2012 4:15 pm reply with quote
karrikuh wrote:

So you use the linear case for the feedback estimate? I'm not quite sure if I correctly understand...
^ Joined: 07 Aug 2002  Member: #3542  Location: Berlin
aciddose
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Tue Apr 03, 2012 4:45 pm reply with quote
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.
^ Joined: 07 Dec 2004  Member: #50793  
karrikuh
KVRist
- profile
- pm
PostPosted: Tue Apr 03, 2012 9:11 pm reply with quote
Urs wrote:
karrikuh wrote:

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
y0 = fast_tanh(x - k*y4);
y4 = g*y0 + s;
but my experiments show that a single iteration is just fine, especially with oversampling.
----
Official Charlatan home page: www.blaukraut.info
Official Charlatan thread on KVR
^ Joined: 06 Apr 2008  Member: #177841  
karrikuh
KVRist
- profile
- pm
PostPosted: Tue Apr 03, 2012 9:22 pm reply with quote
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!
----
Official Charlatan home page: www.blaukraut.info
Official Charlatan thread on KVR
^ Joined: 06 Apr 2008  Member: #177841  
antto
KVRAF
- profile
- pm
- www
PostPosted: Wed Apr 04, 2012 12:26 am reply with quote
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..
----
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
Urs
KVRAF
- profile
- e-mail
- www
PostPosted: Wed Apr 04, 2012 12:37 am reply with quote
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.
^ Joined: 07 Aug 2002  Member: #3542  Location: Berlin
antto
KVRAF
- profile
- pm
- www
PostPosted: Wed Apr 04, 2012 12:46 am reply with quote
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!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
Z1202
KVRist
- profile
- pm
PostPosted: Wed Apr 04, 2012 12:51 am reply with quote
karrikuh 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.
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 though Smile

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

Regards,
{Z}
Last edited by Z1202 on Wed Apr 04, 2012 12:54 am; edited 2 times in total
^ Joined: 11 Apr 2002  Member: #2472  
Z1202
KVRist
- profile
- pm
PostPosted: Wed Apr 04, 2012 12:52 am reply with quote
BTW, while analyzing the diode ladder I have found, why the first capacitor should have half the value of the others - this results in uniform equations for all stages Smile
^ Joined: 11 Apr 2002  Member: #2472  
antto
KVRAF
- profile
- pm
- www
PostPosted: Wed Apr 04, 2012 12:56 am reply with quote
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!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
Urs
KVRAF
- profile
- e-mail
- www
PostPosted: Wed Apr 04, 2012 12:59 am reply with quote
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.
^ Joined: 07 Aug 2002  Member: #3542  Location: Berlin
Urs
KVRAF
- profile
- e-mail
- www
PostPosted: Wed Apr 04, 2012 1:03 am reply with quote
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.
^ Joined: 07 Aug 2002  Member: #3542  Location: Berlin
All times are GMT - 8 Hours

Printable version
Page 1 of 3
Goto page 1, 2, 3  Next
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
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
Username: Password:  
KVR Developer Challenge 2012