我有一个音频数据的数组,我正在传递给读取器:
recorder.read(audioData,0,bufferSize);
实例化的步骤如下:
AudioRecord recorder;
short[] audioData;
int bufferSize;
int samplerate = 8000;
//get the buffer size to use with this audio record
bufferSize = AudioRecord.getMinBufferSize(samplerate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT)*3;
//instantiate the AudioRecorder
recorder = new AudioRecord(AudioSource.MIC,samplerate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT,bufferSize);
recording = true; //variable to use start or stop recording
audioData = new short [bufferSize]; //short array that pcm data is put into.
我找到了一个FFT类和一个与之配套的复数类。我已经尝试了两天在网上寻找答案,但是无法弄清如何循环遍历存储在audioData
中的值并将其传递给FFT。
这是我正在使用的FFT类:http://www.cs.princeton.edu/introcs/97data/FFT.java,以及与之配套的复数类:http://introcs.cs.princeton.edu/java/97data/Complex.java.html