This is based on code found in the document:
"Introduction to Digital Filters (DRAFT)"
Julius O. Smith III ([email protected])
Some audio algorithms (asymmetric waveshaping, cascaded filters, ...) can produce DC
offset. This offset can accumulate and reduce the signal/noise ratio.
So, how to fix it? The example code from Julius O. Smith's document is:
y(n) = x(n) - x(n-1) + R * y(n-1)
// "R" between 0.9 .. 1
// n=current (n-1)=previous in/out value
"R" depends on sampling rate and the low frequency point. Do not set "R" to a fixed value
(e.g. 0.99) if you don't know the sample rate. Instead set R to:
(-3dB @ 40Hz): R = 1-(250/samplerate)
(-3dB @ 30Hz): R = 1-(190/samplerate)
(-3dB @ 20Hz): R = 1-(126/samplerate)