Sample Data Export/Import is “bit-perfect”/lossless?[SOLVED]

Help for Audacity 2.x.x on GNU/Linux.

ImageThis forum is for Audacity 2.x.x on GNU/Linux and Unix-like operating systems.
Please state which version of Linux you are using, the exact three-section version number of Audacity from Help > About Audacity... and whether you installed your distribution's release or daily version of Audacity or compiled Audacity from source code.

Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by steve » Tue Oct 24, 2017 1:56 pm

Here's another curious thing about decimal representation of floating point numbers:
Code: Select all
(setf *float-format* "%.1000g")
(print pi)
; returns 3.141592653589790007373494518105871975421905517578125

The actual value of PI is:
3.141592653589793238462643383279502884197169399375105...
so the value returned by Nyquist is only accurate to 14 decimal places.
3.14159265358979

Code: Select all
(setf *float-format* "%.1000g")
(print (- pi 3.14159265358979))
; returns 0


The binary representation of 3.141592653589790007373494518105871975421905517578125 is
01000000010010010000111111011011

The binary representation of 3.14159265 is
01000000010010010000111111011011

Note that these two binary numbers are identical. So in this particular case, digits beyond 8 decimal places are irrelevant.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by Kdmeizk » Tue Oct 24, 2017 2:23 pm

If “sample-data-export.ny” is accurate to 14 decimal places, all the rest is given “by magic”?

If “sample-data-export.ny” cannot handle more than 14 decimal places, is Audacity in the same case?
Kdmeizk
 
Posts: 30
Joined: Mon Mar 20, 2017 5:28 pm
Operating System: Windows 7

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by steve » Tue Oct 24, 2017 3:54 pm

Kdmeizk wrote:If “sample-data-export.ny” cannot handle more than 14 decimal places

That's not what I wrote.

It's a bit math-heavy, but this article explains a lot about floating point numbers: https://en.wikipedia.org/wiki/Single-pr ... int_format

The smallest positive number (IEEE standard) is about 0.0000000000000000000000000000000000000118
Nyquist and Audacity can handle this number.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by Kdmeizk » Wed Oct 25, 2017 2:14 pm

I have tested the thing incorrectly (because I changed the number manually in the text file, and as you said and your article, there are many decimal values which cannot be exactly represented in 32-bit float), sorry…

If my files are equal or less than 32-bit float (= 24-bit, 16-bit), 48000 Hz, 2 channels, with
Code: Select all
(setf *float-format* "%.1000g")

in Sample Data Export, Sample Data Import will put the values into Audacity, and all this processing is “bit-perfect”/lossless, right?
Kdmeizk
 
Posts: 30
Joined: Mon Mar 20, 2017 5:28 pm
Operating System: Windows 7

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by steve » Wed Oct 25, 2017 2:39 pm

With integer formats the whole thing becomes a lot more straightforward.

Example - 24-bit (integer):
The range of sample values is +/- 1.0 (* see below)
There are 2^24 24-bit numbers (= 16777216 discrete values)
"Normal" digital audio is PCM encoded, which divides the range +/- 1 into equal parts.
That gives 16777216 "steps" of 2/16777216. 8388608 are negative values, 8388607 are positive values, and there is zero. (** see below)

* The range is actually -1 to (1 - 1/8388607) because there is 1 less positive value than negative values.
** The waveform does not actually rise and fall in "steps" (https://www.xiph.org/video/vid2.shtml)

So we know that for 24-bit audio, the theoretically maximum precision is to the closest 1/8388607 = 0.000000119, so 7 decimal places is sufficient to give us the correct binary value (bit perfect).

Also worth noting that even the best studio sound cards cannot achieve 24 bit accuracy. The bottom couple of bits are just noise, so even a studio quality 24-bit sound card can achieve no better than about 22-bit accuracy. But that's not a problem because even "only" 22-bits is enough for fantastically high quality audio.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by Kdmeizk » Wed Oct 25, 2017 3:54 pm

Is it possible to use Sample Data Export to export 24-bit values (I have a file which is in 24-bit)? Or configure Audacity to not convert to 32-bit float?
Kdmeizk
 
Posts: 30
Joined: Mon Mar 20, 2017 5:28 pm
Operating System: Windows 7

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by steve » Wed Oct 25, 2017 4:16 pm

Audacity and Nyquist process in 32-bit float format regardless of the bit format.
Converting from 24-bit integer to 32-bit float is lossless because 32-bit float can represent 24-bit audio exactly, which means that the round trip from "24-bit -> 32-bit float -> 24-bit" is lossless (bit perfect).

There's really no up-side to using 24-bit integer (compared with 32-bit float), other than saving a bit of space in file storage.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by Kdmeizk » Wed Oct 25, 2017 5:16 pm

I show you how I represent the process in my mind:

– I have a WAV file, 24-bit / 48000 Hz / 2 channels;
– I import it into Audacity (all the settings are by default, except I changed the sample rate to 48000 Hz);
– I export it as WAV file, 24-bit;
– I think it will not be the same file as the original.

I think this because:
http://manual.audacityteam.org/man/qual ... Conversion
Sample format conversion would be required upon export if you used the default 32-bit float sample format but exported a 16-bit audio file.
Kdmeizk
 
Posts: 30
Joined: Mon Mar 20, 2017 5:28 pm
Operating System: Windows 7

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by steve » Wed Oct 25, 2017 8:51 pm

Kdmeizk wrote:Sample format conversion would be required upon export if you used the default 32-bit float sample format but exported a 16-bit audio file.

That's true, but it is not the full picture.
If you export a track to a different file format, then yes the file format has to be converted, but regardless of the track format and export format, the audio data is 'mixed down' in 32-bit float and then converted to the export format.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Sample Data Export/Import is “bit-perfect”/lossless?

Permanent link to this post Posted by Kdmeizk » Wed Oct 25, 2017 9:21 pm

steve wrote:If you export a track to a different file format, then yes the file format has to be converted, but regardless of the track format and export format, the audio data is 'mixed down' in 32-bit float and then converted to the export format.

It means dithering is applied, so there is no more "bit-perfect"/lossless! Or does this happen only if the source bit-depth + sample rate are different from the export settings?
Kdmeizk
 
Posts: 30
Joined: Mon Mar 20, 2017 5:28 pm
Operating System: Windows 7

PreviousNext

Return to GNU/Linux and Unix-like



Who is online

Users browsing this forum: No registered users and 7 guests