Is this a basic MA filter?
- KVRist
- Topic Starter
- 183 posts since 18 Nov, 2017
Hi folks...
which kind of filter is this in your opinion?
https://github.com/Geonkick-Synthesizer ... c/filter.h
https://github.com/Geonkick-Synthesizer ... c/filter.c
I just see two buffers and no coefficients at all on it (except factor for q):
https://github.com/Geonkick-Synthesizer ... ter.c#L276
basic Moving Average filter?
Never encountered it before
Thanks
which kind of filter is this in your opinion?
https://github.com/Geonkick-Synthesizer ... c/filter.h
https://github.com/Geonkick-Synthesizer ... c/filter.c
I just see two buffers and no coefficients at all on it (except factor for q):
https://github.com/Geonkick-Synthesizer ... ter.c#L276
basic Moving Average filter?
Never encountered it before
Thanks
- u-he
- 28113 posts since 8 Aug, 2002 from Berlin
It's a Chamberlin state variable filter.
I would have to look, but it seems to be pretty much 100% exactly the topology, just different variable names.
I would have to look, but it seems to be pretty much 100% exactly the topology, just different variable names.
- u-he
- 28113 posts since 8 Aug, 2002 from Berlin
- KVRist
- Topic Starter
- 183 posts since 18 Nov, 2017
I know this Chamberlin version: https://www.musicdsp.org/en/latest/Filt ... rsion.html
But seems a little different? Here it uses 2 buffers (D1/D2) instead of 3 distinct buffer (for L/H/B).
Another implementation?
- u-he
- 28113 posts since 8 Aug, 2002 from Berlin
so this is the actual filter algorithm:
Here, if h is saved or not has no effect on the equation - it gets replaced first thing and no h[n-1] term is used. Storing h is actually not important at all afaiaa. If it's stored for any reason, I can't see it from the filter code. Maybe there is, but by all means, above algorithm is a Chamberlin SVF
Code: Select all
h[n] = in_val - l[n - 1] - Q * b[n - 1];
b[n] = F * h[n] + b[n - 1];
l[n] = F * b[n] + l[n - 1];
- KVRist
- Topic Starter
- 183 posts since 18 Nov, 2017
Ok I'll give a try.Urs wrote: ↑Wed Feb 07, 2024 8:49 am so this is the actual filter algorithm:
Here, if h is saved or not has no effect on the equation - it gets replaced first thing and no h[n-1] term is used. Storing h is actually not important at all afaiaa. If it's stored for any reason, I can't see it from the filter code. Maybe there is, but by all means, above algorithm is a Chamberlin SVFCode: Select all
h[n] = in_val - l[n - 1] - Q * b[n - 1]; b[n] = F * h[n] + b[n - 1]; l[n] = F * b[n] + l[n - 1];
I've noticed that if the input signal goes above/below 1.0/-1.0f it introduces some weird glitches
But I'm not sure if its for some bugs or filter nature (for what I know this topology become unstable with higher freq, not higher level).
- KVRAF
- 7955 posts since 12 Feb, 2006 from Helsinki, Finland
I don't immediately see any non-linearity in the code, so the most likely culprint for "weird glitches" is probably some other code failing to gracefully handle signals exceeding the available dynamic range (eg. conversion to integer format for actual playback would be a common candidate).
- KVRist
- Topic Starter
- 183 posts since 18 Nov, 2017
Not sure: if I gain the signal with Filter Off, it just "hard clip". Instead, if I enable the Filter, I can see those glitch...mystran wrote: ↑Thu Feb 08, 2024 7:41 amI don't immediately see any non-linearity in the code, so the most likely culprint for "weird glitches" is probably some other code failing to gracefully handle signals exceeding the available dynamic range (eg. conversion to integer format for actual playback would be a common candidate).
Note: from code, the hard clip seems after the filter.
-
- KVRAF
- 1607 posts since 12 Apr, 2002
Actually, AFAIK, Chamberlin SVF is a combination of forward- and backward-Euler integrators, whereas this one is not. I think some people refer to both as Chamberlin, but the one here has, IIRC, a much worse frequency response than the Chamberlin's. To distinguish between the two I'm usually referring to this one as "naive", since it's implementing naive integration (off the top of my head I'm not sure if it's the same as backward-Euler) and "naive" feedback.Urs wrote: ↑Wed Feb 07, 2024 8:49 am so this is the actual filter algorithm:
Here, if h is saved or not has no effect on the equation - it gets replaced first thing and no h[n-1] term is used. Storing h is actually not important at all afaiaa. If it's stored for any reason, I can't see it from the filter code. Maybe there is, but by all means, above algorithm is a Chamberlin SVFCode: Select all
h[n] = in_val - l[n - 1] - Q * b[n - 1]; b[n] = F * h[n] + b[n - 1]; l[n] = F * b[n] + l[n - 1];
- u-he
- 28113 posts since 8 Aug, 2002 from Berlin
In my recollection this one has exactly the same code structure as the example in Chamberlin's book, but my memory might deceive me. I remember it to be HP response first, followed by BP/LP each with two multiplies with coefficients and added unit delays ("D1" and "D2").
I have the book in the office, I'll look it up if I don't forget.
(thinking about it, the distinction between states and unit delays might be what I've been missing and that's probably indeed the difference between this version and Chamberlin's, which has the extra steps of storing the delays at then end)
I have the book in the office, I'll look it up if I don't forget.
(thinking about it, the distinction between states and unit delays might be what I've been missing and that's probably indeed the difference between this version and Chamberlin's, which has the extra steps of storing the delays at then end)
- u-he
- 28113 posts since 8 Aug, 2002 from Berlin
- KVRAF
- 7955 posts since 12 Feb, 2006 from Helsinki, Finland
edit: I took a second look and noticed this at the top of the process function:Derozer wrote: ↑Thu Feb 08, 2024 7:53 amNot sure: if I gain the signal with Filter Off, it just "hard clip". Instead, if I enable the Filter, I can see those glitch...mystran wrote: ↑Thu Feb 08, 2024 7:41 amI don't immediately see any non-linearity in the code, so the most likely culprint for "weird glitches" is probably some other code failing to gracefully handle signals exceeding the available dynamic range (eg. conversion to integer format for actual playback would be a common candidate).
Code: Select all
if (isnan(in_val) || in_val > 1.0f || in_val < -1.0f) {
*out_val = 0.0f;
return GEONKICK_ERROR;
}
- KVRist
- Topic Starter
- 183 posts since 18 Nov, 2017
Yeah, I discover this right now without reading your comment hehe.mystran wrote: ↑Thu Feb 08, 2024 6:16 pmedit: I took a second look and noticed this at the top of the process function:Derozer wrote: ↑Thu Feb 08, 2024 7:53 amNot sure: if I gain the signal with Filter Off, it just "hard clip". Instead, if I enable the Filter, I can see those glitch...mystran wrote: ↑Thu Feb 08, 2024 7:41 amI don't immediately see any non-linearity in the code, so the most likely culprint for "weird glitches" is probably some other code failing to gracefully handle signals exceeding the available dynamic range (eg. conversion to integer format for actual playback would be a common candidate).So if the input exceeds 0dBfs (or is NaN) then the filter just returns error instead of processing that sample at all.Code: Select all
if (isnan(in_val) || in_val > 1.0f || in_val < -1.0f) { *out_val = 0.0f; return GEONKICK_ERROR; }
Yes, it's a sort of "clip" skipping some buffer value. Note that it returns error, but value the sample as 0.0f (i.e. *out_val = 0.0f), which is what used on return of the function.
So I think the "glitch" is because the filter doesn't process samples "in order"? A sort of clip+delay signal during filter...
Thanks
- KVRist
- 32 posts since 14 Jun, 2021 from Italy
Yeah I'd say that's it. Muting any sample that's not between -1 and 1 (AND skipping to tick the filter) sounds a bit extreme to me but I guess there must be a reason (I would've just hardclipped and muted any NaN sample).