Csound Csound-dev Csound-tekno Search About

Re: Higher numerical precission in Csound

Date1999-06-06 17:56
FromMichael Gogins
SubjectRe: Higher numerical precission in Csound
Let's introduce some evidence to this discussion.

It is simply not true that Csound's internal precision equals or exceeds
that of professional audio gear. This may be true of some semi-professional
gear, but it is not at all true of really high-end gear.

At the high end, the Otari Advanta system, to pick one off the Web, uses 40
bit samples internally for 24-bit input and output. The Studer mixing
consoles such as the D950 do the same. To pick another off the Web, the Sony
DPSV55 signal processing unit offers 20 bit inputs and outputs but uses 52
bit samples internally. Note too that Microsoft's DirectSound software
explicitly allows for 64-bit sample sizes.

In other words, professional audio practice is to use at least 40 bit
samples internally, which is far better than Csound.

At the semi-professional level, the Yamaha 01V mixer has 20 bit inputs and
outputs but uses 32 bit samples internally. Similarly, the Mackie Digital
8-Buss mixer uses 24 bit inputs and outputs but 32 bit samples internally.

As the above evidence indicates, it has been a common practice for decades
in professional digital audio hardware and software to use internal sample
sizes far in excess of the input and output sample sizes. Even the
semi-professional gear follows this practice, only at a lower level of
precision.

The human ear has a precision of somewhere between 24 and 32 bits. Assume
that the digital audio samples coming into a system are 32 bits. Only a few
arithmetic operations are required to introduce audible noise and blurring
into the signal. If, however, 64 or 80 bit samples are used, dozens of
operations can be performed without the noise floor cutting into the 32 bits
of the input signal. As a result, there will be no audible degradation of
the signal by round-off errors. Even if only 24 bits of precision are coming
into the system, it will only take a dozen or so operations to raise the
noise floor. This is not a great deal of filtering or mixing, and makes it
very clear why professional gear tends to shoot for at least 40 bits.

If Csound were to follow standard professional audio engineering practice,
it would support its 32 bit inputs and outputs with 64 or 80 bit internal
samples.

-----Original Message-----
From: paul winkler 
To: Csound 
Cc: Josep M Comajuncosas ; Sean Costello

Date: Saturday, June 05, 1999 5:25 PM
Subject: Re: Higher numerical precission in Csound


>I would like to throw my hat in as one of those who DON'T want
>double-precision computation to be the default. It's worth noting that
>Csound's internal precision equals or exceeds that of extraordinarily
>expensive "pro audio" software and hardware (a signal path that
>maintains at least 24 bits of integer precision from start to end is
>considered quite good; speed is always a concern, so probably most
>commercial software systems don't use doubles except for rare cases that
>really require it, and maybe not even then).
>
>I understand that some folks want more precision for some purposes, and
>they should have it, but not at the expense of everything running slower
>on most of the hardware in existence. I think a compile-time type
>selection would get us all what we want.
>
>--Paul Winkler

Date1999-06-06 22:35
FromEd Hall
SubjectRe: Higher numerical precission in Csound
Michael Gogins wrote:
> It is simply not true that Csound's internal precision equals or exceeds
> that of professional audio gear. This may be true of some semi-professional
> gear, but it is not at all true of really high-end gear.

Great!  So if you believe that 24-bit, 96Ks/s audio is essential and that
every LSB is sacred, compile Csound with doubles, set sr=96000 and kr=96000,
output in floats or 32-bit ints, and be happy.  But why force this on the
rest of us?

I can easily see why audio gear using fixed-point computation would need
at least 48-bit internal data to avoid overload.  (16-bit level X 24-bit
sample is 40 bits; summing 64 channels of these would need 8 more bits
of overhead; scale only on output.)  Floating point has some real
advantages--a 32-bit float has 254 bits of dynamic range.  And given how
much DSP power a few dollars buys these days, if the chip your mixer is
built on supports 64-bit floating point, why not use it?  In a mixing application, you have cycles to burn.  It looks good on the spec sheet,
anyway.  But is it audibly better than 32-bit floating point?  IMHO, no.

> The human ear has a precision of somewhere between 24 and 32 bits.

Where does this number come from?  And doesn't it conflate resolution
and dynamic range?  The 96dB dynamic range of 16-bit samples is arguably
too small, but that's different than saying that 16-bit resolution is too
small.  There is much less evidence of the latter, and the arguments
I've heard for adding more than a bit or two of resolution have amounted
to hand-waving, at best.

> Assume
> that the digital audio samples coming into a system are 32 bits. Only a few
> arithmetic operations are required to introduce audible noise and blurring
> into the signal.

Where in the (real) world are you going to get 32-bit samples?  Even pro
A/D's only give you 20 bits or so above noise floor (120dB s/n ratio).

> If, however, 64 or 80 bit samples are used, dozens of
> operations can be performed without the noise floor cutting into the 32 bits
> of the input signal.

That's a 192dB noise floor you're talking about, there.

> As a result, there will be no audible degradation of
> the signal by round-off errors. Even if only 24 bits of precision are coming
> into the system, it will only take a dozen or so operations to raise the
> noise floor.

Well, actually, only one, since 32-bit floats have 24-bit mantissas.  But
24 bits represents a 144dB noise floor.  Error estimation for floating-
point calculation is notoriously difficult (dissertations are written on
it), but in the cases of scaling (multiplication) and mixing (addition),
we gain about 1/2 LSB of noise for each operation.  Thus we've lost a bit
less than 6 bits (log2 (100 * 1/2)) after 100 operations.  Our noise floor
is now around 110dB--for any musical purpose, still inaudible; it's way below
the 96dB maximum of a CD (a figure rarely achieved in practice).  And
we've assumed that we're mixing samples of roughly the same level--the
effective noise floor increases if a few signal sources predominate.

> This is not a great deal of filtering or mixing, and makes it
> very clear why professional gear tends to shoot for at least 40 bits.

See my first paragraph--there are other reasons for this.

> If Csound were to follow standard professional audio engineering practice,
> it would support its 32 bit inputs and outputs with 64 or 80 bit internal
> samples.

"Support," yes.  Mandate, no.

I've no more free time for this (or any) discussion at this point.  It's
only my opinion, but I'll let it stand or fall on its merits: there are
few musically justifiable reasons for the general use of 64-bit floating
point in Csound.  On most, if not all, platforms it increases performance
times with little justification.  A few opcodes might be usefully improved
by using it internally, but this should be decided on a case-by-case basis.
Run-time performance matters, for very practical reasons.

And one final opinion: The ultimate test of any feature or change in Csound
should be its utility to the composer, period.

		-Ed