Page 1 of 2
Is exporting WAV files lossless?
Posted: Tue Feb 16, 2010 9:02 pm
by jawohlol
Hey, since exporting mp3 files to mp3 induces quality loss, I thought this might be as well the case with wav exporting; it takes several seconds to save the new file, while I just changed the last few samples of the track, because they caused a nasty pop.
I use 44.100hz 16bit pcm recordings, CD quality. Will anything besides the things I edited be changed when I export to wav?
And I have another question as well: those pops occur at peaks in the last ~10-15 samples. Can I just select a begin point in between the samples to the very end, or should I select it precisely on the first sample I want to delete?
What I mean is this:

I delete in between the sample I want to start with deleting.
Re: Is exporting WAV files lossless?
Posted: Tue Feb 16, 2010 9:43 pm
by kozikowski
You may notice a substantial slowness when you're managing WAV files because uncompressed, high quality sound files are BIG. If you started out life with an eight to one compressed MP3 at 1MB size and you're happy with that, you will be shocked at the 8MB sound file you suddenly get when you convert to WAV. File saving suddenly becomes eight times slower, etc. etc. etc.
The up side of editing that way is the portions not edited are not damaged. There was a posting storm a while back where somebody discovered a conversion problem inside Audacity that did increase WAV damage, but they were talking about sound damage that you needed instruments to detect and you had to know exactly where to look. I think they said they found it by accident. Nothing like the massive, clearly audible damage you can get from multiple MP3 conversions.
Depending on your job, there are certainly direct MP3 editing tools out there. You don't have to go through all the conversion nonsense if all you want to do is shave a quarter second off the back side of your show. You get a shorter show with zero increase in damage.
Koz
Re: Is exporting WAV files lossless?
Posted: Tue Feb 16, 2010 9:51 pm
by jawohlol
So.. You say that audacity changes the track other than my changes? Even though It is inaudible on small systems, I would like to keep my files in pristine state (because these tracks are going to be played on HUGE sound systems), I know for mp3 there is mp3 direct cut, but isn't there something for wav files? It is really only those last few samples I need to delete.
FIY the slower importing/exporting part was just to illustrate that maybe more editing than the part I done was going on.. It isn't a problem, its just an observation
And is it harmful to the exporting process when I have other applications, including an audio program doing ASIO streaming and multiple instances of audacity running?
Re: Is exporting WAV files lossless?
Posted: Tue Feb 16, 2010 10:48 pm
by kozikowski
You can get rid of that disturbance at the end without changing the length of the show by selecting it and Control-L Silence. It will flatten out to match the surrounding baseline -- assuming the baseline is at zero. If you have DC on your show, that will produce a pop.
Audacity default bit depth is 32-bit Floating which is far more accurate than anything else you're likely to encounter, and Audacity Projects assume the sample rate of the first clip you open. So you should be able to either cut or suppress that sound snivvy without introducing any distortion or damage.
Oh, and I totally would not be in Audacity 1.2. Install Audacity 1.3.11 and use that. Audacity 1.3 tools are much improved and expanded over 1.2 and less likely to crash. You can safely install both 1.2 and 1.3, but only use one at a time. Audacity 1.3 Projects will not open in 1.2.
Koz
Re: Is exporting WAV files lossless?
Posted: Tue Feb 16, 2010 11:12 pm
by steve
Exporting in WAV format is virtually lossless in all situations. As Koz has said, there is a very small amount of change to the audio data with some types of WAV export, depending on the settings in Audacity Preferences. We don't usually bother to go into the detail because the difference is so small, but since you ask, here it is:
If you export to 32bit (float) PCM WAV format, it is 100% lossless. [Edit: referring to 32-bit float, not signed 32-bit integer]
If you export to 24bit PCM WAV format , it is (almost) 100% lossless. [Edit: 32-bit float allows values that cannot be represented exactly as signed 24-bit integers]
If you export to 16bit PCM WAV format it will be between 100% and 99.975% lossless depending on the original audio format in Audacity and settings in Audacity Preferences.
The maximum error is +/- 2 on a scale of -32768 to +32768 and you should bare in mind that 16bit audio is at best only accurate to to the nearest digit on this scale.
So where does the error come from?
Audacity performs calculations using 32bit float numbers, which provides incredible accuracy (considerably better than even the best top of the range sound cards). If Audacity needs to reduce the resolution to 16 bit, then there will be "rounding off" errors. If simple "rounding" is done by simply taking each sample value and converting it to the nearest 16 bit value, then a "steppiness" in the output will result which may be audible, particularly with extremely quiet sounds. To avoid this, Audacity applies "dither" in the conversion - this is often likened to "anti-aliasing" in graphics which is used to smooth the steppiness of curves. Rather than always rounding the values to the nearest 16 bit value, dithering will apply a degree of randomness to the rounding off so as to prevent causing steps. There is a good explanation about "dither" in Wikipedia if you are interested in learning more about it.
Dither is only applied when converting from a higher bit depth to a lower bit depth.
Audacity has 3 alternative algorithms for how it applies dither and they are found in "Edit menu > Preferences > Quality". The dither settings we are talking about are the ones for "High Quality Conversion". The available options are: None (no dither), rectangle, triangle and shaped. The differences between these settings are very subtle and you need to be listening carefully with good equipment to notice any difference. Generally, "triangle" or "shaped" will give the best (subjective) results.
If dither is set to "none", then conversions from one bit depth to a lower bit depth will be done by simple rounding (I'm not sure if this is by going to the closest number, or by truncating the remainder).
If dither is set to "rectangle" or "triangle", then a random factor of +/- 1 bit is applied. In effect, this is applying a very small amount of "noise" to the signal.
If dither is set to "shaped", then a random factor of +/- 2 bits is applied. While this may appear to be worse than the other 2 types of dither (the peak amplitude of the noise is greater) the distribution of these random variations is done in such a way that the noise is mostly at the high frequency end of the audio spectrum and as it is at a very low level it may be less noticeable than the other types of dither.
If you are working in Audacity with 32 bit audio, then dither should be enabled in the high quality conversion settings (it is by default). Dither will only be applied if the output is at a lower bit depth. Converting from a higher bit depth to a lower bit depth will inevitably have inaccuracies (because the lower bit depth is less accurate). Using dither just makes these inaccuracies less noticeable in the music.
Converting from 32bit (float) to 24 bit does not introduce dither noise because 32 bit float uses 24 bit precision (and an 8 bit exponent) so the 24 bits are used without modification. [Edit: this is probably not totally accurate]
Here's the exception to the rule: If you have recorded in 16 bit and are only doing simple editing (cut, delete, paste, trim...) and not doing any processing (amplify, equalize, frequency filter....) then for highest accuracy dither can be set to "none". In this case, because there are no 32 bit operations prior to export there is no benefit to using dither. Exporting a 16 bit track to 16 bit with dither set to "none" will be lossless.
If you are doing any form of processing of the audio, then the highest quality will be achieved by using 32bit (float) throughout. 32 bit audio files are twice the size of 16 bit audio files. (and as Koz has said - use the latest version of Audacity 1.3 - it does nearly everything better than the old 1.2.6 version)
Re: Is exporting WAV files lossless?
Posted: Wed Feb 17, 2010 8:55 am
by jawohlol
Interesting story

I use 16 bit audio, which I want to keep totally the same, so I export to 16 bit wav.
So when both dither settings are off I should have 100% lossless? (I updated to 1.3.11 btw)
I also would like to check how much samples have changed, I saw this possible in foobar2000 in another thread here, but when I do it it only gives the difference in total samples (which is of no use for me because I purposely changed this). Do you know how I can check whether the rest is bit-identical?
I know this might come across like nagging but I really want to ensure NOTHING changed except for the last few samples I deleted.
Re: Is exporting WAV files lossless?
Posted: Wed Feb 17, 2010 11:05 am
by waxcylinder
Steve, can you turn that posting into a Wiki article (or an entry in the manual) - a nice succint description, very informative and clear <applause>
WC
Update: just done it for you Steve. I thought it was too valuable to lose. See: http://wiki.audacityteam.org/wiki/Dither
WC
Re: Is exporting WAV files lossless?
Posted: Wed Feb 17, 2010 1:16 pm
by steve
jawohlol wrote:Do you know how I can check whether the rest is bit-identical?
Here's a little "trick": (recent 1.3.x versions only)
1) Set Preferences to: Quality > Default Sample Format = 16bit, High Quality conversion > Dither = None.
2) Record your track.
3) Trim/edit as required - note than any "processing" will be less than optimal because you are working in 16 bit. (simple "edits" are fine in 16 bit)
4) Export as "16 bit PCM WAV"
Now to test:
5) Import the file that you have just Exported (you now have 2 tracks in Audacity).
6) Select only the new (lower) track and use "Effects menu > Invert"
7) Ctrl+A (select All)
8) Ctrl+Shift+M (Mix to new track)
You now have a new (third) track. This track is the difference between the other 2 tracks - if the other 2 tracks were identical, after one was inverted they would be exactly opposite and mixing them together will produce absolute silence.
Now to test that the difference between the two tracks is
absolute silence.
9) Select the new (third/silent) track
10) From the Effects menu select "Amplify" - if the track is
totally silent, the Amplify effect will report that the "New Peak Amplitude" is "-Infinity" (any amount of amplification of silence is still silence)
Re: Is exporting WAV files lossless?
Posted: Wed Feb 17, 2010 2:20 pm
by jawohlol
I have done what you said, first it gave a value.. Then I thought, the original had the spike in the end of the track, and the edited not, so no matter what, there would be some peak volume, as long the spike would exist. So I deleted the last seconds on the line which have the spike, and then when amplifying it gave -infinite
So I think this means that the tracks are bitperfect?
I see that one track doesn't have infinite, even when end is deleted. It also shows when I amplify by 50db.. but I don't hear it without amlification... These must be the tracks I did while dither was still on.
Re: Is exporting WAV files lossless?
Posted: Wed Feb 17, 2010 3:24 pm
by steve
jawohlol wrote:Then I thought, the original had the spike in the end of the track, and the edited not,
In my example the comparison is between the track in Audacity (after editing) and the track Exported from Audacity (after editing).
It sounds like you are comparing the track after editing, with the audio file before editing. That's fine as long as you are only trimming a bit off the end, but if you are making other edits, such as deleting a bit from the beginning then the "trick" won't work because the two tracks will not match up. (they will start in different places so you are not comparing like with like.
jawohlol wrote:
So I think this means that the tracks are bitperfect?
If it gives silence, then yes, every sample in the exported file is identical to the corresponding sample in the Audacity track.
jawohlol wrote:I see that one track doesn't have infinite, even when end is deleted. It also shows when I amplify by 50db.. but I don't hear it without amlification....
That shows that it is
very similar, but not
identical. The fact that the difference is (usually) inaudible, and it only applies to 16 bit (or less) export of uncompressed audio files, is why we don't usually bother going through all this rigmarole (but you did ask

)
If you follow the steps exactly as described, and in the exact order as described, the end result will be silence.
Now that you know how to do it "bit perfect" you don't need to worry about it, but the thing you must remember is that if you do any processing (such as Amplifying the track, Normalizing, Equalizing, or
just about anything other than simple cut/paste/delete editing) you should turn dither back on for best results (and ideally work in 32 bit format).