I’m interested in making some funky nonlinear/adaptive filter/distortion modules, so I am trying to learn more about traditional filters. Besides reading books and articles and watching videos (e.g. Leonardo Laguna Ruiz), I am also trying to understand some of the source code for existing filters in VCV. I started with the Fundamental VCF module, since I thought that might be one of the simpler ones. I have a few questions, many thanks in advance for any answers:

The low-pass filter in the VCF module is modeled on a Moog 4-stage filter, using what seems to be a slightly unusual technique of simulating the circuits through differential equations (as opposed to zero/pole placement or Z-transform analysis). The closest description I could find to this was a Raph Levien paper (https://levien.com/ladder.pdf), although he did some strange exponentiation of a linearized version of the equations instead of the 4th-order Runge-Kutta method that is used by VCF (which I haven’t been able to find a reference for in this context, although Levien mentions it as a possible method). Was this a novel approach? If there is a published analysis of this approach I’d like to read it.

The high-pass output of the Fundamental VCF does not work correctly, as has been noted on this forum already, and it is also noted in the source code. I’ve spent quite a bit of time trying to fix it unsuccessfully. As far as I can tell, it is trying to use a spectral inversion techique on the output of the RK4 simulation to convert the low-pass information to a high-pass filter. I haven’t found any reference that discusses that sort of technique, so if anyone knows of one I’d appreciate it. There are a number of analyses of the Moog filter that relate it to more traditional IIR filters, and using that approach a spectral inversion would be relatively straightforward, but I don’t see a direct connection to the information generated by the ODE approach. Perhaps it would be better to just replace this with a biquad highpass resonant filter?

As the Fundamental VCF turned out to be a longer educational rabbit-hole than I anticipated, does anyone have any suggestions for an open-source filter in VCV that would be particularly simple to look at? I am also curious about any references that filter authors have found exceptionally clear and useful.

they are mostly pretty complicated. the moog lowpass thing has a lot of literature. You need to solve the differential equations to implement a zero delay non-linear filter. Most of the filters in VCV are a) closed source, and b) pretty fancy. I have some that aren’t so fancy. Many of mine use the classic “Chamberlain” state variable filter. It’s in Formants, Growler, and Shaper. My “Stairway”, is a non-linear moog fake, but instead of solving the math for a zero delay filter I use 4X oversampling to mitigate it. You might have better luck with any of those. Have you read “The Arto of VA filter Design” by Vadim Zavalishin? It’s covers a lot of this stuff.

ok. just keep in mind that filter design is pretty hard as far as DSP stuff. It’s not intuitive at all, and it either required a LOT of math and engineering or requires finding a cookbook with exactly what you need. So - what you are trying to do is about as hard as it gets here.

btw, I notice someone else here just posted a link to their dafx paper on non-linear biquads. sounds interesting.

Z-transforms and zeros/poles mainly deal with LTI filters. The most interesting filters are nonlinear, and most analog hardware filters are nonlinear, which can’t be described with LTI language. The language of circuit modeling is ODEs, so most analog models will be ODEs.

I think I’ve fixed this in my local branch thanks to an error spotted by Andy Simper. I don’t know if I’ve pushed it yet, or if I’ve planned for it to be released in Fundamental v2.0.0. It’s a one-line fix.

Audible Instruments Ripples is well-written and sounds great with moderately low CPU.

I also found this repo (https://github.com/ddiakopoulos/MoogLadders) very useful. We are expanding the filter set in surge right now, and as a test case I copied his RK Ladder Simulator model and it sounds good. (I haven’t looked inside Fundamental VCF to see if the code is the same). While we have our own models we are working on and I don’t think we will ship surge with that simulator intact, it was helpful as a worked example of a filter infrastructurally.

I’m slowly working my way through some of the Julius Smith literature (on a bit of a hiatus with work and grad school taking up a lot of time). I haven’t published any filters, but I would like to at some point. I’ll link the Smith books below. Forgive me if you’re already aware of it/it’s not helpful

Here’s some stuff on digital filters (but I think it does have some resources to look at for nonlinear/analog models based on the TOC) https://ccrma.stanford.edu/~jos/filters/

This was my paper! I’m hoping to eventually do something Rack-ish with them, though I don’t currently have any clear ideas. I’d be more than happy to take suggestions, or collaborate with others.

My preferred way of dealing with zero-delay nonlinear filters is outlined in this AES paper by Dave Berners and Jonathan Abel (Universal Audio and CCRMA). Unfortunately, it’s behind an AES paywall, but I have a PDF copy if anyone wants to know some of the details. What’s nice about their method is that you can actually go through and use Z-transforms/other LTI methods for most parts of the system, and then set up a generalized Newton-Raphson solver that typically needs only a couple iterations to converge.

I did a little writeup a couple months ago on resolving delay-free loops if anyone’s interested: https://ccrma.stanford.edu/~jatin/papers/DelayFreeLoops.pdf. I have JUCE/C++ code for it as well, though it’s pretty messy, but I’m happy to share if folks are interested.

Hey @jatinchowhury18 and @hamptonio,
Was wondering if either/both of you would be interested in collaborating on extensions to the Box of Revelations module that we (well, I guess I) just released. Its basically a riff on the Morpheus Eurorack module - seven filters that can be put in any serial/parallel combination and each filter can be LP/HP/BP/Notch etc. - Right now using standard BiQuad filters - mainly because there is a formula for plotting their frequency response.

That said - I would love to add some additional, weird, filter models to it. I’m reading Vadim’s book now, but it would be nice to split the workload.

I’m interested, but I’m not sure I’m at a point yet of being very helpful - I think I still need to learn quite a bit. I have a strong background in differential equations, but not EE-related stuff or traditional filters. One of my next projects was going to be a “filter” (maybe more of a distortion effect) that took one or more inputs and added them as perturbations to various dynamical systems such as the Rossler system (https://en.wikipedia.org/wiki/Rössler_attractor). So sort of like Vult’s Caudal but with an input, and for audio rate oscillators. I think it will be a little tricky to have it sound OK.

By the way, I like the Probably Not(e) - Arabic module, I bought Inside Arabic Music based on your comments on it. Still plowing through that too.

I seriously don’t know how this would work. I’m years removed from my college applied mathematics classes so I am slowly getting back into this math. I guess if you have some cool filter equations to throw in, or even better, given a filter, plot its response (since we are displaying that). Seems like having a math resource like you would be good to have.

Interested in hearing your distortion effect, since I am a big fan of those - I’m mainly a death/black metal guitar player so distortions are my jam. One of my favorite plugins is Ohmicide by Ohm Boys - a quad band distortion effect with tons of non-linear, weird models. would love to bring something like that to VCV

Thanks for the kind words about PN -Arabic, that was a total labor of love. I tried reaching out to the author of Inside Arabic Music thinking he we would love seeing his work applied in a modern setting but never heard back /

@almostEric, thanks for the offer! I feel like my nonlinear biquad structures might work well for this. I’m checking out the module now, maybe I can make a pull request later on…

I am curious, what would a plot of a non linear filter look like, do you have any links please, as my quick google search did not show any results I expected. I ask as I was about to enquire if you had considered plotting the FFT of the impulse response, as I have done in the past, but this would only work for linear.

In general, nonlinear filters don’t have a well-defined “frequency response” that you could plot. However, there are still a few things you can do to get a frequency response-like plot that gives useful information.

First you need to choose an “operating point” for your system, essentially the level at which you send signal through your system, since the behavior of nonlinear systems can change at different operating points. Then you can either send an impulse or a sine-sweep through the filter at the level of the operating point, and use that to measure the frequency response directly, or you can “linearize” the system about the operating point, and find the frequency response analytically.

The problem with the first method is that you can end up with a noisy frequency response measurement (for an example, see this example of my nonlinear filter plugin). With the analytic approach, the only issue is the difficulty of the math, which varies depending on the system, but it usually ends up looking like a linear frequency response, just with a dependence on the operating point. Either approach can work well, depending on the system being plotted, the visual style you’re going for, and what you consider useful visual feedback.

Thanks for the description and video. I was really unsure of what style of plot to expect. I was thinking that it may have been a 3d plot, with the third axis the operating point, but I have limited experience in this field so that was a guess. Your video helped clear this up.

The VCF module in Fundamental is a direct RK4 approximation to the idealised non-linear differential equations first made by Antti Huovilainen, published in his 2004 DAFX paper Non-Linear Digital Implementation of the Moog Ladder Filter. Raph Levien is using Forward Euler based integration, and combining the state increment into the matrix, and then multiplying the matrix by itself to oversample based on using the same input for each stage of oversampling. When repeating A = A.A the say 10 times, the entire matrix fills in, and you are left with a dense 5x5 matrix, which you compute the output directly from the previous time input and the previous states. A new dense matrix would need to be computed for every change in cutoff and resonance, so there would be 5x5 entries each with 5 mults and 4 additions, and that done 10 times, which is 5.5.(5+4).10 = 2250 numerical operations per sample for audio rate modulation, just to compute the A matrix.

The RK4 algorithm needs input samples for times: t-1, t-3/4, t-1/2, t-1/4, and t, so these have to be interpolated if you only have inputs at integer offsets. I have already talked to Andrew Belt about this, and got him to update his RK4 algorithm to include linear interpolation for these terms, as well as using the correct output terms as well for the best possible cancelling of the stages to generate a high pass output. RK4 isn’t phase accurate so the high pass deteriorates at high frequencies, but it’s at least a bit better now, the analysis of this gets complicated, as the RK4 terms, when expanded, are a bit of a mess.

As already pointed out, accurate solutions to highly non-linear resonant filters can be quite involved. I personally use a modified trapezoidal integration and implicit iterative matrix solver to tackle this stuff. I suggest if you want to explore a basic trapezoidal based non-linear Moog filter then check out this KVR thread: Cheap non-linear zero-delay filters - DSP and Plug-in Development Forum - KVR Audio