sfztools / sfizz

SFZ parser and synth c++ library, providing a JACK standalone client
https://sfz.tools/sfizz/
BSD 2-Clause "Simplified" License
405 stars 58 forks source link

The filters #30

Closed jpcima closed 4 years ago

jpcima commented 4 years ago

I attach an implementation of filters which matches ARIA near perfectly. (when implemented there)

It uses some very generic resonant filters, it showed to be quite easy to reproduce them.

Current: sfz-filters ~sfzfilters.dsp.gz~

Reference: https://sfzformat.com/opcodes/fil_type https://sfzformat.com/opcodes/fil2_type

Status:

New ARIA extensions:

Not implemented by ARIA:

Implemented by us, not in specification:

redtide commented 4 years ago

brf_2p is listed in SFZ1 fil_type, I kept them separated.

jpcima commented 4 years ago

@redtide edited. Also, added the All-pass and Notch.

jpcima commented 4 years ago

Here, I implemented the Hal Chamberlin state-variable filter. This one fits requirements to implement the *_sv opcodes, but needs way more precaution. chamberlin.dsp.gz

Reference: https://www.earlevel.com/main/2003/03/02/the-digital-state-variable-filter/

As noted from the article:

The main drawback of the digital state variable is that it becomes unstable at higher frequencies. It depends on the Q setting, but basically the upper bound of stability is about where f reaches 1, which is at one-sixth of the sample rate (8 kHz at 48 kHz). The only way around this is to oversample. A simple way to double the filter’s sample rate (and thereby double the filter’s frequency range) is to run the filter twice with the same input sample, and discard one output sample.

It means if we want to permit range up to 22 kHz, oversample by 3 and call the filter with 1/3 effective cutoff. (Assuming 44.1 kHz as FsMin)

jpcima commented 4 years ago

More general notes:

The cutoff is modulable, it means to recompute the filter coeffs, potentially at the audio rate.

jpcima commented 4 years ago

I made a multimode-filter wrapper class. It is a very simple API. https://github.com/jpcima/sfz-filters-experimental

It's probable that sfizz can use it like it is, however, it will be better if I make also a dedicated stereo wrapper, because then it can optimize filter computations further.

It permits modulation of Cutoff and Q. It works like this:

jpcima commented 4 years ago

Implemented most of filters in the sfz-filters-experimental repo above. I think code as ready to be copied into sfizz at this point.

From observation, state-variable variants don't have a lot of difference with ordinary biquads.

In the repo, you can find also a JACK Qt client if you'd like to test these filters.

jpcima commented 4 years ago

Added the Peaking EQ and shelves.

paulfd commented 4 years ago

Hi @jpcima and thank for all this work. I may not have time until this WE but I will prepare integration then and we can discuss more on a pull request if that's OK with you?

paulfd commented 4 years ago

Let's move this into the release, thanks alot!