Hi,
I have been looking for a working example for the fourier transform using IPP in C#. Issue here is most of the example code here don’t work with the IPP version 9.0.
I wrote following code finally but unfortunately no data is assigned to the destination array. What might be the problem here?
And I have real signal and I create a complex signal to apply fft. Is it better to do fft directly using real signal?
Thanks!
using System.Runtime.InteropServices; using ipp; namespace IntelIPP_Test { unsafe public class Program { // Spec and working buffers static IppsFFTSpec_C_32fc* pFFTSpec; static byte[] pFFTSpecBuf, pFFTInitBuf, pFFTWorkBuf; // Allocate complex buffers static Ipp32fc[] pSrc, pDst; // Query to get buffer sizes static int _sizeFFTSpec, _sizeFFTInitBuf, _sizeFFTWorkBuf; //Set the size static int N = 128; static int order = (int)(Math.Log10((double)N) / Math.Log10(2.0)); static void Main(string[] args) { // Query to get buffer sizes int ippDivisionAlgorithm = 8; // (int)sp.IPP_FFT_DIV_INV_BY_N; IppHintAlgorithm ippPerformanceHint = IppHintAlgorithm.ippAlgHintAccurate; IppStatus result; fixed (int* sizeFFTSpec = &_sizeFFTSpec, sizeFFTInitBuf = &_sizeFFTInitBuf, sizeFFTWorkBuf = &_sizeFFTWorkBuf) { result = sp.ippsFFTGetSize_C_32fc(order, ippDivisionAlgorithm, ippPerformanceHint, sizeFFTSpec, sizeFFTInitBuf, sizeFFTWorkBuf); } // Alloc FFT buffers pFFTSpecBuf = new byte[_sizeFFTSpec]; pFFTInitBuf = new byte[_sizeFFTInitBuf]; pFFTWorkBuf = new byte[_sizeFFTWorkBuf]; // Initialize FFT fixed (byte* p_dftInitBuf = pFFTInitBuf) fixed (byte* p_dftSpecBuf = pFFTSpecBuf) { var p_dftSpec = (IppsFFTSpec_C_32fc*)pFFTSpec; result = sp.ippsFFTInit_C_32fc(&p_dftSpec, order, ippDivisionAlgorithm, ippPerformanceHint, p_dftSpecBuf, p_dftInitBuf); } getData(); // to assign data to pSrc fixed (Ipp32fc* pSource = pSrc, pssDst = pDst) fixed (byte* p_workBuffer = pFFTWorkBuf) fixed (byte* p_dftSpecBuf = pFFTSpecBuf) { var p_dftSpec = (IppsFFTSpec_C_32fc*)p_dftSpecBuf; // Fast Forward Fourier to spectra domain sp.ippsFFTFwd_CToC_32fc(pSource, pssDst, p_dftSpec, p_workBuffer); } }