Mercurial > hg > btrack
diff src/OnsetDetectionFunction.h @ 96:c58f01834337
Merge branch 'release/1.0.4'
author | Adam Stark <adamstark.uk@gmail.com> |
---|---|
date | Sat, 18 Jun 2016 10:50:06 +0100 |
parents | 4aa362058011 |
children | 8fb1610c9192 |
line wrap: on
line diff
--- a/src/OnsetDetectionFunction.h Sun Jan 10 11:36:52 2016 +0000 +++ b/src/OnsetDetectionFunction.h Sat Jun 18 10:50:06 2016 +0100 @@ -22,7 +22,14 @@ #ifndef __ONSETDETECTIONFUNCTION_H #define __ONSETDETECTIONFUNCTION_H +#ifdef USE_FFTW #include "fftw3.h" +#endif + +#ifdef USE_KISS_FFT +#include "kiss_fft.h" +#endif + #include <vector> //======================================================================= @@ -63,7 +70,7 @@ * @param hopSize_ the hop size in audio samples * @param frameSize_ the frame size in audio samples */ - OnsetDetectionFunction(int hopSize_,int frameSize_); + OnsetDetectionFunction (int hopSize_, int frameSize_); /** Constructor @@ -72,7 +79,7 @@ * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType) * @param windowType the type of window to use (see WindowType) */ - OnsetDetectionFunction(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_); + OnsetDetectionFunction (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_); /** Destructor */ ~OnsetDetectionFunction(); @@ -82,7 +89,7 @@ * @param hopSize_ the hop size in audio samples * @param frameSize_ the frame size in audio samples */ - void initialise(int hopSize_,int frameSize_); + void initialise (int hopSize_, int frameSize_); /** Initialisation Function * @param hopSize_ the hop size in audio samples @@ -90,18 +97,18 @@ * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType) * @param windowType the type of window to use (see WindowType) */ - void initialise(int hopSize_,int frameSize_,int onsetDetectionFunctionType_,int windowType_); + void initialise (int hopSize_, int frameSize_, int onsetDetectionFunctionType_, int windowType_); /** Process input frame and calculate detection function sample * @param buffer a pointer to an array containing the audio samples to be processed * @returns the onset detection function sample */ - double calculateOnsetDetectionFunctionSample(double *buffer); + double calculateOnsetDetectionFunctionSample (double* buffer); /** Set the detection function type * @param onsetDetectionFunctionType_ the type of onset detection function to use - (see OnsetDetectionFunctionType) */ - void setOnsetDetectionFunctionType(int onsetDetectionFunctionType_); + void setOnsetDetectionFunctionType (int onsetDetectionFunctionType_); private: @@ -162,6 +169,8 @@ */ double princarg(double phaseVal); + void initialiseFFT(); + void freeFFT(); double pi; /**< pi, the constant */ @@ -169,11 +178,22 @@ int hopSize; /**< audio hopsize */ int onsetDetectionFunctionType; /**< type of detection function */ int windowType; /**< type of window used in calculations */ + + //======================================================================= +#ifdef USE_FFTW + fftw_plan p; /**< fftw plan */ + fftw_complex* complexIn; /**< to hold complex fft values for input */ + fftw_complex* complexOut; /**< to hold complex fft values for output */ +#endif + +#ifdef USE_KISS_FFT + kiss_fft_cfg cfg; /**< Kiss FFT configuration */ + kiss_fft_cpx* fftIn; /**< FFT input samples, in complex form */ + kiss_fft_cpx* fftOut; /**< FFT output samples, in complex form */ + std::vector<std::vector<double> > complexOut; +#endif - fftw_plan p; /**< fftw plan */ - fftw_complex *complexIn; /**< to hold complex fft values for input */ - fftw_complex *complexOut; /**< to hold complex fft values for output */ - + //======================================================================= bool initialised; /**< flag indicating whether buffers and FFT plans are initialised */ std::vector<double> frame; /**< audio frame */