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=53There 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%29http://introcs.cs.princeton.edu/java/97data/FFT.java.htmlYou 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.pdfIf 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_algorithmIf 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.comThey 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.jspHope this helps you and good luck.