On 11 May 2007, at 15:07, Fons Adriaensen wrote:
On Fri, May 11, 2007 at 03:33:04PM +0200, Lars Luthman wrote:

That sounds like a good argument for two ints to me. Although you'd have
to do a lot better than double if you wanted to represent irrational
numbers in binary form. =)

Two 32-bit ints can represent (the non-integer part of) most (not all)
irrational values to better precision than a double. The algo to find
them is a bit mysterious but very simple. Simple example: 355/113 is
equal to pi with a relative error of less than 1e-7, not bad for two
3-digit numbers. It's not difficult to find two 32-bit ints that would
be better than a double.

OK, so I ran some test code (http://plugin.org.uk/misc/num-denom-vs- double.c) and there is indeed a measurable drift when using double accumulators - if you have numerators and denominators that are float unfriendly - which is not /that/ unlikely. But, it's equivalent to a worst-case detune of less than 1/10000th of a cent as far as I can tell - not audible, but possibly measurable under extreme circumstances, as long as no analogue hardware is involved (which rules out listening to it for eg.).

So, this makes me marginally more sympathetic to the idea that it is useful, but I'm still not quite convinced that:

a) many people will bother to do their accumulators in integer space without rounding, and
b) hosts will have the sample rate available to them in that form.

If there's a plugin developer that will use integer pair accumulators (I guess Fons will?) and a host that will generate denominators other than a power of ten or two I'm happy to go with the int pair. It could also be that my maths is wrong.

My preference is still to go for a double, as the difference is too minimal to be audible, under any circumstances, and it makes plugin developers lives harder. LV2 is intended to be an audio plugin format, not for scientific uses. Of course if the host gets its sample rate as a double, it's a PITA, and generally lossy to convert that into num/denom.

- Steve
_______________________________________________
Linux-audio-dev mailing list
[email protected]
http://lists.linuxaudio.org/mailman/listinfo.cgi/linux-audio-dev

Reply via email to