Re: [linux-audio-dev] Fixing Freeverb and Denormals

From: Erik de Castro Lopo <erikd-lad@email-addr-hidden-nerd.com>
Date: Sat Jan 22 2005 - 03:36:44 EET

On Fri, 21 Jan 2005 17:17:43 +0000
Neil Klepeis <nklepeis@email-addr-hidden> wrote:

> Hi all,
>
> The denormal problem with freeverb/ardour on P-4's is killing me.
>
> Since CMT plugin development seems to be a little stagnant, I decided
> to take it into my own hands a bit, but I might need a little help from
> a kind someone out there. Is there anyone who can give me a tip on
> proper syntax for changing the denormals.h file in freeverb (assuming
> this is where the problem lies)?
>
> Details:
>
> On this list and/or posts elsewhere I found that the denormals.h file
> for freeverb doesn't work too well with some newer gcc compilers; one
> recommendation was to exchange the first statement below with the second
> definition:
>
> #define undenormalise(sample) if(((*(unsigned
> int*)&sample)&0x7f800000)==0) sample=0.0f

I think your mail client has wrapped something incorrectly there.

Personally , I would avoid doing this useing integer operations and I
would also avoid macros; inline functions are simply so much better.

> static inline float
> undenormalise(volatile float s)
> {
> s += 9.8607615E-32f;
> return s - 9.8607615E-32f;
> }

That looks OK to me, and the optimiser should not discard it because s
is volatile. Have you looked at the assembler output?

> #define static inline float undenormalise(volatile float s) { s +=
> 9.8607615E-32f; return s - 9.8607615E-32f; }

That is definitle WAAAAAY wrong. what you are doing there is replacing
all instances of the string "static" with "inline float ......".

> You can probably see that I have no idea what I'm doing, but this seems
> like it should be so _simple_.

The static inline function you have above should be OK. Look at the
assembler output (use gcc -S to generate assembler) to make sure that
the addition and subtraction isn't being optimised out.

> Maybe now is the time to go read up on C++.

There's never a good time to read up on C++

Erik

-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  nospam@email-addr-hidden-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"To me C++ seems to be a language that has sacrificed orthogonality
and elegance for random expediency." -- Meilir Page-Jones
Received on Sat Jan 22 04:15:25 2005

This archive was generated by hypermail 2.1.8 : Sat Jan 22 2005 - 04:15:26 EET