FFT or IFFT lose data

0

I am doing FFT and IFFT with audio signal. The following is the code that i am using. But my question is before FFT, it extracts 1 byte from short array. As you know short is 2 bytes.

why it is doing it? Because of the extraction, After IFFT(FFT(original_audio_buffer)) is not same with original_audio_buffer. why it makes data loss?

public void calculateSignal(short[] original_audio_buffer)
{

    final int mNumberOfFFTPoints = 512;
    double mMaxFFTSample;
    int mPeakPos;

    if(converted_audio_buffer == null)
    {
        converted_audio_buffer = new short[mNumberOfFFTPoints * 2];
    }

    double temp;
    Complex[] y;
    Complex[] complexSignal = new Complex[mNumberOfFFTPoints];
    double[] absSignal = new double[mNumberOfFFTPoints/2];

    for(int i = 0; i < mNumberOfFFTPoints; i++)
    {
        temp = (double)((original_audio_buffer[2*i] & 0xFF) | (original_audio_buffer[2*i+1] << 8)) / 32768.0F;
        complexSignal[i] = new Complex(temp,0.0);
    }

    y = FFT.fft(complexSignal);

    Complex[] z = FFT.ifft(y);

    for(int i = 0; i < z.length; i++)
    {
        double tmp_re = z[i].re();
        tmp_re = tmp_re *  32768.0F;

        int tmpIntRe = (int)tmp_re;

        converted_audio_buffer[2*i] = (short)(tmpIntRe & 0x000000FF);
        converted_audio_buffer[2*i+1] = (short)( (tmpIntRe) >> 8);
    }
java
audio
signal-processing
fft
ifft

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0