Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Android process audio for guitar tuner (Read 9581 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Android process audio for guitar tuner

Just wondering what is the best way to process audio so I can output what note is being read in. I am doing a guitar tuner for a college assignment and I am new to Android development. I have seen the Android example on recording sounds on from the Google API, but I was wondering where to go from there? I understand I have to do a Furior Transform or something to get the frequency, just wondering if anybody has any advice on how to do this. Once we can get the correct frequency displayed on screen we have a bulk of our project done. Thanks for any help.

Android process audio for guitar tuner

Reply #1
Just go do some research, I had to use a thing called a library to do essentially what you're doing  My dissertation was taking a recording of a bass guitar (monophonic only) and turning it into a musical score.

The hard work of your project (from what I understand from what you've written) is working out what frequency is being played so you're essentially asking us to do the assignment.

Android process audio for guitar tuner

Reply #2
THere's a tuner plugin for rockbox, which I'm guessing is open source.

Android process audio for guitar tuner

Reply #3
Just wondering what is the best way to process audio so I can output what note is being read in. I am doing a guitar tuner for a college assignment and I am new to Android development. I have seen the Android example on recording sounds on from the Google API, but I was wondering where to go from there? I understand I have to do a Furior Transform or something to get the frequency, just wondering if anybody has any advice on how to do this. Once we can get the correct frequency displayed on screen we have a bulk of our project done. Thanks for any help.



Googling 'Android FFT' brings up a 100 line block of code for computing the FFT in java on Android.  You could look at that.

Android process audio for guitar tuner

Reply #4
To help you on your forthcoming searches, it’s a Fourier transform, not Furior.

Android process audio for guitar tuner

Reply #5
In addition to finding out about the frequency resolution of Fourier Transforms, you might want to look into Phase Locked Loops (PLL) and the methods used in all-electronic guitar tuners if you wish to get within '1 cent' (1/100th of a semitone = ratio 1:2^(1/1200)) of the correct pitch.
Dynamic – the artist formerly known as DickD

Android process audio for guitar tuner

Reply #6
The most obvious solution would be to read in a buffer of data, run an FFT to get the data in the frequency domain then analyse the response. You will find peaks in the frequency response corresponding to the tones. If you're targeting Android then you may at first consider FFT implementations in Java.

If you use a buffer length that is a power of 2 (e.g. 128, 256, 512, 1024, 2048 etc) then the FFT is quite easy to implement and since it does not depend on external libraries, you will find that array index based C and C++ solutions will port very easily over to Java. Solutions that use pointers will require some modification.

Here's a link to someone who ported the example from Numerical Recipies in C to Java:
http://blog.datasingularity.com/?p=53

There are some other Java FFT ports that I have identified for you but have never used:
http://www.wikijava.org/wiki/The_Fast_Four...va_%28part_1%29
http://introcs.cs.princeton.edu/java/97data/FFT.java.html

You will find that discontinuities at the ends of the buffer will create artifacts in the frequency response, so you may want to multiply the buffer with a window function before running the FFT to reduce this problem. You can find a list of window functions at http://en.wikipedia.org/wiki/Window_function. Since your buffer will be fixed length, you can pre-compute this and store in a table the same length as your input buffer. Run over your input buffer and multiply by each value by the corresponding value in the window function table to reduce artifacts coming from the edges of the buffer.

If you find that performance is not very good in Java, you may consider a JNI call to one in ARM assembly language. page 303 of the following free book provides a high performance assembly language implementation of the FFT that will run many orders of magnitude faster than a Java version. It will take you a bit of time to set it up, so I wouldn't bother with this until you have everything working and you find that it needs to go faster.

http://read.pudn.com/downloads154/ebook/68...-and-design.pdf

If you only need to isolate a handful of frequencies then you may also consider an array of Goertzel filters or an array of IIR band-pass filters. These will run much faster than the FFT if you are only interested in a few frequencies. IIR filters are a bit more controllable than Goerzel filters which you can read about here:
http://en.wikipedia.org/wiki/Goertzel_algorithm

If you need to design an IIR filter, then you can use SciPi, SciLab or Gnu Octave, or a simpler option is to use MicroModeler DSP, which will also generate the IIR code for the filter in C which you could then port to Java:
http://www.micromodeler.com

They also have a tutorial on IIR filters here which seems very easy to understand, although I would recommend starting from their earlier tutorials if you are new to the subject:
http://www.micromodeler.com/articles/Intro...onToDSP/IIR.jsp

Hope this helps you and good luck.