summaryrefslogtreecommitdiffstats
path: root/sdrbase/dsp/fftsengine.cpp
blob: e7190651ca813cbbe196af71acb7fffbf29567ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
}