I sometimes wonder if my audience is divided. To put it simplistically, I imagine there are those who come here to read my complaints about Microsoft, and those who come to read my complaints about Bush. I sort of feel like Clifford Stoll in The Cuckoo's Egg, which tells the story of how a minor accounting error led Stoll, an astronomer turned systems administrator, to track down a group of German hackers selling information to the KGB. While I have not been involved with Soviet intelligence agents recently, this quote is pertinent:

Astronomers saw me that way. "Cliff, he's not much of an astronomer, but what a computer hacker [ed: this implied only that Stoll was particularly good with computers]!" (The computer folks, of course, had a different view: "Cliff's not much of a programmer, but what an astronomer!" At best, graduate school had taught me to keep both sides fooled.)

Unlike Stoll, I am not concerned about fooling you as much as boring you to death. While I have constantly worried about the number of "tech" entries on this site, it was never really a problem until this year, as the number of political articles decreased significantly after last November. I have tried to restore some semblance of balance by writing more about literature and music, but I am not sure if I have succeeded.

That said, if you are too scared/paranoid/selfish to write a comment below, you can always send me email at the contact page. This entry is both significantly long (more than 1500 words!) and technical (I try to explain technical terms and the like, but as I said earlier, I am feeling increasingly self-conscious about my ability to explain computing, especially when I am not conversing face-to-face with someone), so this might be a good time to complain about how you come to this website every single week and I never write anything that interests you.

Earlier, I complained about how the binary file structure of iTunes Music Library files (which have an ITL file extension) prevented me from editing the play counts in my iTunes music library. When I first noticed this problem back in May, I had assumed that the ITL file format was the same as that used in iTunesDB files, which store music library data on the iPod. Since the iTunesDB format had been reverse-engineered by various people trying to make their iPod play nicely with Linux, I figured it would be relatively easy to port their efforts into a Windows application. I envisioned using the powerful scripting language known as Python. Python looks like this:
z = 2
for i in range(37):
z = z*2
print z

The above code prints the value of 237. Programs that use Python that you may have heard of: Wirehog, PyMusique.

In June (I was busy in May with school and stuff), I actually opened an ITL file in a text editor. While I could not decipher it, it was clear than it was a different file format than iTunesDB. While iTunesDB files start with "mhbd," the ITL file started with "hdfm." This meant that if I wanted to edit the ITL file, I would somehow have to reverse-engineer it - use trial and error to find how its format. Since the contents of the file did not immediately seem to be structured in any way, I became interested in finding alternate ways to edit the file. Unfortunately, the omniscient Google had no information about the structure of ITL files. I had to assume that outside of the confines of Cupertino, every other programmer who had considered working on an ITL file editor had decided to do something easier, like solving the spam problem.

Since I figured my figuring out the ITL format was going to be difficult enough to me, I decided to stop using Python in favor of Delphi. Delphi is a programming language based on Pascal. In terms of the application I was writing, its main advantage was that I have programmed in Delphi since high school. If I was going to figure out the ITL file format before the end of the summer, I would not have time to fumble around in Python. Delphi code looks like this:
RegServProc := GetProcAddress(module, 'RegisterServiceProcess');
if Assigned(RegServProc) then
if Active then
Result := RegServProc(0, RSP_SIMPLE_SERVICE) = 1
Result := RegServProc(0, RSP_UNREGISTER_SERVICE) = 1;

The above code attempts to register the program as a service under Windows 98/Me. Such a program would not appear in the Task Manager! Programs that use Delphi that you may have heard of: Spybot - Search & Destroy, GetDataBack.

About to give up, I emailed Apple's Developer Technical Support, not expecting to get a response saying that "The ITL file format is the exclusive intellectual property of Apple Computer, and if we told you anything about it, Apple would go bankrupt." As a result of my negative thinking, I was surprised when the first response seemed to actually be interested in answering my question. I replied back, explaining my wish to construct a program to edit play counts, which had been stymied by the heinous binary nature of the ITL file.

The next day, I received a suggestion that I should use the iTunes COM SDK. COM is a technology that allows you to write Windows programs that interact and control with other Windows programs. The implication was that I could write a program that would then tell iTunes to change the play counts. Since I had looked at the iTunes COM SDK back in May (and again in June, just in case anything changed) and decided that it was impossible to use it to edit play counts, I was a bit nonplussed. However, just to be fair, I decided to take another look at the help file before writing an angry email to Apple.

Unlike the previous two times I had looked, this time the existence of the PlayedCount variable, which could be used to get or set the number of times a track could be played. To be frank, I felt very stupid at that moment. I was happy that my task was possible, but far happier that I had restrained myself from responding immediately to the email.

All that remained was to actually write the program. Since it was likely I would get distracted with other projects if the program's creation took more than a day, I was interested in creating it as quickly as possible. Since I was going to be using COM, I decided to switch programming languages again to C#. C# code looks like this:
currFeed.items[currFeed.num_items] = new RSSItem();
int item_depth = XReader.Depth;
while(XReader.Depth == item_depth){ // we have come for your children nodes

The above code came from a RSS aggregator that I wrote back in June 2003 (which, incidentally, took at least two weeks to write - when I realized the strange bugs I was experiencing were a result of fundamental flaws in its design). While I know of programs made with C#, I do not actually use any of them (except, of course, the ones I have written myself).

Since I have not done any C# development since last summer, my first task was to install an IDE to help me with designing the application's interface (where the buttons are, etc.). While my previous C# development took place under the aegis of Microsoft's Visual Studio .NET, I decided against using it. First, installing Visual Studio takes at least a couple of hours, during which time I would be unable to use the computer, but would be forced to sit at the computer swapping CDs in and out (the three computer tasks will consistently put me to sleep are installing Windows, compiling Linux kernels, and installing Visual Studio; they also all take long periods of time and have the tendency to fail in esoteric ways). Also, if you install Visual Studio .NET before Office 2003 and attempt to install it later, the installation will fail (the only remedy in such a case is to spend an hour uninstalling Visual Studio, install Office, and spend more hours reinstalling Visual Studio). Since I had heard good things about the open-source IDE SharpDevelop, I decided to give it a try. The most problematic part of the installation was downloading the .NET Framework SDK in order to get documentation and a debugger - at over 100 megabytes, my unstable wireless connection forced me to download it to this website (using the Unix utility wget) before downloading it using FTP (if the wireless connection dropped, Firefox annihilates your downloads about half of the time; FTP clients, on the other hand, allow you to resume download easily). Of course, if I had installed Visual Studio, it also would have made me download the .NET Framework SDK, so it is unfair to count the time spent against SharpDevelop.

Anyway, the program was almost ridiculously simple to write. Since I was more interested in getting it done than making it look pretty, it is rather ugly (hence the lack of screenshots). It does, however, change play counts in iTunes. I am content.

The iTunes COM documentation is interesting enough that I might make some more applications before the end of the summer. If you have ideas for programs that interact with iTunes, feel free to submit them.