Makefile.am,cwDsp,cwFFT: Updates to make FFTW optional.

This commit is contained in:
kevin 2020-10-11 17:18:58 -04:00
parent 1aba926fda
commit f3dbc6f91a
5 changed files with 80 additions and 10 deletions

View File

@ -48,6 +48,12 @@ if cwALSA
libcwHDR += src/libcw/cwMidiPort.h src/libcw/cwAudioDeviceAlsa.h
libcwSRC += src/libcw/cwMidiPort.cpp src/libcw/cwMidiAlsa.cpp src/libcw/cwAudioDeviceAlsa.cpp src/libcw/cwAudioDeviceTest.cpp
if cwWEBSOCK
libcwHDR += src/libcw/cwIo.h src/libcw/cwIoTest.h
libcwSRC += src/libcw/cwIo.cpp src/libcw/cwIoTest.cpp
endif
endif
libcwHDR += src/libcw/cwAudioBufDecls.h src/libcw/cwAudioBuf.h
@ -62,10 +68,6 @@ libcwSRC += src/libcw/cwTcpSocket.cpp src/libcw/cwTcpSocketSrv.cpp src/libcw/cwT
libcwHDR += src/libcw/cwDsp.h
libcwSRC += src/libcw/cwDsp.cpp
if cwWEBSOCK
libcwHDR += src/libcw/cwIo.h src/libcw/cwIoTest.h
libcwSRC += src/libcw/cwIo.cpp src/libcw/cwIoTest.cpp
endif
libcwHDR += src/libcw/cwMdns.h src/libcw/cwEuCon.h src/libcw/cwDnsSd.h src/libcw/dns_sd/dns_sd.h src/libcw/dns_sd/dns_sd_print.h src/libcw/dns_sd/dns_sd_const.h src/libcw/dns_sd/fader.h src/libcw/dns_sd/rpt.h
libcwSRC += src/libcw/cwMdns.cpp src/libcw/cwEuCon.cpp src/libcw/cwDnsSd.cpp src/libcw/dns_sd/dns_sd.cpp src/libcw/dns_sd/dns_sd_print.cpp src/libcw/dns_sd/fader.cpp src/libcw/dns_sd/rpt.cpp
@ -76,3 +78,10 @@ else
# libcwHDR += src/libcw/cwSvg.h src/libcw/cwDataSets.h
# libcwSRC += src/libcw/cwSvg.cpp src/libcw/cwDataSets.cpp
endif
if cwFFTW
else
libcwHDR += src/libcw/cwFFT.h
libcwSRC += src/libcw/cwFFT.cpp
endif

View File

@ -142,3 +142,4 @@ cw::rc_t cw::dsp::convolve::test()
// 1. 0.5 0.25 0.1 1.05 0.5 0.25 0.1 1.05 0.5 0.25 0.1 0.05 0.0. 0. ]
// 1.0 0.5 0.25 0.1 1.05 0.5 0.25 0.1 1.05 0.5 0.25 0.1 1.05 1.0 0.75 0.

14
cwDsp.h
View File

@ -1,7 +1,12 @@
#ifndef cwDsp_H
#define cwDsp_H
#ifdef cwFFTW
#include <fftw3.h>
#else
#include "cwFFT.h"
#endif
#include <type_traits>
namespace cw
@ -185,7 +190,6 @@ namespace cw
//---------------------------------------------------------------------------------------------------------------------------------
// FFT
//
namespace fft
{
@ -264,7 +268,7 @@ namespace cw
fftw_free(p->cplxV);
}
p->u.dplan = nullptr;
//p->u.dplan = nullptr;
mem::release(p->magV);
mem::release(p->phsV);
mem::release(p);
@ -398,7 +402,7 @@ namespace cw
fftw_free(p->cplxV);
}
p->u.dplan = nullptr;
//p->u.dplan = nullptr;
mem::release(p);
return kOkRC;
@ -576,9 +580,7 @@ namespace cw
rc_t test();
}
}
}
}

18
cwFFT.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "cwCommon.h"
#include "cwLog.h"
#include "cwCommonImpl.h"
#include "cwFFT.h"
void* fftw_malloc(unsigned ) { return nullptr; }
void fftw_free(void*){}
fftw_plan fftw_plan_dft_r2c_1d(int bufN, double* buf, fftw_complex* cplxV, int type ){ return 0; }
fftw_plan fftw_plan_dft_c2r_1d(int bufN, fftw_complex* cplxV, double* outV, int flags ) { return 0; }
void fftw_destroy_plan(fftw_plan) {}
void fftw_execute( fftw_plan) {}
void* fftwf_malloc(unsigned ){ return nullptr; }
void fftwf_free(void*) {}
fftwf_plan fftwf_plan_dft_r2c_1d(int bufN, float* buf, fftwf_complex* cplxV, int type ) { return 0; }
fftwf_plan fftwf_plan_dft_c2r_1d(int bufN, fftwf_complex* cplxV, float* outV, int flags ) { return 0; }
void fftwf_destroy_plan(fftwf_plan){}
void fftwf_execute( fftwf_plan){}

40
cwFFT.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef cwFFT_H
#define cwFFT_H
#define FFTW_MEASURE (1)
#define FFTW_BACKWARD (2)
/*
typedef struct fftw_plan_str
{
int foo;
} fftw_plan;
*/
typedef int fftw_plan;
typedef std::complex<double> fftw_complex;
void* fftw_malloc(unsigned );
void fftw_free(void*);
fftw_plan fftw_plan_dft_r2c_1d(int bufN, double* buf, fftw_complex* cplxV, int flags );
fftw_plan fftw_plan_dft_c2r_1d(int bufN, fftw_complex* cplxV, double* outV, int flags );
void fftw_destroy_plan(fftw_plan);
void fftw_execute( fftw_plan );
/*
typedef struct fftwf_plan_str
{
int foo;
} fftwf_plan;
*/
typedef int fftwf_plan;
typedef std::complex<float> fftwf_complex;
void* fftwf_malloc(unsigned );
void fftwf_free(void*);
fftwf_plan fftwf_plan_dft_r2c_1d(int bufN, float* buf, fftwf_complex* cplxV, int flags );
fftwf_plan fftwf_plan_dft_c2r_1d(int bufN, fftwf_complex* cplxV, float* outV, int flags );
void fftwf_destroy_plan(fftwf_plan);
void fftwf_execute( fftwf_plan );
#endif