How can I get frequency data from PCM using FFT

后端 未结 3 1794
南旧
南旧 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);
    
    0 讨论(0)
  • 2021-02-09 07:12

    PCM is the technique of encoding data. It's not relevant to getting frequency analysis of audio data using FFT. If you use Java to decode PCM encoded data you will get raw audio data which can then be passed to your FFT library.

    0 讨论(0)
  • 2021-02-09 07:14

    Some of the details will depend on the purpose of your FFT.

    The length of the FFT required depends on the frequency resolution and time accuracy (which are inversely related), that you wish in your analysis, which may or may not be anywhere near the length of an audio input buffer. Given those differences in length, you may have to combine multiple buffers, segment a single buffer, or some combination of the two, to get the FFT window length that meets your analysis requirements.

    0 讨论(0)
提交回复
热议问题