Precise Guitar Tuner - Review

14/09/19 Permalink

Produced as a part of a study into the science of soundwaves this was possibly one of the most fun pieces of software I have written.

I've always had a love of guitars and self taught myself to a decent level using books and the Internet, but I've always been intrigued how a guitar tuner works. How does it know what is in tune?

It turns out it's all in the science of sound waves and how they're formulated. A sound wave is produced by the vibration of air particles and travels in a wave. Now the wave has a frequency (measured in hz, how many waves/second) and amplitude (how tall the wave is) and by pulling data from the mic you can measure this. This is where it gets complicated.

A mic transforms the wave into data. It can 8 bit, 16 bit, 32 bit etc. 8 bit was tested first and it was fairly easy to measure - you've only got 256 values after all, but the accuracy was poor. Too approximated. So up to 16 bit - short values. Way more accurate and suitable - it added a lot more CPU horsepower to the job but it was necessary. The sample rate was next - how much data per second was piped through. It needed to as high as possible but to keep the stability.

The software was firstly developed on desktop Java and then ported quite easily to Android. It was much easier to develop the bulk of the software on the desktop, especially when visualising the sound waves on a graph. I was blown away how different sounds make different waves. You'd think a simple note played on a guitar would look quite similar to a sine wave. Nope, they have a weird shape dependent on something called timbre - the physical shape and type of string can change the shape significantly. All kinds of weird data going on. But I eventually got some decent measurements using various calculations, buffer sizes etc.

At this point the software was at a decent level - enough to port. Because Android is basically a container for Java (mostly earlier versions), the porting was fairly straightforward. A few classes came in different flavours, but a tweak here and there, and the engine was slotted in. Then you've got Android phones supporting various sample rates to contend with. I ended up writing code that would start at a reasonable high and test down until it didn't throw an exception. So some devices will benefit from higher frequencies, ie. more data, more accurate. This has the advantage of the software improving when newer hardware does. I think all devices support 48k which is sufficient, but I wanted to use as much data as possible.

The GUI was next. I wanted it to be clean, simple and fast - you don't want to sit there waiting - you just want to tune your guitar. I always liked the idea of presenting the raw data, but not too much that it would baffle people. So the 2 decimal place accuracy number was added. Then the graphical view to give perspective of where the played string is in relation to the target string and the rest of the strings. Custom tunings presets were then added as an alternative to EADGBE. I've never tuned to some of these tunings before and have to say, they sound awesome. Then I added manual string selection. 4 half notes down, 4 half notes up. I figured if you tune below or higher than this your strings are going to be too loose/tight. This added numerous other combos of setups (531,441 as an overall total (96)). Yes you read that right, over half a million custom tunings.

Anyway, I hope you've enjoyed this blog post, and if you want to try Precise Guitar Tuner out you can download it at Amazon, or Google Play.

Share It: Digg | del.icio.us | Furl | reddit | Facebook | Yahoo! | Send to Phone

mobile-utopia.com | Feedback