Using mpg123 instead of iTunes
Face it, iTunes is a pig. If you just want to spin some tunes and spare some cpu cycles in OS X this story is for you. Since I got the iBook a couple years ago I have been impressed with the slick apps that came with OSX. I was used to the spartan world of my homemade, frankenstein linux box for several years before that, so I was wowwed by the glitz and glamour. After some time I realized that I really missed some of the simple tools that made my linux box so much fun to use…
[Note: more recent article discusses other players]
I really like to play mp3s while I work on other stuff but I don’t like sacrificing 30% of my CPU cycles to run iTunes and the iTunes interface, while beautiful, doesn’t allow me to work with mp3 files the way I want to: The iTunes paradigm is much like that of the other OSX apps - the app handles all the import and export of files (be they pictures or whatnot) and saves history data on the use of those files in little XML files so it can display how many times you played a file or what personal rating you give it, etc. Because of this, it doesn’t just read in a directory of files at the time you launch the app and display it, rather you have to import the tunes into the app’s library and once iTunes has it safely stored away, you can start playing it and acting upon it. Then, if you move those files out for archive purposes for instance and delete them from your hard drive, all the fancy play history is basically lost. It’ll recognize that the file is gone, but when you put it back it doesn’t necessarily recognize its back, it’s then listed twice in the library and the new one doesn’t inherit the history! Generally I find all the history stuff useless to me anyway. I just don’t have time to fiddle with that crap. I have filled my 20G hard drive to the brim and I have about 80G of data on my backup firewire drive. Music, pictures, docs, apps, roms, you name it. I’m constantly shuffling data around just to make room for a new wave of mp3 files because I’m sick of the old ones for now, or maybe to listen to Christmas music… The iTunes interface just gets in the way. What I was looking for was WinAMP, as described in this story. I tried running XMMS (an X windows app) for awhile, which is a WinAMP clone, but it crashed too often and I didn’t need the interface anyway most of the time.

Basically, I missed mpg123 in all its simplistic command line glory. I’ve used it to run holdmusic on a redhat 9 linux box for months at a time with no issues. mpg123 doesn’t come with OSX but it is the backend to XMMS and so, can be installed via fink (Im using Version 0.59s-mh4 (2000/Oct/27)). The only problem was that mpg123 doesn’t have a command line switch to read files recursively (which is odd, I think). This is a big bummer, since all my mp3s are in subdirectories and it would have forced me to play one album at a time or take all mp3s and load them into a single directory which would run counter to the way I want to work.
The answer was to pipe the output of the find command to mpg123! There were lots of people with helpful hints on their sites (now I’m one of them!), but most of the solutions to get mpg123 to play recursively (and shuffle) didn’t work for me in OS X. Here’s what Jon Haugsand (found a post by him last July on debian.linux.user suggested which did work (My iBook is set to use tsch if that matters):
find ./ -type f -print0 | xargs -0 mpg123 -z
I suppose a little script could be hacked together to control this better, I just have a little “play” script that just cd’s into a directory, runs this and escapes to the shell.
I can move files in and out of the p3 directory while playing tunes (as I often do) and I don’t have to “import” them or otherwise let iTunes know about them which is nice. Of couse, when I wanna use iTunes again, I have to deal with that annoyance at that time.
I don’t always use mpg123, I still use iTunes alot really, it offers great features like the built in id3 editor, I can drag and drop cover images onto the file, create playlists easily, surf internet radio, play with the party shuffle which is great feature if you have iTunes I bet you use it, etc. But if I want to listen to tunes while I use a memory hog program like Photoshop, iTunes is just a waste of precious memory space. I also spend a lot of time at the command line using ssh and the like, so I’m there anyway. There’s also a considerable number of geek points involved.
This works well with my desire to store the mp3s as subdirectories of genre, so I can just get to the toplevel of a genre and find everything in it and shuffle or not (-z shuffles).
[aside]
I have the same anal retentive problems with images. I don’t like the way iPhoto tries to do all the thinking for you and automatically stores your photos by date when I want to file them by subject, so I don’t use iPhoto at all. The “browse” in Photoshop works *almost* as well as ACDsee on windows to make me happy, so iPhoto has been relagated to the trash bin. Its slow as hell on the G3, but I don’t think any slower than Photoshop which offers “batch rename” which seals the deal on that front.[/aside]

Comment posted on 12-12-2004
So how much of your cpu gets used up when you are running through mpg123? iTunes uses about 6%-9% of my cpu and I don’t even notice that it’s running. It even starts up very quickly and I use the playlist features constantly. Also, iTunes pipes my audio via my airport express to my stereo speakers. All of my CD’s now live in a box in my garage as opposed to living in piles in my livingroom.
Comment posted on 12-13-2004
In my admittedly unscientific test, I opened a terminal and ran mpg123 as normal. Then I launched iTunes as well. (The cool thing about OSX is that I can run two streams like this and not crash, so don’t try this in windows!) In another terminal I ran top to monitor the CPU useage. mpg123 is just doing one thing: playing mp3s. Its not displaying stuff on the screen, displaying album art, etc. and it bobbed up and down from a minimum of 5% to a maximum of 30%. mpg123 was much steadier at a minumum of 2.5% to max of 5.3%.
All my CDs live in the garage too now, but I’m still deciding what is the best way to serve up the mp3s, frankly. I like the interface of iTunes but I don’t like having to depend on my laptop to play music. I would rathar have an NAS drive serve up to a dedicated mp3 player in the stereo system, but I might also like to have a full blown server (linux or OSX server) sitting there for that task as well as network cameras and file storage.
Comment posted on 10-1-2007
The real difference is in memory usage. Since I have only 512Mb Ram, it’s a significant difference. I will write about mp3blaster soon which is what I’m playing with now.