Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAxx filters' frequency parameter not scaled properly #28

Open
devilfish707 opened this issue Dec 20, 2021 · 9 comments
Open

VAxx filters' frequency parameter not scaled properly #28

devilfish707 opened this issue Dec 20, 2021 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@devilfish707
Copy link

Describe the bug

Cutoff frequency of all the zdf filters is scaled too high

To Reproduce

{ VALadder.ar(Saw.ar(200), 50)}.freqscope

Screenshots
Schermafbeelding 2021-12-20 om 22 46 13

Desktop (please complete the following information):

  • OS: MacOS Big Sur 11.6.1
  • Architecture: M1 (rosetta)
  • SC Version: latest
  • PortedPlugins Version: latest
@jamshark70
Copy link

I can confirm.

// clearly audible resonance at 440 Hz
// 440 / 144 ~= 3
a = { (VALadder.ar(Saw.ar(110), 144, 0.99, 0) * 0.1).dup }.play;

At 44.1 kHz, this x3 ratio seems to hold consistently, e.g., if I set the cutoff to 110, then I clearly hear the third harmonic 330 Hz resonating.

Work-around-able by writing SynthDefs with ffreq * 0.33333333 perhaps, but better to fix it.

@madskjeldgaard
Copy link
Owner

I agree - this is definately a problem. Also, kind of related: It sounds to me like the filters have too much gain boost even on low settings. I think this should be fixed in the code. If anyone feels like doing a PR that would be amazing - otherwise I will get around to it some rainy day. Thanks!

@jamshark70
Copy link

This appears to be independent of sample rate btw -- I've tried at 44.1 kHz and 96 kHz, and they both seem to sound the same.

@madskjeldgaard
Copy link
Owner

This appears to be independent of sample rate btw -- I've tried at 44.1 kHz and 96 kHz, and they both seem to sound the same.

Thanks. That's a helpful observation. I have a suspicion that the problem might be somewhere around here, but I'm not sure yet. It's only a hunch so far:

https://github.com/madskjeldgaard/portedplugins/blob/main/plugins/odinfilters/Korg35Filter.cpp#L51

Particularly the first part - I suspect that the first part should not be 2 * samplerate but 2 / T where T is 1/samplerate.

This is what that section looks like in William Pirkle's Designing Synthesizer's book (first edition):

double wd = 2*pi*Fc;     
double T = 1/SampleRate;       
double wa = (2/T)*tan(wd*T/2); 
double g = wa*T/2;  // <--- i.e. g = tan(wd*T/2)   
// --- final calculation
double alpha = g/(1.0 + g);

@madskjeldgaard madskjeldgaard changed the title ported plugins filters frequency not scaled properly VAxx filters' frequency parameter not scaled properly Jan 4, 2022
@madskjeldgaard
Copy link
Owner

A slightly related issue here. I think these filters need a little overhaul #30

@jamshark70
Copy link

Particularly the first part - I suspect that the first part should not be 2 * samplerate but 2 / T where T is 1/samplerate.

But, if t = 1/sr, then 2/t == 2 / (1/sr) == 2 * sr.

TBH my filter theory isn't that good... would take awhile for me to spot it.

@madskjeldgaard
Copy link
Owner

Particularly the first part - I suspect that the first part should not be 2 * samplerate but 2 / T where T is 1/samplerate.

But, if t = 1/sr, then 2/t == 2 / (1/sr) == 2 * sr.

TBH my filter theory isn't that good... would take awhile for me to spot it.

haha good point - also explains why there was no difference when I messed with this ;)

@madskjeldgaard madskjeldgaard added the help wanted Extra attention is needed label Jan 16, 2022
@jamshark70
Copy link

One other detail: VALadder and VAKorg35 seem to filter at the given frequency * 3. VADiodeFilter is at given frequency * 2.17. No idea why.

@madskjeldgaard
Copy link
Owner

Comparing to the port of the same filters and code in the Odin project I honestly cannot tell the difference between how we do it and how they do it.

https://github.com/surge-synthesizer/surge/blob/main/src/common/dsp/filters/K35Filter.cpp#L66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants