On Wed, Feb 13, 2013 at 10:36 PM, Romain Beauxis <[email protected]>wrote:

> Hi,
>
> 2013/2/13 Martin Konečný <[email protected]>:
> > Samuel,
> >
> > I'll report back with OCAML 4.00.1 results. However if that does not
> work,
> > it would be amazing to have this nofpu Liquidsoap.
> >
> > Just out of curiosity  I know floating point is used to represent a wide
> > range of values with a relative error constant, whereas fixed point is
> used
> > to represent a much smaller range of values but with higher precision.
> How
> > would this affect Liquidsoap - is there a reason Liquidsoap was
> originally
> > written in floating point, when these instructions are so much more
> > expensive? Is it easier to work with Floating P in the audio domain, or
> is
> > it some other reason?
>
> Good questions.. My 2 cents:
>
> Fixed-point arithmetic is a pain in the butt and, from the programmer
> point of view, it's always easier to let the compiler/CPU deal with
> those details. Beside, there is no standard representation for
> fixed-point (or fractional) numbers in C and OCaml, which means we'd
> have to re-implement our own arithmetic operations in both sides,
> which would again be a pain.


>From my point of view, the major problem of fixed-point is that you
constantly have to think about how to arrange operations in order to
achieve a good precision, while avoiding overflows. For instance, having a
volume of 90% is a simple matter of

x *= 0.9

in floats, whereas 0.9 does not mean anything in ints. So you might be
tempted to write

x = (x*10)/9

with integers, but then with typical samples (from -32767 to 32768), this
would result in an overflow on a 16bits arch. Granted there are not many of
those archs left, this is just to give you an idea, with a more realistic
realistic example you can easily get an overflow in a similar way. And
moreover, you constantly have to worry about bracketing operations,
precision, etc. For instance,

x = 10/9*x

does not change the volume...

Actually, we started implementing Liquidsoap in fixed-point and had many of
this kind of problems, which are quite hard to track, so we decided to
switch to floats.

++

Sam.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to