Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8039/src
RCS file: /cvsroot/audacity/audacity-src/src/SampleFormat.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- SampleFormat.cpp 22 Sep 2006 07:03:54 -0000 1.13
+++ SampleFormat.cpp 1 Oct 2006 23:53:10 -0000 1.14
@@ -19,30 +19,15 @@
Floating-point samples use the range -1.0...1.0, inclusive.
Integer formats use the full signed range of their data type,
for example 16-bit samples use the range -32768...32767.
- This presents a problem, because either the conversion to
- or from a float would have to be asymmetric, or zero would
- have to be mapped to something other than zero. (A third
- option is to use a symmetric, zero-preserving mapping that
- might clip, and check for clipping...but this option is
- both uncompelling and slow.)
- Audacity chooses to use a symmetric mapping that doesn't
- preserve 0:
- 16-bit float 16-bit
- -32768 -> -1.000000 -> -32768
- 0 -> 0.000015 -> 0
- 0.000000 -> 0
- 32767 -> 1.000000 -> 32767
+ This means that reading in a wav file and writing it out again
+ ('round tripping'), via floats, is lossless; -32768 equates to -1.0f
+ and 32767 equates to +1.0f - (a little bit).
+ It also means (unfortunatly) that writing out +1.0f leads to
+ clipping by 1 LSB. This creates some distortion, but I (MJS) have
+ not been able to measure it, it's so small. Zero is preserved.
- Note that 0.0 (float) still maps to 0 (int), so it is nearly
- an ideal mapping. An analogous mapping is used between
- 24-bit ints and floats.
+ leads to some of the discussions that were held about this.
Note: These things are now handled by the Dither class, which
also replaces the CopySamples() method (msmeyer)