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