Thursday, March 5, 2009

Java Midlet as a guitar tuner - fail & success :)

[Updated]

So, just about 2 days ago i started to play around with my nokia e51 phone and java midlets. After some frustration i managed to come up with an application that measures the sound frequencies for me. And all that just to leave me in trouble after all.

It turns out that the micrphone of a mobile phone is just awful :) Literally awful. Anything that goes below 150hz is not noticed ... which is the lower 3 strings of the guitar (82.4, 110.0, 146.8). After i fixed the buffer reading and decoding, i did get the higher frequencies correct, so at least that's good. I detect correctly the 3 higher strings of the guitar (329.6, 246.9, 196.0), not missing by an inch (tested with audacity).

It looks like a mission impossible to get a correct reading from this on it's own, for the lower frequencies, it just won't work. No matter what you measure ( FFT aka Fast Fourier Transforms, just zero crossing counting, whatever else ...), the pcm reading that you get isn't just accurate below 150hz. What a shame :(

Long story short : you need something a lot better than a mobile phone microphone, to get an audio tuning that is good enough to tune any kind of instrument (well maybe drums would work but :p, you get the idea)

psps. it's really easy to create java midlets if you have any idea how the language works

pspsps. i will keep the code around in my gmail box, i may need it one day :)

maybe i will give the same code a shot behind a pc mic as well, just to know how good sensitivity do those have.