Sunday, 23 June 2013

Using Apple Lossless (aka. ALAC) in Windows

Apple has without a doubt won the music wars, their iPods and now iOS devices are by far the most popular personal music players, and the iTunes Store is by far the most popular music download store. Even Microsoft has conceded defeat and discontinued their Zune Player and store. Furthermore when Windows 7 was launched Microsoft added built-in support for AAC format music files as popularised by Apple.

However many people want to use a lossless music format rather than a lossey format like MP3 or AAC and this is still an area that requires a bit of extra work. First some background.

Many years ago I decided to setup a Microsoft Media Center because back then and still now, it was far superior to any equivalent solution on the Mac. Yes this maybe a shock but it’s true :)

Elgato’s EyeTV does a great job for recording and playing back TV shows but that is all it does. FrontRow (when it existed) could playback files including your iTunes Music library but could not do TV recording. At the time PlexApp did not exist but even XBMC which PlexApp is based on also does not do live TV or record TV. While there are some equivalents to Microsoft Media Center like Myth, or MediaPortal, or SageTV they either did not work on the Mac at all, or had poor support for Mac compatible TV tuners, or were not as attractive as Microsoft Media Center. Gasp! Another shock, a piece of attractive Microsoft Software!

So I wanted to use Microsoft Media Center (running on a Mac of course via Boot Camp). However I wanted to have a single copy of my music and still be able to sync it to my iPod or iPhone which meant the music needed to be in a format compatible with those devices. On the Apple side, supported music formats are MP3, AAC, AIFF, WAV, and Apple Lossless. On the Windows side supported formats were MP3, WMA, WAV, and AIFF. However Apple software does not support tags in WAV files, and Windows Media Player does not support tags in AIFF. Also as you can see from that list Apple Lossless was not supported at all in WMP. I therefore began by looking for additional codecs for WMP to let it play Apple Lossless files. I rapidly found several codecs that supported AAC for WMP but after an extensive search found there was none at all for Apple Lossless. So initially I had to settle for using AAC which could be used on both Apple and Microsoft systems with full support for meta-tags.

I did not give up, I then decided to look for any Windows solutions that supported Apple Lossless in the hope one might be adapted to my needs, I then found that a plugin was available for dbPowerAmp and Foobar2000 but that it could not be used with Windows Media Player. I then found a developer library called BASS which is available for Windows and Mac. On their website I also found an addon which supports Apple Lossless in Windows. These by themselves were not a solution, but at the same time I found a developer called Milenko Mitrovic had used the BASS library and a BASS MP3 addon and made a directshow filter called DC-BassSource out of them. This showed that it would be possible in theory to do the same with the Apple Lossless addon. I managed to get in touch with the developer of DC-BassSource and persuaded him to make a new version which added support for Apple Lossless (and AAC). When he sent it to me for testing, I then became the first person in the world to successfully play an Apple Lossless music track in Windows Media Player. As Microsoft Media Center uses WMP to manage and play the music it then meant I could also successfully play the music in Media Center as well.

There was only one final step that needed addressing which was allowing WMP to read the tags in AAC and Apple Lossless files. (Both use the same file MPEG4 file format, file extension and tag format.) As there was already several codecs available for WMP to let it play AAC files there was also already two different plugins available for WMP to let it read tags from AAC files and since Apple Lossless uses the same file extension, file format, and tag format these worked equally well for Apple Lossless files. These two plugins are WMP Tag Support Extender and WMP Tag Plus. The combination of the modified DC-BassSource codec and one of these two WMP plugins meant that you could easily add Apple Lossless tracks to WMP and it would read the embedded tags to show the track name, album name, artist etc. You could even set WMP to monitor your iTunes library folder and when you added a new track/album to iTunes WMP would automatically spot this and add them to its own library using the same single copies of each track.

This was an excellent result and worked fine from Windows XP through Windows Vista (not that I used Vista myself). However Microsoft did initially throw a spanner in the works when they released Windows 7. As you may remember above I mentioned that Microsoft added built-in support for AAC with Windows 7, they even added built-in support for reading MPEG4 tags as used in AAC files and even supported reading the embedded album artwork from AAC files. In theory this should not have been a problem, it was still possible to add an additional codec to allow playing Apple Lossless in WMP with Windows 7 and in theory as Apple Lossless files use the same file extension, file format, and tag format it should have happily read tags from Apple Lossless files as well. Unfortunately Microsoft went out of their way to specifically detect these files were not AAC files and even though (with the additional codec) it could play them Microsoft chose deliberately to move them to the ‘other’ section and not treat them as music files. This was incredibly frustrating as the pre-release version of Windows 7 had not done this. Fortunately Tim De Baets the developer of WMP Tag Plus was eventually able to come up with a way of tricking WMP in to thinking Apple Lossless files were AAC files. We could now once again have them play in WMP and have WMP accept them as music files and read the tags and artwork from them.

There was one more added complexity with Windows 7 which had already been solved. The preferred type of codec in Windows 7 was no longer directshow filters but a new type called Media Foundation. If a suitable Media foundation codec was present it took precedence over a directshow filter one. Therefore the built-in Media Foundation codec for AAC took precedence over the directshow AAC/Apple Lossless codec meaning that initially it would not play Apple Lossless even if you installed the appropriate directshow filter. Fortunately a new multi-codec pack was released for Windows7 which was known as Win7Codecs from ‘Shark007’. This included the same modified DC-BassSource directshow filter but had a button specifically for disabling the built-in Media Foundation AAC codec thereby allowing the DC-BassSource codec to take over.

If you would also like to use Apple Lossless with windows then download the appropriate choice from the list below.

Windows XP or Windows Vista
DC-BassSource -
Wmp Tag Plus -

Windows 7 or Windows 8
Win7Codecs -
WMP Tag Plus -
As a bonus iTunes itself can now automatically convert from Apple Lossless to AAC when syncing to an iPod or iOS device. This allows you to keep your music on your computer in its full lossless original quality, and to copy a slightly lower quality version to your music device that takes up less space – which as iPods or iOS devices have far less storage space is an important consideration. With this automatic conversion you do not have keep two copies of each track.

Apple Lossless is now an open-source standard with free source-code available here

No comments:

Post a Comment