0

I've been doing a bit of research on determining frequency given raw audio. There seems to be a lot of information on it, but I haven't been able to find a simple implementation using java. What I would like to do is partition an array of bytes with 44.1K elements into samples of size 44 (discarding the remainder) and determine if there is a tone over 18KHz in each sample (I'm trying to find when a tone that was played during the recording was picked up by the mic). If need be, I could use larger samples but 44 elements per sample would be ideal. I understand that I would probably need to use FFT, but the math is a little heavy for me. I had attempted to analyze the array using the goertzel algorithm, but I wasn't able to get conclusive results. My question then is how would I divide up an array of bytes with 44.1K elements into 1002 samples, determine the frequency of each sample (or detect if the frequency of a sample is over 18KHz), and what would be an example implementation of this. Please give code or pseudocode. I've read a lot of the documentation that is out there I just need to see an example.

HXSP1947
  • 1,311
  • 1
  • 16
  • 39
  • You really should persist with the Goertzel approach rather than FFT for the reasons I gave in response to [your previous question](http://stackoverflow.com/questions/18652000/record-audio-in-java-and-determine-real-time-if-a-tone-of-x-frequency-was-played). – Paul R Sep 09 '13 at 07:31

1 Answers1

0

About FFT in java, have a look at Reliable and fast FFT in Java

Everything else is just a loop:

for (int i=0; i<sampleArray.length; i+=44) {
    if (findOver18KHz(sampleArray, i, i++44)) {
        // found tone over 18KHz
    }
}

/**
 * Check for a tone over 18KHz
 */
boolean findOver18KHz(int[] samples, start, end) {
  // call the FFT stuff
  // make sure you don't get an ArrayOutOfBoundsException for samples.
}
Community
  • 1
  • 1
BetaRide
  • 16,207
  • 29
  • 99
  • 177