Mike Bland

Music student, semi-retired programmer, and former Googler
mbland@acm.org - archives - tags - subscribe - about - Google+ - Atom feed

Most recent posts

50 posts total. See Filtering and Navigation for tips on how to find the bits in which you're interested.

Early Thoughts on the Aftermath of the Boston Marathon Bombings
Extracting Album Artwork From iTunes 11
I Should Be Practicing

After the Boston Marathon bombings on April 15, 2013, I consider my good fortune and the suffering of others, and reaffirm my dedication to music

- Boston
Tags: Berklee, music, philosophy
Discuss: Discuss "Early Thoughts on the Aftermath of the Boston Marathon Bombings" on Google+

The weather here in Boston has been pretty glorious the past few days, after such a long, cold, lonely winter—well, it hasn’t been totally lonely—but obviously the present circumstances are not quite as pleasant. The Boston Marathon bombings happened maybe half a mile from the main Berklee buildings—even less for at least a couple of them—but school was closed because of the Marathon traffic anyway, so I was home working on my taxes all day, several miles away. I wasn’t checking the news, so the first I’d heard was when I’d just finished stuffing all the tax form envelopes and my Mom called to ask if I was OK. Berklee’s within the investigation radius, so it was closed yesterday, and is closed again today.

You’d think I’d get ahead on studying, practicing, and projects with all this extra time, but I was working out all my class registration planning for summer and fall (and potentially all future semesters) nearly all Saturday and Sunday, doing taxes all day Monday, and just generally saddened and distracted by the bombings since Monday afternoon. Only today do I feel like I’m getting back into a proper rhythm. But I can’t help but think of how some folks’ “normal rhythm” will be forever changed, and how purely lucky I was not to be down there. Hell, I’d only just walked past the finish line and the bleachers Friday evening. I haven’t been back down there since, and kinda don’t want to, since I want to remember it how it was, rather than how I’ve been seeing it on the news.

Despite my mild sense of guilt that I get to resume a “normal rhythm” while so many others can’t, when I think about why I’m here doing what I’m doing—music, of all potential pursuits, given my good fortune, good health, intellect, education, etc.—I’m actually more determined that this is the right thing for me to do. Some people live their lives to wreak senseless havoc on strangers, living out some warped, ideology-fueled fantasy of power and wrath, appointing themselves administrators of self-righteous justice on lesser, “evil” human beings that all deserve punishment, suffering and death. Some, like me, are trying to live their lives to bring a sense of connection and joy and beauty to others, so that we all seem a little less like strangers and more like fellow companions on the same exciting journey, to celebrate differences rather than fear and condemn them. I’m not so sure I’ll personally succeed in achieving such a high-minded goal with my own art, but I believe it’s a worthy pursuit, still.




Extracting the album artwork for Jimi Hendrix's "People, Hell & Angels" from iTunes 11, using vim to change the binary ITC file format to JPEG

- Boston
Tags: Jimi, Mac OS X, technical
Discuss: Discuss "Extracting Album Artwork From iTunes 11" on Google+

Happy day! I got the latest Jimi Hendrix album, People, Hell, & Angels, from Amazon today. It’s so new that the online music databases don’t yet have the cover art. To remedy this, my first impulse was to scan the CD cover myself, but my scanner driver decided to freak itself out temporarily. While rebooting my machine, which did in fact remedy the driver issue, I recalled that iTunes does have the artwork already—and it’s a far sight better than what I could expect to scan myself, most likely.

Little did I know I was jumping down another rabbit hole, though thankfully a relatively shallow one. Still, I feel the need to document what I learned during the process as a note-to-self, and to allow for the possibility of sparing others a few precious moments when faced with the same task.

Just because I’m obsessive about archiving, I like to rip my physical CDs—what few I choose to purchase over direct iTunes purchases these days—to the lossless FLAC format using XLD on Mac OS X, even though I still rip them to iTunes in AAC format, so I can use DoubleTwist to sync my iTunes library to my Android phone.1 XLD can embed the cover art in the tracks if it can find it online; otherwise you can upload your own image.

So, like I said, I thought, “Great! I’ll just pull the image for PH&A from iTunes, and embed that in the FLAC files via XLD.” The first sign of trouble was that there was no apparent way to export a piece of album artwork directly from iTunes 11. Then I found out that the mp4v2 tool can extract art from AAC files—but it turns out the art isn’t stored in the AAC files. 2 So I dug around in ~/Music/iTunes/Album Artwork, which is not exactly laid out to tell you the exact path to the file you’re looking for, since its files and directories are named according to some numerical indexing scheme. However, since I’d only pulled this one artwork file this afternoon, I was able to find the exact culprit via a little shell command: ls -lR | grep "Mar .*7"3

Only problem is, the file is in this iTunes-proprietary ITC format. Neither the open command by itself, or forcing Preview to open it with open -a preview will make sense of the file as-is. Doing a bit of searching about, I found the tip that the ITC file may be a PNG file with a few extra binary headers. I brushed off my knowledge on editing binary files with vim, and upon opening the file, realized the file was a JPEG, given the presence of the “JFIF” marker rather than “PNG”. So popping open the file with vim -b, I changed this:

ITC file before conversion to JPEG
Click for a larger image.
The ITC file with the original binary header intact. Notice the word “data” is highlighted; everything from the beginning of the file until the end of this word should be deleted.

to this:

ITC file after conversion to JPEG
Click for a larger image.
The JPEG file after removing the ITC headers. Notice the two binary bytes remaining before the “JFIF” string.

by deleting everything from the beginning the file through the word “data”, leaving the two bytes before “JFIF” in place. Lo and behold, Preview could open our new JPEG file! From there it was a matter of just loading it into XLD and letting it rip:

Album art imported into XLD
Click for a larger image.
Shot of XLD preparing to rip People, Hell & Angels using the album art extracted from iTunes 11. You can import the JPEG containing the album art by right-clicking (or CTRL-clicking) on the blank image template and selecting “Load Image…”.

And to make sure the entire operation was a success, I played the album using the FLAC-aware Vox player:

Playing People, Hell & Angels and displaying its cover art using Vox
Click for a larger image.
Playing People, Hell & Angels using Vox, displaying its cover art imported from iTunes 11.

OK, mission accomplished! Now back to the business of studying and practicing…

…which is going extremely well, by the way! But every now and then, I welcome the excuse to take a break by indulging in my geeky tendencies and scribbling about them here—especially if Jimi’s somehow involved.

Footnotes

1I use a special build of DoubleTwist that can disable AAC-to-MP3 transcoding, since Android groks AAC.

2I’d already installed mp4v2 using homebrew at some point.

3Yes, there’s probably a thousand better, “more correct” ways to execute this command, perhaps using a brilliant invocation of find, but I’m not a programmer anymore, and this little quickie got me exactly what I wanted.




There are many better uses of my time than getting sucked into writing demented Python scripts for Mac OS X. That doesn't seem to matter, always.

- Boston
Tags: Mac OS X, programming, time sink
Discuss: Discuss "I Should Be Practicing" on Google+

Somehow, via Isaac Truett’s repost of a Robert Konigsberg post that I just stumbled upon today, I thought it was worth my time to take Rob’s creepy one-line Mac OS X shell script to the next little level. See, when I ran the say -v ? command in that script, I found the output…amusing. But, since it’s a pain to parse strings into multiple fields in a shell loop, I dropped down to Python to do the dirty deed.

I call it creepy.py. Run it with the lights on, folks.

#! /usr/bin/env python

import os
import re
import subprocess

for l in subprocess.Popen(['say', '-v', '?'],
    stdout=subprocess.PIPE).communicate()[0].split('\n'):
  if not l: break
  l = re.sub('   +', '|', l)
  name, _, quote = [s.strip('# ') for s in l.split('|')]
  print "%s: %s" % (name, quote)
  subprocess.call('say -v "%s" "My name is %s. %s"' % (name, name, quote),
                  shell=True)