From f3dbc6f91a0671f916eb7457dd8b759d9bf3e9c8 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 11 Oct 2020 17:18:58 -0400 Subject: [PATCH] Makefile.am,cwDsp,cwFFT: Updates to make FFTW optional. --- Makefile.am | 17 +++++++++++++---- cwDsp.cpp | 1 + cwDsp.h | 14 ++++++++------ cwFFT.cpp | 18 ++++++++++++++++++ cwFFT.h | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 cwFFT.cpp create mode 100644 cwFFT.h diff --git a/Makefile.am b/Makefile.am index 616ba90..39d898d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 + diff --git a/cwDsp.cpp b/cwDsp.cpp index 48c08c2..a3ce1d1 100644 --- a/cwDsp.cpp +++ b/cwDsp.cpp @@ -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. + diff --git a/cwDsp.h b/cwDsp.h index 453de25..d4ea593 100644 --- a/cwDsp.h +++ b/cwDsp.h @@ -1,7 +1,12 @@ #ifndef cwDsp_H #define cwDsp_H +#ifdef cwFFTW #include +#else +#include "cwFFT.h" +#endif + #include 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(); - } - - + } } } diff --git a/cwFFT.cpp b/cwFFT.cpp new file mode 100644 index 0000000..ad5bd2b --- /dev/null +++ b/cwFFT.cpp @@ -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){} diff --git a/cwFFT.h b/cwFFT.h new file mode 100644 index 0000000..e09cb75 --- /dev/null +++ b/cwFFT.h @@ -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 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 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