- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm developing an application for Xscale processor. The goal is to perform FFT of already acquired block of data.
Below is a snippet of the code I'm using:
IppsFFTSpec_R_32s *pFFTSpec = NULL;
Ipp8u *pWorkBuf = NULL;
Ipp32s* pDst = ippsMalloc_32s(blockSize + 2);
Ipp32s* pDstMag = ippsMalloc_32s(blockSize/2);
status = ippsFFTInitAlloc_R_32s(&pFFTSpec, order, IPP_FFT_DIV_FWD_BY_N, ippAlgHintNone);
status = ippsFFTGetBufSize_R_32s(pFFTSpec, &bufSize);
pWorkBuf = (Ipp8u*)malloc(bufSize);
ippsFFTFwd_RToCCS_32s_Sfs(pSrc, (Ipp32s*)pDst, pFFTSpec, 0, pWorkBuf);
ippsMagnitude_32sc_Sfs((Ipp32sc*)pDst, pDstMag, blockSize/2, 0);
Hope somebody in the forum has done similar processing, and will be kind enough to look at the code snippet to point at my mistake. I think I'm doing something wrong.
Thank you,
Leon Kosovsky
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Leon,
there is comment from our experts:
it seems you are trying to apply complex magnitude to results from real FFT transform.
Please try to convert CCS data to complex format or perform complex FFT operation.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
there is additional comment from our expert:
if you are interested only in first half of FFT results you may use CCS format.
It is not clear what seems to be wrong for you, FFT results or subsequent Magnitude results?
BTW, please note that in your code FFT contains blockSize/2 + 1 complex elements whereas Magnitude calculates 1 elements less.
The results of FFT is divided by 2**order (IPP_FFT_DIV_FWD_BY_N) so results of Magnitude will be also N times less. If you need Magnitude results in correct range you may use IPP_FFT_NODIV_BY_ANY at FFT call or you can apply scalefactor = -order at Magnitude call.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was trying to imitate an Example 7-5, from page 7-38 from the latest (v5.2) ippsman.pdf. I am interested in only first part of FFT. That is why I was using CCS format and ippsMagnitude function.
Now, the FFT result was correct only partially: frequencies were all in right spots but amplitudes ( and subsequently magnitudes) were off.
It turned out, and I have to apologizes for this, I had a problem with raw data that was processed by my FFT implementation. I expected to see specific spectrum magnitudes assuming known input signals. But these signals were corrupted due to problem in DAQ driver. That is why results were wrong. When I fixed the driver everything became correct.
I've applied the advice you give in your post. Here is the final stripped code snippet that works for me:
Ipp32s* pDst = ippsMalloc_32s(blockSize + 2);
Ipp32s* pDstMag = ippsMalloc_32s(blockSize/2 + 1);
status = ippsFFTInitAlloc_R_32s(&pFFTSpec, order, IPP_FFT_DIV_FWD_BY_N, ippAlgHintNone);
status = ippsFFTGetBufSize_R_32s(pFFTSpec, &bufSize);
pWorkBuf = (Ipp8u*)malloc(bufSize);
ippsFFTFwd_RToCCS_32s_Sfs(pSrc, pDst, pFFTSpec, 0, pWorkBuf);
ippsMagnitude_32sc_Sfs((Ipp32sc*)pDst, pDstMag, (blockSize/2 + 1), -1);
Hope it'll be useful for our online community :-)
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you for sharing your findings here, definetely it may help others to use IPP functions in their applications
Regards,
Vladimir
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page