How can I get frequency data from PCM using FFT

后端 未结 3 1793
南旧
南旧 2021-02-09 06:20

I have an array of audio data I am passing to a reader:

 recorder.read(audioData,0,bufferSize); 

The instantiation is as follows:



        
3条回答
  •  北海茫月
    2021-02-09 07:01

    Assuming the audioData array contains the raw audio data, you need to create a Complex[] object from the audioData array as such:

    Complex[] complexData = new Complex[audioData.length];
    for (int i = 0; i < complexData.length; i++) {
        complextData[i] = new Complex(audioData[i], 0);
    }
    

    Now you can pass your complexData object as a parameter to your FFT function:

    Complex[] fftResult = FFT.fft(complexData);
    

提交回复
热议问题