← All Posts

Optimize Your Music

Posted by

  tech

10 min read | 2790 words | 514 views | 0 comments

While some audiophiles might swear by vinyl, most music consumption today is digital. As awesome as records and as convenient as cassettes are, digital music can be consumed infinitely and endlessly without degrading, and it can be organized and consumed in ways that analog music simply can't be. Although PCM-encoded "CD quality" WAV is the gold standard, MP3s are also popular thanks to the proliferation and convenience of MP3 players over the past two decades. Throw in yet other formats - WMA, AAC, M4A, and FLAC, to name a few, and it's easy to get confused. What format is best? Which formats sound the best? Which format is right for me?

In the past, the question was often portrayed as either a tradeoff or as a Hobson's choice. The tradeoff was between quality and size - the better your music sounded, the most space it occupied on disk. This is especially true of CD-quality: it's easy to ignore just how large they are when each disc is considered by itself, but each disc can only store 70 to 80 minutes of music, and CDs typically store around 700 MB of music. That's 10 MB per minute. Not bad when you have a stack of CDs and can swap them out when needed, but not so good when you have an MP3 player - mine is old enough that it only has 128 MB of storage. Needless to say, it wouldn't be very useful if it could only play 12 MB of CD-quality audio at a time. Thankfully, MP3 files are almost ten times smaller - about 1 MB per minute, and I can usually make it through a plane ride without having to repeat any songs.

In some ways, each format plays to its unique strengths. I don't fly very often, and the acoustics of an airplane make it impossible to pick apart the nuances of music anyways - the bass motif of "One Of These Nights" (Eagles, 1975) is so inaudible at 30,000 feet that I can't hear much at all and usually skip the song. For an occasional airplane ride, compressed MP3-quality is more than adequate. On the ground, however, it's a different story - the acoustics are usually much better, and I'm not limited to 128 MB - instead, I'm limited to as much music as will fit in a ring binder of CDs, a computer hard drive, or network storage, which allows for much more fussiness in picking the audio format.

Audiophiles (including me, to the limited extent that I am one) consider this more to be a Hobson's choice - we want the best-quality music or none at all. Some skeptics maintain that there is no discernible difference between the audio quality of lossless digital music and lossy digital music. To some extent, they're not entirely wrong - MP3 compression (which is lossy, meaning the file size is reduced by throwing away information that can never be gotten back) was designed to specifically discard information that most people can't hear. However, everyone's ears are different, and not all lossy compression is created equal. You can create good sounding MP3s and bad sounding MP3s depending on how you convert them and what settings you use. Some music is less optimized for lossy compression than others. Some people can hear the difference, just like some people (albeit very few) have perfect pitch. Either way, lossless audio is never going to sound worse than lossy audio, and there's no beating having the highest fidelity recording possible. To that extent, it becomes a Hobson's choice. Want good quality music? Then it's WAV or nothing - and just two hours of music will set you back more than a gigabyte in space. Storage is sacrificed at all costs in order to avoid any possible loss in quality.

Lossy and compressed are often used synonymously, but in fact, they don't necessarily come together. In fact, one audio format in particular - FLAC - allows you to have your cake and eat it, too! FLAC utilizes lossless compression to reduce the size of the audio with no loss in quality - not no discernible loss - no loss at all. If you compress a WAV file to FLAC and then convert it back to WAV, you'll end up with the same exact file that you started with. In fact, you can try it as an experiment - the checksums of the original WAV and the uncompressed WAV (from FLAC) should match exactly. No information is lost in any of the conversions.

So, if FLAC is so awesome, why isn't it more widely used? It's a good question. This past weekend, we converted our music library from WAV files to FLAC files and thought it was nuanced enough of an issue that it deserved some discussion. Let's pick it apart.

First, let's clear up the distinction between lossy and compressed once and for all. WAV audio (CD-quality, 44.1 KHz sampling, PCM-encoded) is essentially "pure" unaltered digital audio (the WAV file container itself can be used for storing other kinds of audio, but typically it's this kind, and we'll assume that simplification here). It's an essentially-perfect audio capture with no optimizations (essentially-perfect, because it depends on the limitations of the sampling rate chosen: 44.1 KHz is good enough for most human applications, and certainly more than adequate for music). WAV is lossless, clearly, but more importantly, it's uncompressed. Two WAV audio files of the same length will have near-identical file sizes: it's a pure ~10 MB per minute, assuming the regular 44,100 Hz sampling rate and that you're recording in stereo, not mono.

Although this all sounds unappealing, WAV files actually have several benefits. First of all, they're almost universally supported. Few other audio formats enjoy such widespread compatibility. Almost any music player on any operating system in the past three decades will have no difficulty playing WAV audio. Because it's not compressed, it's also easy on your computer's CPU - playing compressed audio requires more CPU cycles than playing uncompressed audio. Thus, in theory, older computers should have less difficulty playing WAV files than compressed formats like FLAC or MP3.

A prime application of WAV files is in audio work. WAV files are very common because they're extremely easy to work with. Our telecom subsidiary, PhreakNet, has a large library of audio, many of which consists of telephone recordings or samples that are frequently digitally spliced, manipulated, or extracted for audio projects. As a result, much of this audio is in WAV format. It's extremely fast for programs like Audacity to process and export, and keeping audio libraries in the uncompressed WAV format means that audio work can take place very rapidly.

While this is all good and great, such advantages are of limited usefulness to music libraries. A format like WAV, while excellent for audio work, is conversely extremely poor for applications like music. Not only does it take up more space than formats like FLAC which can take advantage of lossless compression (reducing file size with zero reduction in quality), but the WAV format also lacks good, integrated support for tagging (if you've ever tagged your library of WAV music, only to move it somewhere and find that all of your tags disappeared, you know what we're talking about - we've been there, done that). Tagging is how metadata gets attached to digital music, and it's what allows Windows Explorer and music players to show you the artist, album, release year, track number, and other helpful details. It's one of the unique advantages of digital music, and it's totally screwed up when audio gets stored as WAV files. Tagging isn't generally important except for songs, when it's very important, so this is a major disadvantage of the WAV format when it comes to music.

Furthermore, how often do most people digitally manipulate their music? Probably not very often, if ever - music is static and unchanging. So there's no significant advantage in this respect to keeping music in the WAV format, since it doesn't need to be easily and quickly manipulated. That's not to say, of course, that it can't be done - you can very easily work with compressed audio - it'll just take longer, and you can always convert audio back to WAV (and if you started with a losslessly compressed format, like FLAC, you'll get the exact same original file back).

All this to say that while WAV has its places, music is certainly not one of them. As you can guess, FLAC is the optimal audio format for music. It has excellent built-in support for persistent tagging, so that you never lose your tags and bemoan all the hard work you put into them. And it makes the dichotomy that divided the music world for so long (size vs. quality) almost irrelevant, today. There's no reason you need to give up size or quality - you can get music that sounds just as good while taking up significantly less space (on average, around half as much space). True, it will still take up significantly more space than MP3-quality audio: FLAC audio, depending on the level of compression used, is typically around 4 to 5 MB per minute. While the MP3 format still has its place, particularly when quality doesn't matter so much (e.g. voice-only recordings or airplane playlists), storage capacities have increased enough in the two decades since FLAC has debuted that it is well-poised and extremely well-suited to storing music today and tomorrow.

But what's the catch? There's always a catch, a tradeoff, when it comes to audio, isn't there? It sounds too good to be true. That's the best part about FLAC. The only thing we can think of is that it may be slightly more taxing on the CPU than a comparable WAV file (it is compressed, after all, and compression and decompression require CPU cycles). Expect it to be less taxing than MP3s, however, and it's unlikely that any discernible difference would be detectable on any processor from the last fifteen years - we're talking audio here, not video graphics, after all.

One downside of FLAC, however, is that out of the box, there's very little support for it. Support for WAV is ubiquitous, but FLAC support is typically an add-on (even though, ironically, FLAC is a free and non-proprietary codec, unlike the proprietary WAV format). This isn't much of a downside, though - even if Windows Media Player can't play FLAC files, the free and versatile VLC Player certainly can, and all popular music software, such as Foobar2000, has excellent support for FLACs. If you're stuck on a stock Windows install with no third-party software, however, you might be in trouble. There certainly are people out there who might have difficulty downloading a FLAC file and playing it immediately, because their system doesn't have the codecs for it, yet. Given that we're talking about personal music collections here, this is not terribly relevant.

We hope this has been an insightful public service announcement into what FLAC is and why FLAC is perfect for your music library. Got a bunch of WAV music sitting around collecting dust? Upgrade your music library and free up disk space by converting it to FLAC. Fortunately, with free and popular tools, it's relatively trivial to do nowadays. Here's how you can get started:

  1. Download Foobar2000. Foobar2000 is a popular, powerful, and extensible music player. It has excellent support for FLAC and just about every other imaginable digital music format. You might opt to use it for organizing your music, or you might not choose to, say, stick with VLC Player - but Foobar2000 makes it easy to do batch audio conversions.
  2. Open up Foobar2000 and go to File → Add Folder. Add the root folder containing all of your music. It may take a minute but Foobar2000 will load all of the metadata.
  3. Now, select all of the audio files and right-click and go to Convert → and click the three dots at the bottom.
    flac1.png
    If you have more than just WAV files to begin with, right-click the column headings, and go to Columns and add File extension. Now, sort by file extension, so you can select only the WAV files (if you have some FLACs already, or worse, MP3 files, there's no point in compressing them).
  4. You'll get a screen that allows you configure the conversion options. By default, WAV is the output format, so go ahead and change that to FLAC. Although the compression levels range from 0 to 8 (8 being smallest file size), 5 is probably suitable for most purposes. Beyond level 5 compression, your audio won't compress very much, but it will take significantly more CPU cycles to compress the audio - it's probably not worth it, especially if you've got a large music library.
    flac2.png
  5. Now, change the destination of the converted file to "Source track folder". This means that the converted FLAC files will end up in the same directories as the original WAV files, even if you have a complex folder hierarchy. Otherwise, they'll all end up in the same directory, which is probably not what you want.
    flac3.png
  6. Go ahead and convert the files. It will take a moment, but maybe not as long as you might think. Extremely large libraries might take a long time, but we converted nearly 15 GB of WAV music into FLAC level 5 format in relatively little time.
  7. You might get some errors about "Truncated files". Apparently, this is common and normal. We saw it a bunch, and there weren't any issues with the audio format. We won't go into why this happens, but you can most likely safely ignore it.
  8. Once audio conversion is complete, we'll need to tag the music. Some of the metadata might carry over on some tracks, some might not. A lot of variables come into play here. Unless you get really lucky, though, it's likely that tags will be missing from some of your music and you'll need to add them. Luckily, there are tools to make this process less painful. We used Mp3tag, which dubs itself as the "universal tag editor".
  9. How you do the next part is up to you - you can do this on all of your music at once, or break it into chunks of subfolders. Right-click a folder and click Mp3tag. All the audio in that folder and its subfolders will appear in Mp3tag. You can make individual or batch tag changes here. To make changes, select a file. To apply changes to all the files at once (for instance, say you've organized your music by year or by album - you can apply that tag to all files at once), select all files (CTRL+A) and then use the tag editor. Writing your tag changes is as simple as clicking save or hitting CTRL+S - it really is that easy!
  10. One trick that you can use is opening all your music files - WAV and FLAC - in Mp3tag. Sort by name so that the WAV and FLAC version of each song appear next to each other. For songs where the WAV was tagged but the FLAC is not, you can use CTRL+C and CTRL+V to literally copy and paste the metadata from one song to another. You'll need to do this process for every individual song, but it sure beats manually editing tags.
  11. Once all your audio is properly tagged, you're almost done! Although Foobar2000, VLC Player, and Mp3tag all can handle your FLACs just fine, Windows Explorer, by default, lacks the necessary shell integration to support FLAC tags. You might be puzzled at first to see your tags don't show up at all, seemingly. Fortunately, there's a simple fix, which is described in this article. To get the necessary shell integration, download the Windows 7 FLAC Property Handler. This allows Windows Explorer to support FLAC tags just like WAV tags or MP3 tags.
  12. Make sure that your music folders are optimized for music. You can ensure this by going to folder properties and making sure Music is selected and that the subfolders checkbox is checked:
    flac6.png
  13. Once you restart Windows, your tags will show up, voila!
    flac4.png
  14. Now, you can safely delete the original WAV files and keep only the FLAC versions instead. In addition, if you were using a folder hierarchy to organize your music (as we were), you can flatten it if you choose now that you can rely on tagging. Windows Explorer allows you to sort files by multiple criteria - in the screenshot above, we've sorted primarily by year, but also by artist, album, and then track number, as is evident here:
    flac5.png
    Of course, you can also organize your playlists using Foobar2000 - it's up to you!

← All Posts


Comments

Log in to leave a comment!