[openal] Feedback on OpenAL Soft's x86 build
Chris Robinson
chris.kcat at gmail.com
Fri Jun 22 01:38:09 EDT 2018
On 06/21/2018 04:52 PM, Lubomir I. Ivanov wrote:
> you probably know this already, but the way to deal with denormals
> when doing DSP on the x87 is with applying a small DC offset over the
> "state" of the unit doing the work.
>
> here is the Direct Form I difference equation of a biquad derived from
> the bilinear transformation:
>
> y = a0*x + a1*x1 + a2*x2 - b1*y1 - b2*y2;
> x2 = x1;
> x1 = x;
> y2 = y1;
> y1 = y;
> out = y;
>
> note that i don't know what biquad form is used in the openal code
> base, but if you link me to the source code lines for this i can tell
> more.
For the main/generalized biquad filter, OpenAL Soft uses Transposed
Direct Form II:
<https://github.com/kcat/openal-soft/blob/master/Alc/filters/filter.c#L110>
There are other filters it uses that are somewhat specialized, either
because it can reduce the amount of computations for its particular
use-case, or because it has needs that aren't well-served by the
generalized biquad. Like:
<https://github.com/kcat/openal-soft/blob/master/Alc/filters/splitter.c>
A low-pass with an associated all-pass used to split a signal into low
and high frequency bands. And:
<https://github.com/kcat/openal-soft/blob/master/Alc/filters/nfc.c> A
series of low-shelf filters of increasing order, using really low
reference frequencies that a biquad would have trouble with.
A number of effects have specialized feedback processing as well, like
the reverb's T60 filter and Gerzon all-pass filter.
> to apply denormal prevention you need to introduce a small DC offset;
> 1e-35 should work for both IEEE's binary32 and binary64.
>
> y = a0*x + a1*x1 + a2*x2 - b1*y1 - b2*y2 + DC;
> x2 = x1;
> x1 = x;
> y2 = y1;
> y1 = y;
> out = y - DC;
>
> notice how the DC offset is introduced in the state, but then removed
> when the output is obtained.
> so with a couple or less potential FLOPS (as you can also choose to
> omit the `- DC` subtraction part) you prevent denormals for any order
> DSP filter.
Yeah, I've seen code that does this. I'm sure it works at reducing the
potential of denormals, but it feels more like a band-aid than a proper
solution. Denormals can still be generated outside of the feedback loop,
for example in the coefficients or other unassociated pieces of code,
and they can also be passed in by the app. And in general, the x87 is
just not very efficient at following the IEEE-754 standard (not wholly
its fault since IIRC the x87 came before the standard, but still).
While it may be worth doing something like that for x87 builds, when you
care about performance it's generally just better to use SSE
instructions with denormals disabled if possible.
More information about the openal
mailing list