PCMデータをマイクからPotr Wendykier(JTransformsのDoubleFFT_1Dクラス)が使用しているこのFFTクラスにどのように渡すべきかを理解できません。AndroidでFFTを使用する
私は実数と虚数を返してから、最終的に周波数= 8000 * i/1024を得るために実数を2倍にしなければならないと思います。
誰かが再生されたノートの頻度を見つけるのを手伝ってもらえますか?
次のように私は記録クラスを持っている:
import edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D;
...other various imports...
class recorderThread {
...public variables...
public static void getFFtresult(){
AudioRecord recorder;
short[] audioData;
int bufferSize;
int samplerate = 8000;//or 8192?
bufferSize= AudioRecord.getMinBufferSize(samplerate,AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT)*2; //get the buffer size to use with this audio record
recorder = new AudioRecord (AudioSource.MIC,samplerate,AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,bufferSize); //instantiate the AudioRecorder
recording=true; //variable to use start or stop recording
audioData = new short [bufferSize]; //short array that pcm data is put into.
int recordingLoops = 0;
while (recordingLoops < 4) { //loop while recording is needed
if (recorder.getState()==android.media.AudioRecord.STATE_INITIALIZED) // check to see if the recorder has initialized yet.
if (recorder.getRecordingState()==android.media.AudioRecord.RECORDSTATE_STOPPED)
recorder.startRecording(); //check to see if the Recorder has stopped or is not recording, and make it record.
else {
recorder.read(audioData,0,bufferSize); //read the PCM audio data into the audioData array
DoubleFFT_1D fft = new DoubleFFT_1D(1023); //instance of DoubleFFT_1D class
double[] audioDataDoubles = new double[1024];
for (int j=0; j <= 1023; j++) { // get audio data in double[] format
audioDataDoubles[j] = (double)audioData[j];
}
fft.complexForward(audioDataDoubles); //this is where it falls
for (int i = 0; i < 1023; i++) {
Log.v(TAG, "audiodata=" + audioDataDoubles[i] + " no= " + i);
}
recordingLoops++;
}//else recorder started
} //while recording
if (recorder.getState()==android.media.AudioRecord.RECORDSTATE_RECORDING) recorder.stop(); //stop the recorder before ending the thread
recorder.release(); //release the recorders resources
recorder=null; //set the recorder to be garbage collected
}//run
}//recorderThread
本当にありがとうございました!
ベン
複製(同じユーザー):PCMデータからアンドロイドにJTransforms FFT(http://stackoverflow.com/questions/7649003/jtransforms-fft-in-android-from-pcm-data) –
FFTに何かを渡すように思われる、実際のデータと想像上のデータを取得しています。 –