Skip to content

Android: Fretter

by peterdk on April 11th, 2010

Currently I am also working on an Android App called Fretter. It’s an advanced chordfinder for guitar, banjo and ukulele. Advanced, because it support lots of tunings and even custom ones for all mentioned instruments and tries to find all voicings of a single chord. So when you select the C chord, it will give you around 12 possible valid options of how to play that Chord. Really cool.

How it works
It’s even more cool, because the chorddiagrams are not stored in the database but calculated on the fly. That means that I (thank God) didn’t entered all the variations in a database and simply retrieve them on user command. No, I wrote it that it knows what a major chord is, that it knows what a C note is and by combining this knowledge knows which notes a CMajor chord consists off.  It then is able to calculate all the valid chordfingerings for a given tuning.  The great thing about this, is that I can simply add chordtypes to it’s library, and it will be able to calculate them for every pitchclass and every instrument. That’s what computerprograms should be like: letting the computer do the hard work.

Profiling and optimizing
One of the really cool things during development was the optimization phase. I had some prior experience with profiling code because I had joined a simple programming competition where you needed to create a “zeeslagje” bot (Battleship game). Such a bot needed to run as fast as possible, so I tried a profiler for the first time.
In the case of Fretter, it’s obvious that the actual chordfinding needs to be as fast as possible. If it takes more than 1 or 2 seconds, the user will be frustrated because of the waiting (Well, I would definitely be). In that case I would need to use  a pre filled database with all the calculated results. I still would have the benefits of not having to enter all the chords manually, but users would still have to wait long when they select a non-standard tuning. I guess I would end up with a 10mb sqlite database, which is unacceptable.

It didn’t looked good the first time when I tried the completed chordfinder. It took 4-6 seconds to generate the chords. That’s a lot. Thankfully, VisualVM helped me pinpoint a lot of hotspots that could be optimized. It’s really cool to work on something, and then when you profile again, you get a 200% faster program! Some methods just needed a little work, and some methods needed to be rewritten into a smarter one. But the endresult was: from 4-6 seconds to 1-2. Really cool and now workable!

Same thing for the reverse chordfinder. It is definitely slower then the normal chordfinder, but that was to be expected. I think I improved the algorithm speed by around 250%. Now it takes I guess 4 seconds to complete. Very acceptable, since it’s something you will use more incidentally.

The real world
Today I have received my G1, and in a few days I will be able to test my app on a real android device. I am greatful to Google that they have limited their emulator to a certain bogomips. I expect the real device will perform with the same processing power as the emulator, but that certainly needs to be tested. Looking forward to it.

Availability and info
Fretter will be available on the appstore for €1.50,-. It supports guitar, 4-string and 5-string banjo and ukelele.
If you have another instrument you would like to have added, let me know. Custom tunings are supported.

From → Android, Java

Comments are closed.