Quantcast
Channel: KVR Audio
Viewing all articles
Browse latest Browse all 5492

DSP and Plugin Development • Is there not a better DC Blocker algorithm, because this one is broken!

$
0
0
The following DC Blocker code snippet can be found on several websites;

Code:

out = in - previousIn + 0.995 * previousOut;previousIn = in;previousOut = out;
Now it may be me doing something wrong, but for a saw waveform, where samples starts at -1.00 and gradually goes to 1.00, speed off course dependent on frequency (phase delta), instead of keeping the signal centered, it introduces a DC bias so signal will shift to about -1.18 to 0.82 at 220Hz. At lower frequencies, the bias is greater, at higher frequencies the bias is lower.

For a pure square wave, going from -1.00 and half way through going abruptly to 1.00, at the point where is shifts abrupt from 1- to 1, the above DC formula variables contains the following;

Code:

in = 1.00previousIn = -1.00previousOut = -.58
Which means out = 1.00 - -1.00 + 0.995 * -.58 = 1.4229

After a few iterations of the frequency, the signal settles into a range of -1.26 to 1.26. So the above DC Blocker code actually amplifies the signal.

I should mention my block of samples, buffer size is 512, meaning every 512 samples, I run those samples through the above DC Blocker algorithm.

Is there something I missed, doing wrong or is this just a quirk of the high pass filter / DC Blocker algorithm?

And if that is the way it works, does anyone know of a non-destructive DC Blocker algorithm. One that not only does not filter out low frequencies, and but one that also does neither introduce a bias, nor amplifies the signal?

Statistics: Posted by DKDiveDude — Sat Dec 30, 2023 4:36 pm — Replies 1 — Views 70



Viewing all articles
Browse latest Browse all 5492

Trending Articles