forked from sdr/sdrangelove
ffts
This commit is contained in:
parent
5864e48bd8
commit
34fb4e9973
|
@ -0,0 +1,29 @@
|
|||
#ifndef INCLUDE_FFTSEngine_H
|
||||
#define INCLUDE_FFTSEngine_H
|
||||
|
||||
#include <QMutex>
|
||||
#include <ffts/ffts.h>
|
||||
#include <list>
|
||||
#include "dsp/fftengine.h"
|
||||
|
||||
class FFTSEngine : public FFTEngine {
|
||||
public:
|
||||
FFTSEngine();
|
||||
~FFTSEngine();
|
||||
|
||||
void configure(int n, bool inverse);
|
||||
void transform();
|
||||
|
||||
Complex* in();
|
||||
Complex* out();
|
||||
|
||||
protected:
|
||||
void allocate(int n);
|
||||
ffts_plan_t* m_currentplan;
|
||||
void *imem;
|
||||
void *iptr;
|
||||
void *omem;
|
||||
void *optr;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FFTSEngine_H
|
|
@ -5,6 +5,9 @@
|
|||
#ifdef USE_FFTW
|
||||
#include "dsp/fftwengine.h"
|
||||
#endif // USE_FFTW
|
||||
#ifdef USE_FFTS
|
||||
#include "dsp/fftsengine.h"
|
||||
#endif // USE_FFTS
|
||||
|
||||
FFTEngine::~FFTEngine()
|
||||
{
|
||||
|
@ -20,7 +23,10 @@ FFTEngine* FFTEngine::create()
|
|||
qDebug("FFT: using KissFFT engine");
|
||||
return new KissEngine;
|
||||
#endif // USE_KISSFFT
|
||||
|
||||
#ifdef USE_FFTS
|
||||
qDebug("FFT: using FFTS engine");
|
||||
return new FFTSEngine;
|
||||
#endif // USE_FFTS
|
||||
qCritical("FFT: no engine built");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#include <QTime>
|
||||
#include "dsp/fftsengine.h"
|
||||
|
||||
FFTSEngine::FFTSEngine() :
|
||||
m_currentplan(ffts_init_1d(1024, 1))
|
||||
{
|
||||
allocate(4096);
|
||||
}
|
||||
|
||||
FFTSEngine::~FFTSEngine()
|
||||
{
|
||||
ffts_free(m_currentplan);
|
||||
free(imem);
|
||||
free(omem);
|
||||
}
|
||||
|
||||
void FFTSEngine::allocate(int n)
|
||||
{
|
||||
imem = malloc(n*4*2+15);
|
||||
iptr = (void*)(((unsigned long)imem+15) & (unsigned long)(~ 0x0F));
|
||||
omem = malloc(n*4*2+15);
|
||||
optr = (void*)(((unsigned long)omem+15) & (unsigned long)(~ 0x0F));
|
||||
}
|
||||
|
||||
void FFTSEngine::configure(int n, bool inverse)
|
||||
{
|
||||
ffts_free(m_currentplan);
|
||||
m_currentplan = ffts_init_1d(n, 1);
|
||||
}
|
||||
|
||||
void FFTSEngine::transform()
|
||||
{
|
||||
ffts_execute(m_currentplan, iptr, optr);
|
||||
}
|
||||
|
||||
|
||||
Complex* FFTSEngine::in()
|
||||
{
|
||||
return reinterpret_cast<Complex*>(iptr);
|
||||
}
|
||||
|
||||
Complex* FFTSEngine::out()
|
||||
{
|
||||
return reinterpret_cast<Complex*>(optr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue