In reference to EQ #34 (See below) – The original implementor’s solution was to change the $offset value to 0xFF. Why did this work?
EQ#34
The following pseudocode represents an implementation of a single-pole low-pass IIR filter, using 16-bit input and output values and a 24-bit internal accumulator and a filter coefficient of 1/256:
#The 32-bit accumulator holds 16 integer
# and 16 fractional bits
$acc = 0x00000000;
# The input value is a 16-bit integer.
$input = 0xFFFF;
# Offset used for rounding the accumulator
# to 24 bits.
$offset = 0x80;
while (1) {
# acc = (255*acc + input)/256
$acc -= ($acc >> 8);
$acc += ($input << 8) + $offset; # limit acc to 24 bits $acc &= 0xFFFFFF00; # output is integer part of acc $output = $acc >> 16;
}
— ADVERTISMENT—
—Advertise Here—
An implementor of this filter complained that “the output never reaches 0xFFFF.”