Categories
Software

Creating an Audiobook for the iPod

iPodiPods treat audiobooks differently than music files. For one you can leave an audiobook listen to something else, and later pick up where you left off. An iPod won’t do this when you are listening to music file. Furthermore an audiobook can have chapter markings making it easier to find a chapter in a longer book.

iTunes makes it easy to create a music file for the iPod. You can insert a CD and iTunes will import it at the push of a button. Creating a proper audiobook however, is difficult with iTunes. You could import a whole CD as a single file but what if your audiobook covers multiple CDs?

I’ve had this problem for a while now. My initial solution involved importing each track and numbering them in a way that they would line up in a playlist. This works, but it’s annoying. I can play the book but if I stop I have to remember which chapter I left off with. If I don’t go back to the book for a couple of days I forget where I am and have to start over. A couple of weeks ago I finally had enough and went searching for a better solution.

The solution to my problem came from a program called Chapter and Verse by lodensoftware.com.  The program will take a list of AAC (.m4a) files and convert them into one single audiobook (.m4b).  This makes creating an audiobook from a CD very easy.  Simply import the CD using iTunes in the AAC format and then use Chapter and Verse to make the conversion.

Chapter and Verse - Main screen

Chapter and Verse is not perfect however.  If files are not in the AAC format it will have to convert them into this format before creating the audiobook.  If you use a free audiobook solution such as librivox.org this means it’ll have to convert each file before combining them into one.  Not too big of a deal, just plan a little extra time when creating an audiobook from a set of mp3s.

Quick Audiobook Tutorial

Creating an audiobook is very easy in Chapter and Verse.  First download and install the application.  You will need to make sure iTunes is installed as well because it is used by Chapter and Verse to convert files.

Once Chapter and Verse is installed start the application and it will load to an empty project screen.  Each project contains a set of AAC audio files which will end up being the chapters in this simple tutorial.

Begin by clicking the “Add Files” button to add the audio files you want to be a part of the audiobook.  The open file dialog only shows MP4 files by default so be sure to change the filter if you are adding say .mp3 files.

If you added a file that is not in the AAC format Chapter and Verse will attempt to convert the file using iTunes.  In that case click “Yes – Convert” on the conversion screen.  iTunes will open for the conversion, do not close it until it’s done.  When Chapter and Verse is done with the conversion your files will be added to the “Input Files” tab.

Click on the “Chapters” tab to change each chapter’s name.  On this tab you can rename each chapter in the audiobook.  For my audiobooks I generally set each chapter name to be the same as that of the file.  There are several options here that you may wish to explore.  Near the bottom of the tab there is an “Input Files” dropdown where you can choose prefixes for the chapter names.  I usually to choose the <Filename> option and leave the rest of the settings at their defaults.

The “Metadata” tab allows you to change the file information for the audiobook.  I usually set the title because that is displayed in the track listing on the device.

Finally make sure “Autobuild” is on and then click the “Build Audiobook” button.  Chapter and Verse will ask you where to save the file and then will create the book.

So to sum it all up

  1. Click Add Files to add your audio tracks, Chapter and Verse will convert them if necessary.
  2. Edit the chapter titles on the “Chapters” tab.
  3. Edit the final file information on the “Metadata” tab.
  4. Build the audiobook

 

Ahh programming for a living…  There’s nothing quite like working on someone else’s problem for hours on end trying to get the dumb thing to do what you want.

Alright I’ll admit it; there are some days when I would rather be at home working on one of my own projects.  Those days I find it very hard to focus because one thought runs through my head.  “My own projects are fun and exciting and this is soooo BORING, I want to go home!”

But since my fun projects don’t put food on the table I have to snap out of it and get my head back into what actually does.  I find on those days it’s best to medicate the problem a little with my trusty iPod.  With my iPod I can do something for myself while still working and lately I have been on an audiobook and podcast kick.

iPods treat audiobooks and podcasts differently than they do music files.  For one you can leave a podcast, listen to something else, and later pick up where you left off.  An iPod won’t do this when you are listening to music.  Furthermore an audiobook can have chapter markings making it easier to find a chapter in a longer book.

iTunes makes it easy to create a music file for the iPod.  You can insert a CD and iTunes will import it at the push of a button.  Creating a proper audiobook however, is impossible with iTunes.  Oh sure you could import a whole CD as a single file but what if your audiobook covers multiple CDs?

I’ve had this problem for a while now.  My initial solution involved importing each track and numbering them in a way that they would line up in a playlist.  This works, but it’s annoying.  I can play the book but if I stop I have to remember which chapter I left off with.  If I don’t go back to the book for a couple of days I forget where I am and have to start over.  A couple of weeks ago I finally had enough and went searching for a better solution.

The solution to my problem came from a program called Chapter and Verse by lodensoftware.com.  The program will take a list of AAC (.m4a) files and convert them into one single audiobook (.m4b).  This makes creating an audiobook from a CD very easy.  Simply import the CD using iTunes in the AAC format and then use Chapter and Verse to make the conversion.

Chapter and Verse is not perfect however.  If files are not in the AAC format it will have to convert them into this format before creating the audiobook.  If you use a free audiobook solution such as librivox.org this means it’ll have to convert each file before combining them into one.  Not too big of a deal, just plan a little extra time when creating an audiobook from a set of mp3s.

Categories
Programming

Starting a Windows Forms .NET Application

This week at work I have been redesigning the flow of our internal application. When Sally gets into work the first thing she does is launch this internal application. The application opens to a login form which disappears when she enters her credentials. A secondary screen then shows up asking which set of data she would like to work with. She chooses what she’s been assigned to work on and waits for the data to load in a third screen.

The code required to launch such an application is very straight forward. The login form needs to be displayed and when it is dismissed the secondary form can be shown. The third screen can be launched off of the second and will stay alive as long as the second is open.

Program.cs

///
/// Entry point for the test application
///
static class Program
{
    ///
    /// The main entry point for the application.
    ///
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        // Ask the user to login
        Login.LoginScreen login = new Login.LoginScreen();
        Application.Run(login);

        if (login.DialogResult == DialogResult.OK)
        {
            // Run the main application
            Application.Run(new NewWindowApp());
        }
    }
}

Take a look at lines 17 and 22 in the code sample from Program.cs.  The calls to Application.Run(Form) start a message loop on the current thread enabling the form to receive Windows messages.  Application.Run(Form) essentially says to Windows, “Here take this form and show it to the user.”  The form that is supplied can launch other child forms but when it dies so does the whole application.

My goal this week has been to make Sally’s job a little easier by removing the secondary screen and building its functionality into the third screen.  Now normally this would be as simple as replacing line ten with Application.Run(new ThirdForm());.  However that will not work in this case because the third form has a very useful “New Window” button.

Oh, it will work just fine for a while. Sally can click the button leaving her with two views of the application. However the message loop is only hooked up to the first form and if it is closed both forms will die off.

The solution to this problem is in an overload to the Application.Run method that takes an ApplicationContext property. In fact the documentation at MSDN shows a partial solution to my problem.

Instead of supplying Windows with a Form to display to the user I now supply a custom ApplicationContext object.  This custom context can manage the new window call and keep the application alive no mater which form is closed.

Context.cs

/// 
/// Does the work of firing off new application windows.
/// 
internal class Context : ApplicationContext
{
    // The number of windows currently open
    private int mWindowCount;

    /// 
    /// Initializes a new instance of the  class.
    /// 
    public Context()
    {
        this.NewWindow();
    }

    /// 
    /// Creates and shows a new window.
    /// 
    public void NewWindow()
    {
        NewWindow window = new NewWindow(this);

        window.FormClosed += new FormClosedEventHandler(window_FormClosed);

        ++this.mWindowCount;

        window.Show();
    }

    // Close out the application when all windows have been exited
    private void window_FormClosed(object sender, FormClosedEventArgs e)
    {
        NewWindow window = sender as NewWindow;            
        if (window != null)
        {
            window.FormClosed -= this.window_FormClosed;
        }

        --this.mWindowCount;

        if (this.mWindowCount <= 0)
        {
            this.ExitThread();
        }
    }
}

It's important to note that this object knows how many windows there are.  Also note that as each window is created by NewWindow() a listener is added to the FormClosed event.  These two elements allow the context to know when the last form is closed and therefore when to finally exit.

Full source code for the project.