Sunday, June 13, 2010

Reading iTunes m4a tags with .net

So it turns out that if you need some code to read media information out of an m4a file the only viable option to be found on the interwebs is a project called Atomic Parsley. Written in C/C++, you can tell a lot of time was put into reverse engineering the structure of MPG-4 audio file meta data and specifically, the types of tags used by iTunes.

The downside to that set of code is that it is written as a command line utility (global state, lots of fprintf, and exit(1) for error handling) and not at all structured in a way to be easily used as a class or component; especially from managed code.

Since what I have been looking for is some code that can be used from C#, I took the pieces of Atomic Parsley that I needed and restructured them as C++ classes. From there it wasn't too hard to create a C++/CLI wrapper for easy consumption in C#.

On the nostalgia side: It has been a long time since I've seen calls to malloc and I even forgot for second that unmanaged memory needs to be manually initialized to NULL.

And on the new technology side: this was a good foray into the latest C++/Cli syntax, using VS.NET 2010 and .NET4. It's getting more and more like C# in flavor but is still feels cumbersome in comparison. That being said, when creating a shiny new managed interface around legacy code, it cannot be beat.

So if you are looking for a mechanism to read meta-data from iTunes/m4a files the result might be helpful. Check it out on google code.

No comments:

Post a Comment