num/denom v's double (was: Re: [LAD] [ANN] LV2 beta3)
Fons Adriaensen
fons at kokkinizita.net
Fri May 11 19:37:47 UTC 2007
On Fri, May 11, 2007 at 06:24:38PM +0100, Steve Harris wrote:
> On 11 May 2007, at 15:07, Fons Adriaensen wrote:
> >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.
First, if you read the paragraph above in its context, it should be
clear that this is *not* the rationale for having sample rates as
a ratio of two integers. It's just a side note.
(Sigh) I have already written (some nights ago) that this has nothing
to do with _absolute_ precision. Most sound cards are way off their
nominal sample rate anyway, and very few people complain.
This is about _relative_ precision in multirate processing. It only
works if the ratios are exact. It does not work at all if they are
not. I can easily imagine processing networks where not all plugins
run at the same rate, but at rates related by simple integer ratios.
Maybe improbable for music production. But certainly possible for
audio DSP work in general.
> b) hosts will have the sample rate available to them in that form.
??? In the current spec the sample rate is an integer. JACK and ALSA
will give you an integer. Just set the denominator to 1 if your host
runs all plugins at the normal sample rate, as most will do.
** That's really all there is to it. **
We may even require that if the sample rate is integer the denominator
must be set to 1. Simple plugins that can't do division and expect a
single integer can then refuse to instantiate if the denominator is
not 1.
:-)
--
FA
Follie! Follie! Delirio vano è questo !
More information about the Linux-audio-dev
mailing list