0

Currently i m kissFFT on the input data..

I had the input data in the std::vector& samples2 i want convert into the format required by the KissFFT..

I am using the following code to convert this,,

but at the end i am getting diff value please help..

here is my code

 ShortBuffer *pBuffer1 = pData->AsShortBufferN();

    std::vector<short> input(pBuffer1->GetPointer(),
            pBuffer1->GetPointer() + BUFFER_SIZE);

    kiss_fft_scalar* samples = (kiss_fft_scalar*) &input[0]; // Here my input data  is change 

please help

Sunny Shah
  • 12,990
  • 9
  • 50
  • 86
  • 1
    The default type for `kiss_fft_scalar` is a `float`. Casting an array of type `short` to type `float` is not going to work. Change `kiss_fft_scalar` to be defined as type `short`, Use `std::vector` or allocate an array of `kiss_fft_scalar` and copy the values over. Those are your options. – Captain Obvlious Jun 05 '13 at 05:11
  • Thnks its now its works for me.. but i m facing another problem that is when i apply this input data to the FFT. FFT output returns nan output. do you have ant idea? – Sunny Shah Jun 05 '13 at 05:35
  • 1
    Yeah, read the manual so you know what you're doing. – Captain Obvlious Jun 05 '13 at 06:28
  • [myCode](http://stackoverflow.com/questions/16931570/how-do-i-get-most-accurate-audio-frequency-data-possible-from-real-time-fft-on-t/16932278?noredirect=1#comment24445183_16932278) in the FFT output i am getting nan output – Sunny Shah Jun 05 '13 at 06:35
  • can you tell me what i am doing wrong? – Sunny Shah Jun 05 '13 at 06:36

2 Answers2

1

The difault value of 'kiss_fft_scalar' is float. but It can be either of type short or float.

http://www.reproducibility.org/RSF/book/rsf/manual/manual_html/node11.html

0

type of kiss_fft_scalar may be float, short, int32 or __m128. It is depend on same preprocessor definitions for FIXED_POINT and USE_SIMD. Check that type of kiss_fft_scalar is short.

Your compiler can help you - do not use C cast:

 kiss_fft_scalar* samples = &input[0];  // type of &input[0] must be kiss_fft_scalar* !!!
SergV
  • 1,269
  • 8
  • 20
  • DO you have any more idea about KissFFT.. actually i am facing some problem with that... – Sunny Shah Jun 05 '13 at 06:24
  • @Sunnyshah kissFFT works for me. Read manual. There is short example in README file. There is test and tool directories. – SergV Jun 05 '13 at 07:58
  • @Sunnyshah. What is a reason that you re-accepted my answers? Do you think it is incorrect answer? – SergV Jun 05 '13 at 08:13
  • @Sunnyshah. You re-accepted answers of "Mis-seok Kang" now. Do you think those answer is wrong? Do you know about concept of "useful" answer and what is "voted"? (See http://stackoverflow.com/about) – SergV Jun 05 '13 at 08:33
  • @Sunnyshah. I think you have read http://stackoverflow.com/about ? Please, up vote answer of "Mis-seok Kang" if it is usefull for you. – SergV Jun 05 '13 at 08:49