This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C5515 fft / ifft sample code



Hi all,

DSP:C5000

Audio data : 8K sample rate , 16 bit , MONO

I want to use fft / ifft to filter i2s data and compression the data.

If the i2s data are on 20Hz ~ 10KHz , the data don't any change and save to another buffer. If not, the data don't do anything.

Please suggest some C5000 fft / ifft code or library from where my purpose.

ps: I don't know how to use cfft / cifft ,  could you provide sample code ?

  • I've forwarded this to the software experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev,

    Any updates?
  • SMART,
    Please check out the C5x DSPLIB http://www.ti.com/tool/sprc100. It has the fft routines/examples that would help.
    Here is an app note detailing the DSP lib benchmarks which would also help.
    www.ti.com/.../sprac34.pdf

    Lali
  • I used matlab to test fft/ifft function , the result data are the same with input data.
    But i used TI DSP C5515 cfft/cifft , the result data (recBuf_ifft) are different with input data(i2s).
    Please help check this issues.


    ========================================
    matlab code
    ========================================

    y = wavread('Ping\200Hz.wav');

    s = fft(y);
    f = abs(s);

    y2 = ifft(s);
    f2 = abs(fft(y2));

    subplot(3,3,1), plot(s);
    subplot(3,3,2), plot(f); % wav Spectrum
    subplot(3,3,3), plot(y); % wav waveform
    subplot(3,3,4), plot(y2); % ifft waveform
    subplot(3,3,5), plot(f2); % ifft Spectrum



    ========================================
    // c5515 code
    ========================================
    static Uint16 recBuf[512];
    static Uint16 recBuf_fft[512];
    static Uint16 recBuf_ifft[512];

    fft_test()
    {
    for(i=0;i<512;i+)
    {
    recBuf[i] = *i2sRxLeft; // get data from i2s
    recBuf_fft[i] = recBuf[i]; // get data from i2s
    }


    cfft (&recBuf_fft[0], 512/2, NOSCALE); // fft
    for(i = 0; i < 512; i++)
    {
    ABS(recBuf_fft[i]);
    }
    cifft (&recBuf_ifft[0], 512/2, NOSCALE); // ifft
    for(i = 0; i < 512; i++)
    {
    ABS(recBuf_ifft[i]);
    }
    }
  • Any updates? Please help fft/ifft issue
  • Hi SMART

    If I understand your question, your problem is that when you run FFT and then IFFT the results are not the same as the input vector.

    Before I start looking into the code, here are two reasons why it happens-

    The first and obvious one is the limited accuracy of 16-bit arithmetic. You "lose" bits of accuracy in FFT and IFFT. This depends on the size of the FFT (and the IFFT), so for 1024 FFT the error may be up to 10 bits.  MATLAB may convert everything to floating point and does 32-bit or even 64-bit computation.  (I am not sure how MATLAB) does it calculations)

    The second issue is the square of N in the FFT formula.   TI code does not divide the FFT by the square of N.   Some people just multiply by N or divide by N.  I am not going to explain it here, but you can do search and find out (or you already know it)

    So - tell us how the error looks like - is it like random error between two elements or you see a ratio (like N) between the elements of the input and the output of FFT/IFFT

    best regards

    Ran

  • Hi Ran,

    Thanks for your kindly reply, i understand the issue.
    For now , i can use TI cfft / cifft to convert codec data , but i don't know how to convert codec data by cfft/cifft from time scale to frequency scale.
    1) Please advice convert time scale to frequency scale .
    2) Please advice filter 2k Hz by cfft/cifft.


    ======================
    DSP : C5515
    codec : AIC3254 / 8k sample rate / 16 bit / MONO
  • Dear SMART

    The questions that you asked are generic signal processing questions, not specific TI questions. 

    If you search the net you will find many similar questions and discussions. See for example  www.bitweenie.com/.../      or the MATLAB discussion in  https://www.mathworks.com/matlabcentral/newsreader/view_thread/302004  

        Please read these (and other sources) and you will figure it out

    Best Regards

    Ran

    P.S.  Can you please close the thread?