15 January, 2010

My first published Android App - "Suzuki Twinkle"


I just published my first Android app last night - "Suzuki Twinkle". It's meant to help beginning Suzuki violin students learn their notes, rhythm and pitch. Suzuki Twinkle was pretty rewarding to write, particularly because I was able to involve my kids. If you try it, you'll hear some clapping and cheering when you get something right - those are my kids. The screen you see is for pitch, where the student is expected to tell if the second note was higher or lower than the first. The next release will add score, a little more beauty and hopefully a smaller download size.

From a technical perspective, I ended up trying a good chunk of the Media API. The app plays midi and ogg content. I dabbled with the MediaPlayer for both the midi and ogg, but ended up settling on JetPlayer for the midi, and SoundPool for the ogg. JetPlayer gives you some control over your midi files, although you have to repackage them into a .jet file beforehand. I use the mute capability to mute tracks when playing back notes. This allows me to pack all of the single notes into a single midi file. It probably isn't necessary, seeing as how that is partially the point of Jet, but it does make for less source files when all is said and done.

My original plan for the midi content was to generate the midi notes on the fly using something similar to the midi API in Java SE. Android unfortunately does not expose such an API. So I then pursued AudioTrack, which allows you to stream audio directly. unfortunately the data needs to be PCM encoded, so the level of effort to create the notes was just too high. Thus, I went the JetPlayer route.

For the ogg content, I gave MediaPlayer more of a shot. It mostly worked, but I found that it's lifecycle was too complex for what I wanted (2-3 second playback), and despite my efforts, I could not get it to play well if the previous playback was interrupted. Enter SoundPool. SoundPool was much easier to use. It has a simple lifecycle, and was designed for what I had in mind anyway.

I currently have all this managed by a single Player class that manages all this so that the midi sounds don't clobber the applause and vice versa.

This was actually a pretty simple app overall to implement, as it took just a few days to complete while working a day job and learning about midi from scratch.

Open Source Notes:
This whole app was written with open source software, I am proud to say. I wrote the app on Ubuntu Karmic 9.10 with the following tools:
* Eclipse
* Android SDK
* Rosegarden
* JetCreator
* Gimp

I expect to be posting the source code soon as GPL.

2 comments: