Hmmm it's interesting because your approach should yield exactly the same results - matematically - as using a OnePole with a 14.05Hz cuotff at 44100 Hz: an increment proportional to the difference is actually what a OnePole filter with coefficients a
and 1 - a
does.
Your formula is
y = y1 + (x - y1) a
where:
x
is the "current input", i.e.: gTargetAmplitude
y
is the "current output", i.e.: gActualAmplitude
after the assignment
y1
is the "past output", i.e.: gActualAmplitude
before the assignment
The onepole is canonically written as:
y = ax + (1 - a)y1
, so:
y = ax + (1 - a)y1
y = ax + y1 - ay1
y = y1 + (x - y1) a
so this is the same as your formula for the same value of a
.
The formula used in the the OnePole
class to compute the a
coefficient (called a1
there) is:
b1 = expf(-2.0f * (float)M_PI * cutoff/_samplingRate);
a1 = 1.0f - b1;
for cutoff = 14.05 and sampling rate = 44100, we have a1 = 0.002
.