Category Archives: Music

The ABC’s of creating MP3s

New link, read Fine DAE scripts for more. and Linux… Arghh.

Update: Since this I’ve learned that Barnes and Noble carry Audiobooks in the MP3 format. To download them though the Windows application OverDrive Media Console is required. Good news is that you can D/L the file and open it through the application so you don’t have to order it through Windows. Thankfully it’s a good program and does it’s job well.

Recently, I decided to get and audiobook to be able to listen to on my MP3 player. I had heard on TV the commercial that audiobooks could be downloaded and played on my computer or MP3 player. I went to Audible, found the book I wanted and downloaded it. When it started downloading, I noticed the extension was .aa. I hadn’t noticed but below the Download link was a mention of how to import the file to iTunes. The .aa extension is a specially created extension short for Audible Audio and it only works on several types of portable music players that support it. iPods are one, and newer Creative Zen, and SanDisks do too. Having already spent $30 dollars though, I was determined to get this to play on my slightly older MP3 player. Unfortunately, the only way to do this (without spending $20 to $30 on software that removes DRM illegally) is a time-consuming, and somewhat laborious process.

Burn, Burn, Burn… Rip, Rip, Rip

I was a bit thrown off of the MP3 mention:

Saying MP3 player (to me) seems a bit too generic to me and sadly it had me boot up my dusty Windows install :) to be able to start the process. I did bit of research and booting to Windows is necessary – there is no way to convert .aa files in Linux as of yet. I copied my .aa files to the Windows partition, rebooted to Windows, and then installed iTunes. To begin: in iTunes I had to create a new playlist ‘File > New Playlist’, and drag an .aa file to it. I had multiple .aa files so I had to do them separately, one at a time. After that, I did ‘File > Burn Playlist to Disc’, select ‘Gap Between Songs’ as ‘none’, and hit ‘Burn’. This is where the long part of the process takes. For my three part audiobook (three .aa files) the total ~15 hour audiobook spanned 13 discs. I did this for each .aa with a new playlist. I tested a CD after it was done and it played fine but oddly I noticed that iTunes had decided to break the audiobook up into 8 minute tracks – wish it didn’t do. When finished, I decided to rip in Linux. Reboot.

In Linux, Ripit is a good command line tool for ripping CDs. In Ubuntu, install by:

aptget install ripit lame

Lame is required for encoding. Make a new directory for the audiobook. In my case:

mkdir -p ~/Audiobooks/Stephen\ King/Full\ Dark\,\ No\ Stars\ \(Unabridged\)
cd ~/Audiobooks/Stephen\ King/Full\ Dark\,\ No\ Stars\ \(Unabridged\)

And begin burning:

ripit --playlist 0 --bitrate 64 --quality 0 --loop 1 --outputdir ~/Audiobooks/Stephen\ King/Full\ Dark\,\ No\ Stars\ \(Unabridged\)

I did a bit of research on this and for most audiobooks the are encoded in 32bit mono but since some have sound effects, 64bit is the way to go. Also using 64bit helps because a bit of quality will be lost in the conversion. This unfortunately makes the MP3s slightly larger (the original files were about 75MB each, afterward they were around 150) but is really the best choice. The other commands here do: playlist 0 (don’t create a playlist), quality 0 (encode slower for slightly better MP3 quality), loop 1 (will eject disc after rip and prompt for a new one), and outputdir (to specify where to put the ripped folders). Ripit automatically queries the FreeDB database for MP3 tagging (there won’t be any valid entries likely) and there is no way to override it. So for each CD I had to enter into it: not to use a DB entry (0 none of the above); to label with the “Default Album…”; and for genre I just hit enter (none). Ripit burned the CDs into folders named ‘Unknown Artist – Unknown Album’ and was smart enough not to overwrite the folders of the same name and sequenced them. When it was done, I had a list like this:

ls -1
Unknown Artist - Unknown Album
Unknown Artist - Unknown Album 1
Unknown Artist - Unknown Album 10
Unknown Artist - Unknown Album 11
Unknown Artist - Unknown Album 12
Unknown Artist - Unknown Album 2
Unknown Artist - Unknown Album 3
Unknown Artist - Unknown Album 4
Unknown Artist - Unknown Album 5
Unknown Artist - Unknown Album 6
Unknown Artist - Unknown Album 7
Unknown Artist - Unknown Album 8
Unknown Artist - Unknown Album 9

Put it Together, Polish it Up

To be able to put the audiobook back together, I’d have to join the numerous MP3s back together. Here, I choose to use mp3cat. I was a bit unsure which way to go. The best source I could find to do this was this question at stack overflow. I decided to use mp3cat because here it is said that (later on in post by joelhardi) that mp3wrap “inserts its own custom data format in amongst the MP3 frames (the “wrap” part), which causes issues with playback, particularly on iTunes and iPods.” mp3cat pulls the tag (ID3) information out (which leaves only the binary part of the file) and then joins the MP3s together. To install:

tar xvf mp3cat-0.4.tar.gz
cd mp3cat-0.4/
make install
sudo cp mp3cat /usr/local/bin

For my audiobook, part 1 of my audiobook spanned the first folder (0) to folder 4, part 2 from 5-8, and part 3 from 9 to 12. To concatenate the files back together, I’d have to define the folder span of the MP3s to put together. However, because the folders will are not going to be recognized in the correct order (e.g. folder 10 will come after folder 1 [as recognized by the shell]) I had to zero pad them (e.g. …Album 000, …Album 001,…):

mv Unknown\ Artist\ -\ Unknown\ Album/ Unknown\ Artist\ -\ Unknown\ Album\ 0
rename 's/\d+/sprintf("%03d",$&)/e' *
ls -1
Unknown Artist - Unknown Album 000
Unknown Artist - Unknown Album 001
Unknown Artist - Unknown Album 002

The rename command here grabs any number and turns it into a it’s three digit equivalent. Since all my folders had numbering at the end of the name this solution worked good in this case. I created a script to concatenate the MP3s with for ease of use if I ever have to do this again. I had help from some people at the Arch Linux forums to help finish this, particularly rockin turtle. Thanks guys!

To use it for example:

mp3cat-multiplefolders 0 4 "01 Part1"

This did exactly as I wanted except for one thing: I learned that the track length information is also part of the binary file. This would cause some MP3 players to report the length incorrectly thinking that the MP3 was an eight minute track instead of the five or so hours that each actually was. To fix this, the only program I could find was MP3 Diags. This is a great tool to repair damaged MP3s with. Unfortunately, it a GUI utility only and I was hoping for a command line one. To install on Ubuntu: apt-get install mp3diags. I just clicked on 4 to fix everything (which was just the track length issue (bc)).

Tag Line and Submit

I searched online for tag information of the audiobook on both the FreeDB and MusicBrainz databases but had no luck. At this point I knew I’d have to create the audiobook information tags (ID3) manually. Originally I used EasyTag but it created a couple issues afterward when I went back and checked it with MP3 Diags, particularly when adding cover art (problems with frames and such). So it looks like its best to use MP3 Diags tag editor as it had all the basic parts I needed. The tag editor was basic but worked nice and I found the only tricky thing was adding cover art (which I had to be copied to the clipboard and pasted in). The only way I could find to put an image to the clipboard was to find the image in Firefox and copy it from there. The only question I have now is if MP3 Diags correctly assigned it as CoverArt as it has no ability to specify it. However, when playing the files in Banshee the CoverArt is show correctly.

Since this audiobook hadn’t been listed in an ID3 database, I thought I’d put it up in case anyone else was crazy enough to do this :). After looking at FreeDB some more, I read in the forums that they didn’t think this was a place for audiobooks and that the FreeDB was geared toward audio CDs. However, MusicBrainz had audiobook listings so I decided to put it there. Originally I had tried to use MusicBrainz’s own application (Picard) to tag the MP3s with but to tag with Picard the original needs to be a CD (the DiscID creator feature requires a CD to be inserted). However, Picard does have a plugin available called “Add cluster as release” that works. I installed it following the instructions, put the audiobook into a cluster, right-clicked the ‘Album’ > Plugin > Add cluster as release, created an account (required to submit), and filled out the form as best as I could:

Finally, I found the audiobook on Amazon and did ‘Relate to URL’ to add coverart. When done I was told that MusicBrainz has a process that puts new entries into a queue for peer review.

Thoughts and Conclusion

All and all the process went smooth so I’m happily listening to my audiobook now. I’m happy with the quality for the MP3s except for one thing: when I reach the length in the track where the segments were joined I can hear a slight dip in volume. Barely noticeable so I’m not too worried. I also would have liked to be able to fix the track length error from the command line and enter ID3 information from there as well. If anyone knows of anything, I’d appreciate hearing from you. And finally, if anyone knows if it is possible to get audiobooks in MP3 format that would help me quite a bit.

Fixing MPD

Once before I had installed MPD, and once before I really liked it. But as always with updates something had to be stuborn. I honestly hadn’t noticed the breakage until I tried to play some music recently with Sonata. I have Sonata configured as to search for new audio on every load up. This time I had added new audio to the music folder and this time I got zip – the playlist showed, well… empty. I looked into /var/lib/mpd/database and sure enough it the listing blanked.

It had been awhile since I installed the Music Player Daemon originally, and though I usually take notes of the process i didn’t’ remember to and I was at a loss at how to repair it. With the Gentoo LInux Wiki down last week, I was at a total loss.

Fixing MPD

The Music Player Daemon for those of you who haven’t tried it, heard it, is exactly as it states: a constant running process on your computer that’s able to play music. I should not say “your” however because many people use MPD on server and listen to audio over a network. What I’m talking about here is setting up MPD as a local daemon as opposed to a remote daemon. Why do this? MPD provides an absurdly low CPU usage and since it is continually running near to zero startup times. Using MPD as a local daemon as opposed to the remote daemon, though both processes will be similar, is different enough. I’ll start at the very beginning.

Install MPD

emerge mpd

Setting Permissions

This is what I had forgotten so many months ago. MPD looks at it’s configuration files and requires them to belong to the audio group and also to the owner listed in the configuration file. I saw this as odd as I failed to see why a daemon needs permissions since it runs as root. This is reasonable I learned if you use MPD as it was originally intended: as a remote daemon. An MPD server would create a user “mpd” and hence have all the proper settings to begin distributing sound. I might argue that MPD is probably installed as a local daemon more often then it is as a remote one…

Verify these exist:


The database will need to be created.

echo > /var/lib/mpd/database

As well as a pid file (I’ll talk about that in a bit.)

echo > /var/run/mpd/

All these files and folders must have the correct permissions. They need belong to owner:group – youruser:audio.

chown user:audio /var/lib/mpd/* /var/log/mpd/* /var/run/mpd/*

Now we need to tell MPD where to find your audio directory

cd /var/lib/mpd/music
ln -s /home/user/My\ Audio

Setting the Configuration

nano /etc/mpd.conf

There a few details here that will need to be set to have MPD work nicely

To begin make sure info of the pid file is commented out, this is necessary to the init-script to close correctly.

Now replace your username. Since we won’t be running MPD as a separate user we need to set “mpd” for our own.

Configure audio output if you know all the details otherwise the driver settings will be used (which is what you want for most cases.).

Create the Music Database

Now we should have all the settings need to build a proper database.

mpd --create-db

Start the Daemon

/etc/init.d/mpd start

Add the daemon to the run-level

rc-update add mpd default

Troubleshooting MPD

Setting a pid file as a local daemon is little tricky. MPD wants a Personal ID file which is important to close MPD., whether it’s needed or not… In my personal opinion this is an over-site of MPD as it does not create a new pid on initializing but requires one to shutdown. To add the the dilemma, MPD will delete pid on shutdown, meaning that we will have to make one each time MPD is started. The only solution I’ve found to reasonably fix this is to edit the boot script.

nano /etc/init.d/mpd

And add in the checkconfig section:

echo > /var/run/mpd/
chown user:audio /var/run/mpd/

Picking a Client

Since MPD is a daemon it will not play the music directly, we need a client for that. The MPD wiki offers a good number of them.


I’ve heard of MPD using a ~.mpdconf. Has anyone tried this? How does it work?

I Love Sonata.

The more I learned about music the more I began to think that most music players I used in Linux are just too darned big. My recent Linux experience had me starting with Ubuntu which uses Rhythmbox. A nice app for sure, but i’m the type of person that when I push a button I expect results. :| I have a MacBook so its pretty quick, but from the point I actually started Rhythmbox and played the song it was probably no more the 20 seconds. My problem was unless you have a massive library or are DJ or something you forgot what was behind it. I tried alot quod libet, exaile (actaully I like exaile alot only it has a bug at the time) but they were just too large. So I found Sonata. First time I emerge Sonata I thought it pull in all the dependencies. I started it but it wouldn’t play any of my music. I found out it requires mpd (music player daemon) mpd is a music player that runs all the time in the background. I reported this ommission to bugzilla where sed developer became a little miffed, explaining to me (not so unbluntly) that mpd can also run on a remote system … ahh. Anyways it’s pretty easy to setup. I just followed the HOWTO MPD at the Gentoo Wiki. It was pretty simple.


Lightweight and nice. The only thing that I’d like to be able to do is not see mp3 as the directory header, and instead just the albums:


If keep a static (don’t change much) library of music, you might want to disable “Update MPD library on start, to speed up boot times.  “Sonata is still very very young as well as mpd. Though I haven’t had any issues with it it does take a little bit longer to load that I imagine it possibly could.


Get every new post delivered to your Inbox.

Join 58 other followers