logicomacorp / WaveSabre

Official WaveSabre repository
MIT License
245 stars 33 forks source link

Investigate potential improvements to StateVariableFilter #73

Open yupferris opened 3 years ago

yupferris commented 3 years ago

This is a decent and very compact filter design, ultimately originating from [1] (though in this particular case I believe I took the code from Sonant, and somewhere online before that). Its derivation is covered here (among many other places).

However, this particular filter construction has known instabilities at higher frequencies. To get around this, we employ a simple 2x oversampling scheme, equivalent to a linear upsampling filter before the SV filter, and a 2-tap moving average filter after. This setup effectively halves its (normalized) cutoff frequency, thus avoiding said instabilities (note that “avoiding” is used here instead of “eliminating” as I haven’t actually analyzed/proved it properly; I can only say I haven't experienced/heard of of any instances where it's “popped” in a very long time!).

While the code for this is very simple, the up/downsample processes alone are likely introducing noticeable artifacts even in the absense of the actual SV filter, which surely degrades the perceived quality of the SV filter itself. It's likely that with a bit of investigation, we can find a similarly-cheap, yet more-transparent strategy, so we should look into this.

Alternatively, since this filter is used wherever an "analog-style"/"coloring"/"non-surgical" filter is desired (eg. in the synths and many creative effects), it's possible that another filter topology (perhaps VA or similar) that's inherently stable (thus avoiding up/downsampling entirely) is more attractive altogether.

[1] H. Chamberlin,Musical Applications of Microprocessors, Second Edition, New Jersey: Hayden Books,1985.