Re: [LAD] Floating point Denormals: C++ and Waf

From: Tim Goetze <tim@email-addr-hidden>
Date: Thu Aug 02 2012 - 23:11:52 EEST

[David Robillard]

>On Thu, 2012-08-02 at 20:31 +0200, Martin Homuth-Rosemann wrote:
>[...]
>> // denormals are zero
>> static inline float daz( float f )
>> {
>> // define an aliasing type to perform a "reinterpret cast"
>> typedef __u32 __attribute__ (( __may_alias__ )) u32bit;
>> if ( *( (u32bit*)&f ) & 0x7F000000 ) // E > 1 : normal.
>> return f;
>> else // E <= 1 : zero or _almost_ denormal
>> // (may become denormal with next operation)
>> return 0.0;
>> }
>[...]
>> float reverb( float xin )
>> {
>> static float yout = 0.0;
>> static float xv0, xv1, yv0, yv1;
>> float x, y;
>>
>> // additional feedback
>> x = daz( xin/8 + yout/64 );
>
>Branch per sample, eeck...

Not to worry about the aliased pointer ...

I think it's almost always a better idea to add an inaudible DC offset
or a square wave at the block interval or at Nyquist, whatever, all
less problematic than this (adorable but potentially slow) solution or
relying on specific FTZ/DAZ-capable hardware to run your code.

Tim
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri Aug 3 00:15:11 2012

This archive was generated by hypermail 2.1.8 : Fri Aug 03 2012 - 00:15:11 EEST