NotifyMe 1.1 is out

by jegeblad

Apple accected NotifyMe 1.1 today.

There are a lot of myths about Apple's submission process. In my experience the whole process is quite smooth. Generally, the apps are accepted for the first time within 7 days, and updates within 3-4 days. I have even had an app accepted after 1 1/2 day and an update after 1 day. The strangest experience I have had, was that I received an email that an update of one the apps was going to take a bit longer than usual, but without any explanation. That app ended up taking 10 days to get accepted. The rejections I have had, I think have been pretty fair and I have a feeling that Apple is taking the process pretty serious. The apps are clearly tested thoroughly.

NotifyMe is a speaking clock with a lot of options. The idea was originally pitched to me by Allan Odgaard (the Textmate guy). I think that Allan's vision was a simpler app. I thought a long time about the design and decided that it had to look like the built in Clock app so that people would feel right at home with the app. In reality, the interface may have turned out slightly too complicated and I have started to think about a simpler version.

Speech

The first computer we owned at home was a TI994A. One of the peripherals that I think both my brother and I were most interested in was a speech synthesizer. The idea that you could make the computer talk just seemed so cool and what really turned us on about it was that you could do it from BASIC with one line; something like "10 call say("Hello Dave")". I think the TI had a limited vocabulary.

We never got the speech synthesizer for the TI, but in the early 90s I bought a Sound Blaster Pro card for the family PC. That card transformed the PC from a useless sound device to an 8-bit multimedia powerhouse. It also came with a software-based speech system. I think, there was a horrible API-system that allowed third party applications to use it. The card came with just one speaking software application: The artificial psychologist Dr. Sbaitso (an ELIZA clone). We only played with it once, then the fun wore off and I forgot about speech.

Speex

... Until about 5 years ago when I had a job at a small company that develops training computer games for doctors (medical simulators). To make everything seem more lifelike the software was supposed to read aloud messages once in a while which would include blood pressure and temperature measurements. Just a few days before I started working there, they had a male and female actor read aloud about 1,000 sentences including numbers. Before I started they had already built a simple speech-system. The way it worked was by breaking a message into smaller pieces each matching one of the actor's samples, and then playing back those samples consecutively. A few things, like reading aloud numbers, didn't quite work yet and they wanted me to work on it because it was a simple first assignment. It didn't take long to do, but for some reason it was a lot of fun and it immediately made me happy about the new job.

The speech system was quite strong and over the next couple of months the product was expanded to include 14 different languages, which resulted in hundreds of thousands of samples. One of the problems with that was fitting everything on to a CD. Previously, they had used the Ogg-vorbis sound format, but for speech there is a better sound codec called Speex. I don't remember how much speech there was in the end, but I remember that it was somewhere between 10 and 20 GB of raw sound and that it took my work computer (a Pentium 4, 3 GHz) a couple of days to encode everything in the Speex format. I had to do it several times with different encoding settings to get the management satisfied about the sound. One of the great things about that job was that people were quick to point out if something could be improved.

The speech in NotifyMe

When Allan suggested the app I was already thinking about my old job. One of the really demanding parts of the speech system was recording the samples. You need the right equipment and I remember that at my old job they rented an entire floor at a nearby hotel to record the speech of some 30 actors who were hired for the job. On top of that, a special recording utility was built so that the actors could speak each required sample unsupervised, and so that we wouldn't have to cut silences in the beginning and end of each sample.

In short, the speech-system was actually the source of a lot of pain for us. I was happy, that I only had to deal with the software development part.

I don't know anyone with a neutral English/American accent that I can ask to record 300 samples. I also didn't want to spend days removing silences in the beginning and end of each sample, or having to fight with badly sounding samples. So I quite quickly decided that speech synthesis was the way to go.

When Mac OS X Leopard came out it included updated speech synthesis. The new voice was called Alex and sounds incredibly lifelike compared to the voices from Tiger not to mention the Sound Blaster speech from the 90s. Initially, I was hoping that they had put the speech synthesis on the iPhone, but unfortunately they hadn't. So I decided that a hybrid system would work.

I piece together samples, like we did at my old job, but rather than having actors read the samples, I record the speech synthesis from OS X.

Working with speech on OS X is so simple that it almost made me laugh when I had the app up and running. It takes just a few lines of simple code and amazingly you can output the speech to a file very easily. In the end NotifyMe's 700 samples took only about 1 minute to generate and because I use speech synthesis instead of actors, it is incredible easy to generate new phrases, I don't have to cut out silences in the beginning or the end of samples, and I don't have to worry about unequal sound-volume.

The counter

One of the first things I began working on is the countdown counter of the main screen. It actually consists of a number of CALayers. There is a background layer (the metal). Then there is a layer for each of the numbers. Each layer for the numbers displays a graphic of the numbers from 1 to 10. When a number changes, I simply change the content region of the layer to show the new number. Rather than using the built-in animation from CALayer to do this, I animate the content regions myself to get more control over the animation. I am sure I could reproduce my animation by using the right bits of core animation, but I am still not 100% comfortable with core animation. Finally there is a third set of layers that handles highlight on the numbers to make them look like they are spinning. It is not a complicated system, but it was fun to make.

Keeping the app running
One of the problems on the iPhone is that you cannot have apps running in the background. In fact, you can barely keep them running in the foreground. If an app is "inactive" for about 30 seconds it's sound will be deactivated. There is not much fun in having a countdown for 30 seconds. By accident I discovered that if you play sound you can keep the application alive, so NotifyMe plays a silence every 15 seconds to make sure that it kept active. I don't really know what Apple's reason for deactivating sound is, but this is not a pretty hack.

Shadows in UITableView
The lists of alarms and timers include a shadow at the bottom of the last row. To do this I expand the last cell so that it is slightly taller than the other cells in the UITableView, and then the last few pixel lines of the cell are drawn using alpha. Although that may sound like a trivial solution to the problem, it wasn't. I fought a bit with UITableViewCell and I tried several other approaches before I got it to work.

The overall project
So far, NotifyMe has been a very interesting project. It took less than 10 work-days to develop from beginning to end, and the update took me a couple of extra days. I had to fight a bit with the sound-system on the iPhone and work a bit with the navigation system from UIKit which are used to show the different screens of the application. It is not a technically stunning piece of software, but it does what it is supposed to do and it sure feels like a good robust iPhone app.