私はAndroid用のテストプログラムを作成し、マイクからオーディオを録音し、JTransformlibを使用してfftを計算します。matlabと比較しましたが、同じ結果は得られません。例えば :
JTransform:
real: 0.035003662109375 imag: 0.036529541015625
real: 0.036712646484375 imag: 0.0355224609375
real: 0.033966064453125 imag: 0.033111572265625
real: 0.034149169921875 imag: 0.035858154296875
real: 0.036712646484375 imag: 0.0360107421875
MATLAB:
4.1469
1.6639 + 0.6458i
5.1224 +17.1221i
-4.3110 - 1.8984i
9.3352 + 4.8483i
レコーダー:
DoubleFFT_1D fft1d = new DoubleFFT_1D(bufferSize / 2);
short[] sourceBuffer = new short[bufferSize];
double[] fftBuffer = new double[bufferSize];
FFT fft = new FFT();
recorder.startRecording();
isRecording.set(true);
while(isRecording.get())
{
int read = recorder.read(sourceBuffer, 0, bufferSize);
//Log.e(LOG_TAG, "read: " + read + " bufferSize: " + bufferSize);
if(read != AudioRecord.ERROR_INVALID_OPERATION)
{
for(int i = 0; i < bufferSize && i < read; ++i)
{
// signed int16 to double (2^15 = 32768)
fftBuffer[i] = (double) (sourceBuffer[i] / 32768.0);
try
{
// for matlab
soundFile.write(fftBuffer[i] + "\n");
}
catch (IOException e)
{
Log.e(LOG_TAG, e.getMessage());
}
}
}
}
fft1d.realForward(fftBuffer);