Are WAV files really better than FLAC?

Using the command line tools to test out the idea that FLAC audio files are inferior to WAV.
291 readers like this.
4 manilla folders, yellow, green, purple, blue

Open Clip Art Library (public domain). Modified by Jen Wike Huger.

If you lurk around enough audiophile-related sites, you may stumble upon writers claiming a difference in sound between the same music played back in FLAC or WAV format. This article on The Well-Tempered Computer does a nice job of exploring this concept, both from the perspective of those who don't believe such a thing is possible and from those who think there is a difference.

Without reprising the whole article, there seem to be two parts to this opinion:

  1. FLAC is somehow inferior to WAV in terms of preserving the original signal.
  2. FLAC takes more processing effort from the playback device and therefore introduces "infelicities" into the digital-analog conversion.

In the past, I mostly ignored this whole debate, but recently I found myself in a discussion with someone I greatly respect who held the opinion that FLAC was inferior to WAV in terms of the music content. Specifically, he believes something is lost in the conversion from WAV to FLAC and that a "second-generation" WAV resulting from the conversion WAV (1st generation) → FLAC → WAV (2nd generation) would be inferior to the original. Moreover, he believes that such loss of quality means you should never purchase FLAC files when WAV files are available because converting the FLAC back to WAV would be a poor copy of the original.

I am sure that some of you reading this will be scratching your heads over such an opinion because the whole point of FLAC is lossless compression. I mean, heck, do we worry that putting our documents in ZIP format might cause us to lose some characters from our sentences? But I really respect this person, who has a great deal of experience in recording and engineering music. So how could I convince someone that FLAC is a safe storage format for precious musical bits?

Using the command line to prove my case

The Well-Tempered Computer article suggests loading both files into an audio editor and subtracting the two tracks. I thought about this for a while; I could load Audacity, mess around to get the starting points aligned, subtract the two, and voilà, the bitstream of zeros would show that the files are equivalent. But I foresaw a fair bit of work in that approach, plus I didn't see how to best present the bitstream of zeros as evidence. So, having Linux on hand, I started a terminal session and proceeded as follows.

First, I used the command-line flac utility to convert a first-generation 24-bit, 44.1kHz WAV file to FLAC, then created a test directory where I could save the FLAC and the subsequent second-generation WAV file.

flac --keep-foreign-metadata 'Immunity-008-Jon Hopkins-Immunity.wav'
mkdir test
mv 'Immunity-008-Jon Hopkins-Immunity.flac' test

Then, I used the command-line flac utility once more to convert the FLAC file into a WAV.

cd test
flac --keep-foreign-metadata -d 'Immunity-008-Jon Hopkins-Immunity.flac'

Finally, I wanted to use the diff command to show the minimal difference between the two generations, but diff is not that informative with binary files. So I used hexdump to convert the two binary files into ASCII files that would better suit diff:

hexdump -v -e '/1 "%02x\n"' ../'Immunity-008-Jon Hopkins-Immunity.wav' >  008_before.hex
hexdump -v -e '/1 "%02x\n"' 'Immunity-008-Jon Hopkins-Immunity.wav' > 008_after.hex
diff 008_before.hex 008_after.hex

Sure enough, diff's output showed the only differences were in the metadata header:

5,6c5,6
< 00
< 63
---
> fe
> 62
57c57
< 12
---
> 10
76,77d75
< 00
< 00

Interpreting the above, bytes 5 and 6, which were originally 00 63, were changed to fe 62; byte 57 was changed from 12 to 10; and the two null bytes at 76 and 77 were dropped.

Personally, I'm OK with metadata changes of this magnitude. And just to confirm this wasn't a lucky choice of source, I've tried this as well on several other files at varying resolutions up to 24 bit / 96kHz, and not seen any changes to the musical content.

The perils of converting with ffmpeg

So if the flac utility does a credible job of preserving signal content across this WAV → FLAC → WAV conversion process, what about other utilities?

I used ffmpeg to convert the 24-bit, 44.1kHz FLAC file back to WAV, with no command-line options, and was surprised to see that ffmpeg downsampled my signal to 16 bits! Here's the output:

Input #0, flac, from 'Immunity-008-Jon Hopkins-Immunity.flac':
  Duration: 00:09:56.76, start: 0.000000, bitrate: 1397 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s32 (24 bit)
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'ffmpegged.wav':
  Metadata:
    ISFT            : Lavf57.83.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc57.107.100 pcm_s16le
[NULL @ 0x55f3b6f51a20] sample/frame number mismatch in adjacent frames
size=  102801kB time=00:09:56.75 bitrate=1411.2kbits/s speed=1.35e+03x

Also, I'm not comfortable with that "sample/frame number mismatch" error message. Hmm. I think I prefer a utility that downsamples when I tell it to, as opposed to by default.

What about sox?

I decided I should try sox to see what the results would be. In this case, there was no output (gotta love the tradition of *nix commands that emit a message only when something goes wrong).

Based on using hexdump and diff on the converted files, it appears that sox is a bit harder on the metadata than flac, at least by default. There were a number of differences in the first 70-odd bytes (too many to list here), but it seems the music payload isn't changed.

This was my first experience with sox; I leafed through its man page to see if there was some way to tell it to be gentle with metadata, and I must say I am stunned by all the cool things you can do with sox. Wow, well done, devs!

My conclusions, for now…

If you buy music in FLAC format and want to convert it to WAV, use the flac command-line tool. Same story if you buy music in WAV format and want to convert it to FLAC. Be prepared to edit your FLAC tags. In ether case, don't worry about the conversion process changing the digital music stream itself—it doesn't.

If you're determined to use ffmpeg, make sure to specify your output format so your file won't get downsampled. Or use sox, but consider taking the time to peruse the documentation and learn more about this wonderful tool.

As for why my contact believes changes are created by the WAV → FLAC → WAV conversion process, perhaps it's due to hs familiarity with real degradations that occur in making copies of analog originals, or in converting DSD to PCM.

And what about the second question above? Do WAV files sound better than FLAC? Well, I'm not going to step into that minefield, except to refer interested parties back to the article on The Well-Tempered Computer.

And more music

Recently, we were fortunate enough to attend a concert by Gli Angeli Genève, where they performed several Bach cantatas from Actus Tragicus as well as some Telemann and Buxtehude. We were moved by the high quality of this performance, and I quickly went looking for a download of Actus Tragicus. On 7digital, a Linux-friendly download store, I bought Vox Luminis' performance in high-resolution FLAC format, and we've been enjoying it since. You can hear some of this music on YouTube.

Another recent find, on that wonderful open source medium, vinyl LP, is Orchestra Baobab's Tribute to Ndiouga Dieng. What a wonderful album! Even better: it came with a download coupon that led to an excellent high-resolution FLAC download. This band has been around for more than 30 years, and wow! They still have the jam. Check out the official video on YouTube.

And, last but not least, I finally shelled out for the high-res download of The Allman Brothers' At Fillmore East, again from 7digital. I've always had a soft spot for The Allman Brothers, but I tend to ignore live albums as, in my experience, their quality varies. This live album is pretty darned wonderful, though. The sound quality is good, the band is at its early best. If you like them but have avoided this album thinking it will be poorly recorded junk, you might want to reconsider!

Chris Hermansen portrait Temuco Chile
Seldom without a computer of some sort since graduating from the University of British Columbia in 1978, I have been a full-time Linux user since 2005, a full-time Solaris and SunOS user from 1986 through 2005, and UNIX System V user before that.

8 Comments

Is there any need for compressed data? As far as I can tell no-one has ever, in a double blind test, been able to recognise anything better than CD quality uncompressed audio. Mpeg adds features that can be identified with practice. In theory flac doesnt but the mere act of decompression can lead to jitter and as there is, in this day and age, no need to compress CD quality then why bother?
It may be worth having higher bit rate and depth on audio recording/processing but for listening purposes CD is as good as you need, or in deed can get.

Thanks for your comments, madtom 1999. As to your your point regarding recognition of anything better than CD quality, I offer this meta analysis http://www.aes.org/e-lib/browse.cfm?elib=18296 which suggests that people can distinguish high resolution music (ie better than CD quality).

The question of blind / double blind testing is, in my mind anyway, a bit of a red herring, for four reasons. The first is that the testing environment itself is not a relaxing and contemplative environment, and may reduce the listener's ability to notice fine differences in details. The second is that many listeners (and I would include myself in this group) haven't spent time really working on trying to hear these kinds of differences. The third is that there is no particular guarantee that the music on offer in a double blind test actually exhibits any kind of potentially detectable difference between its 16/44.1 and (say) 24/96 forms. And finally, the fourth is that there is no particular guarantee that the equipment used for the testing is capable of rendering - in a reasonably accurate fashion - the difference (if it exists) between the 16/44.1 and 24/96 versions of a given piece of music.

With respect to the potentially detectable difference between 16/44.1 and 24/96, I find it instructive to use the Spek open source spectrum analyzer to look at music files and see what content is out there above 18-20kHz in those high-resolution files. Picking two more or less at random, The Allman Brothers Live at the Fillmore East shows some overtones, at a very low level, above 20kHz; Orchestra Baobab Tribute to Ndiouga Dieng shows much stronger overtones up into the 25kHz region and lower ones up to 40kHz. Interestingly, this latter shows that the high frequency overtones taper off in what appears to be a natural fashion between about 35 and 42 kHz, well below the Nyquist frequency of the sampling. So no "brick wall" filtering, which is quite evident on some music that was evidently recorded at 44.1 kHz and later re-released on 96 kHz (Emily Barker and the Red Clay Halo Despite the Snow is a "good" example of this).

Thanks again for raising this point; I think I may do a future article on this topic.

As to the question "is FLAC's compression worth it", for me at least, right now, it is: my music library is currently almost all FLAC (a few scattered MP3s where that was my only option), and I am guessing about 75% is CD quality, the rest being 24 bit and often 88.2 or 96 kHz. Currently this requires about 250GB. This fits nicely on a reasonably priced 500GB SSD along with the rest of my stuff on my laptop, leaving me with a great travelling music collection. It also fits barely on my 256GB MicroHD card in my digital audio player...

As to the effort required to decompress FLAC introducing jitter in the digital output stream, I don't believe we can make these kinds of a priori arguments. It's just as easy to claim that the extra I/O required by WAV files will introduce jitter into the digital output stream. What's needed is some very careful testing of these hypotheses.

In reply to by madtom1999

Thanks very much for this article and research! A very interesting read.

Very interesting
At least it points out what is very important: good recordings, good original files, good converters, and, to avoid jitter, a good clock for the converter.

I am using Linux with Jack to listen to music on various sound cards, consumer (integrated audio chipset), prosumer (Presonus) or professional (RME, Echo). I always have been amazed by how music sounds better on Linux compared to Windows: more details, better dynamic. That was, historically, one of the first reason for me and a few friends to move permanently to Linux, to listen, produce and record music.

Perhaps it's just a feeling. But, I would really like to see if it's possible to measure the impact of the operating system and the softwares playing the music.

Thanks for your thoughtful comments, Antoine Thomas.

I originally started buying 24/96 re-releases that claimed to be remasters of previous music. What I wanted were better-sounding versions of some of my favourite tunes, where the mastering engineer backed off on the level a bit to leave some headroom, got rid of some of the compression, and (I hoped) re-equalized the low frequencies that were often reduced to make records that played on toy record players of the 60s and 70s. And, I've kept buying high resolution music when possible, not because I'm certain I can hear the difference between 16/44.1 and 24/96, but because it seems to me that my original idea - the engineer making high-res releases is going to be more concerned about sound quality - is more or less correct.

So, starting with the best material is a key step, in my opinion at least.

I find your comments about Linux vs Windows interesting as well. I have read that Windows users really concerned with sound quality will download some kind of driver (?) that bypasses the audio mixing that takes place in Windows. I guess when I blacklist my external DAC in Pulse and use it only through ALSA I'm doing something similar. I have to confess that I haven't done a whole bunch of comparisons of different setups in the way that you have. I think you should write an article about that here on opensource.com!

As to measuring the differences between different music reproduction chains, that sounds like a great idea. I don't necessarily trust claims that "wow this sounds much better than that", nor do I necessarily trust the results of elaborate blind or double-blind testing. Certainly it would be cool to figure out some way of unequivocally determining that chain A provides a higher fidelity than chain B. But it's also good to remember the wise words of Siegfried Linkwitz (requiescat in pace), as quoted by Michael Fremer here:

'What is important to the eye is not necessarily important to the ear,' he said. 'Why should it be? Nature makes sure each does its job and does its job perfectly. You get cues from the eye, but some things that look gross in the frequency response, the ear says, "I don't care".'

(https://www.stereophile.com/content/siegfried-linkwitz-rip#sfSBoup5oLcd…)

In reply to by ttoine

There might be some truth to argument 2 as to why WAV may be a better option than FLAC, where "infelicities" are introduced during DAC. I have decided to start ripping my cd library in WAV, as opposed to FLAC, this being the reason. I put together a new PC laptop after my older macbook died, and I wanted to take the opportunity to start experimenting with different players and file types. I ripped Arcade Fire's album "Suburbs" in FLAC in MusicBee. Towards the end of my favorite song, "Sprawl II," there were audible artifacts toward the end of the song. I listened straight from the CD and no such artifacts were present. I did a little research on what to try, ripped it in WAV, and voi la! No artifacts. Could I hear a difference in the sound quality? Who knows, I might not be able to tell which was which from a good A/B test. But I want to rip my library and not have to worry about whether or not artifacts will be introduced in the process. So, WAV it is, specifically when ripping.

Thanks for the very interesting comment, Jud. It would be good to hear a bit more about these audible artifacts you noticed. At what moment do they occur in the track "Sprawl"? What do they sound like to you? Have you tried another ripper - I'm not familiar with MusicBee, but one possibility must be that the process generated errors that were audible in the MusicBee rip. What is your DAC? I don't think I have this CD but I'd love to experiment with it if I did (especially since I'm using a different platform than you are).

In reply to by Jud (not verified)

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.