Hi,
What's wrong with this class? Is this the right way to handle the IppsFFTSpec_C_32fc workspace? I don't think so.
using System;
namespace IPP
{
///
/// Summary description for FFT.
///
public class FFT
{
// TODO: Add x-axis label calculation helpers
// Defines
// private static int PSD_SIZE = 4096;
private static int PSD_SIZE = 64;
private static int PSD_ORDER = 12;
private static int IPP_FFT_NODIV_BY_ANY = 8;
// FFT
public ipp.Ipp32fc []fftIn = new ipp.Ipp32fc[PSD_SIZE];
private ipp.Ipp32fc []fftOut = new ipp.Ipp32fc[PSD_SIZE];
private byte []fftScratch = new byte[PSD_SIZE];
// Power Spectrum
public float []psd = new float[PSD_SIZE];
// FFT Workspace
private ipp.IppsFFTSpec_C_32fc fftw = new ipp.IppsFFTSpec_C_32fc();
// Status
private ipp.IppStatus status;
public FFT()
{
}
unsafe public FONT>void Init()
{
// FFT Workspace
ipp.IppsFFTSpec_C_32fc fftws = fftw; // fftws = new ipp.IppsFFTSpec_C_32fc();
ipp.IppsFFTSpec_C_32fc *pfftws = &fftws;
status = ipp.sp.ippsFFTInitAlloc_C_32fc(&pfftws, PSD_ORDER, IPP_FFT_NODIV_BY_ANY, ipp.IppHintAlgorithm.ippAlgHintFast);
Log("ippsFFTInitAlloc_C_32fc status=" + status.ToString());
fftw = fftws;
}
// Read input from fftIn, write output to psd
unsafe public void Process()
{
// FFT Workspace
ipp.IppsFFTSpec_C_32fc fftws = fftw; // fftws = new ipp.IppsFFTSpec_C_32fc();
ipp.IppsFFTSpec_C_32fc *pfftws = &fftws;
fixed(byte *pfftScratch = fftScratch)
fixed(float *ppsd = psd)
{
status = ipp.sp.ippsFFTFwd_CToC_32fc(fftIn, fftOut, pfftws, pfftScratch);
if (status != ipp.IppStatus.ippStsNoErr) Log("ippsFFTFwd_CToC_32fc status=" + status.ToString());
status = ipp.sp.ippsPowerSpectr_32fc(fftOut, ppsd, PSD_SIZE);
if (status != ipp.IppStatus.ippStsNoErr) Log("ippsPowerSpectr_32fc status=" + status.ToString());
}
for (int i=0; i < PSD_SIZE; i++)
{
psd[i] = 10.0F * (float)Math.Log10(psd[i]);
}
}
private void Log(string text)
{
Console.WriteLine(text);
}
}
}


