Music Library Checker


First posted on 19th October 2008 over on my HTML site

I’ve been ripping my CDs for a while now and I’ve used several different programs over the years. When I started out I didn’t know much about how the bit-rate affected the quality and I didn’t have that much disk space to store the files anyway. As I got different applications (MusicMatch, WinAmp, and now Media Monkey) and more disk space I gradually increased the bit-rate. Recently, however, I decided to rip them at the highest possible quality (for mp3!) and use quite high (450×450 pixel or higher) images for the cover art. That does mean that I’ve got a lot of music ripped at 192 bps or even 128 bps and with low resolution cover art to re-rip. Media Monkey (my current software of choice) has options for showing tracking that are missing tags such as the AlbumArtist or Genre and I use that for most things, but it can’t show me the bit-rates at all or the cover image size easily.

So I’ve written an application to do just that:

Album checker start-up screen

Album checker start-up screen

To use just point it at your music library (by clicking ) and then click Check. The DataGridView is setup programmatically using reflection to get the names of the columns from the properties on the AlbumInfo class and also to get the actual data. You can choose which columns to display by right clicking over the DataGridView to get the context menu. This is populated by reflection and the column states are persisted to the settings file.

Album checker context menu

Album checker context menu

Once the scan is underway it can be aborted at any time by clicking on Stop.

Album checker in action

Album checker in action

Once the scan is complete I can examine the data. All the columns are sortable so I can sort by bit-rate or whether the album has a cover image etc. Thus I can scan, sort by bit-rate and then re-rip the top 10 albums for example. If I want to do more analysis I can Export the data to an XML file.

Album checker completed

Album checker completed

Having written it I’m not sure how often I’ll use it, but it was a useful exercise in reminding me on how to use reflection. It was also a useful lesson in how to use the data grid itself. The code to display the row numbers was pulled off the net.

It’s not brilliant, but it does the job. And I’m making it available online to download. I’m not charging for the software, but if you like it I’d appreciate a donation:


It was written in C# using Visual Studio 2008 on top of .NET 3.5 and is (obviously) only available for Windows. It uses a C# mp3 tag library (TagLib#) to pull out the tags I’m interested in.

I may well be updating it at some point (but don’t hold your breath) and I may even put the code online too (once I’ve tidied it up). The usual warnings and provisos apply to the program – use at your own risk, there’s no support etc. However, if you have any comments or suggestions then I’d be happy to hear from you.

On 20th October 2008 my middle son asked if I could add a button to stop the checking part way through. I said “of course”, but while demonstrating what to do I realised that to get it to work I’d needed to put the code that scans the library into its own thread. This failed straight away as I wasn’t updating the DataGridView in a thread safe manner. I started doing this, but soon realised it wasn’t trivial. At which point, I told him to go to bed!

After he left I finished reworking the application to be multi-threaded – another beneficial exercise in itself – and you can now stop the scan part way through, most useful if you haven’t set the root folder of your library correctly (which I tend to do quite often), by clicking Stop or pressing Esc. The various buttons are enabled and disabled appropriately which also acts as a visual clue to what the application is doing.

On 8th November 2008 I added an Export option to write the data out to an XML file. This meant I had to do what I should have done in the first place and created a DataTable to separate the storage of the data from its display. I also added the context menu to the DataGridView to control which columns are visible. This means I don’t have to edit and rebuild the application each time I want to change what data is displayed – which was always a temporary solution. I haven’t added all the properties yet, just the ones I find most useful.

I’ve recently been looking at Microsoft FxCop and reading up on .NET 3.5 and C# 3 so the code is now in a far tidier state than before.

I’ve just created a Windows Presentation Foundation version of this application to gain some more practise in this area. The designer isn’t as mature as the WinForms one (obviously) but it’s interesting. One big drawback is that I’ve had to install a 3rd party grid view control. WPF may be the subject of a later blog post.

Future enhancements:

  • Use Dependency Injection to link the application with the AlbumInfo class which will be moved to a class library/dll. This will mean that by simply updating either the dll or the DI configuration I’ll be able to change what sort of file the checker looks for and what data is displayed.
  • Create a custom XMLWriter class so that only the visible columns are written to file on an export.
  • Look for music file types other than mp3.

© 2009, Chris. All rights reserved. If you republish this post can you please link back to the original post.

,

  1. No comments yet.
(will not be published)

*