Mercurial > hg > qm-dsp
changeset 503:b1f72e469ec8
Style fixes: avoid unsigned, fix formatting
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 05 Jun 2019 11:18:11 +0100 |
parents | 162673c8f9de |
children | f1070135c8ea |
files | dsp/signalconditioning/DFProcess.cpp dsp/signalconditioning/DFProcess.h dsp/signalconditioning/FiltFilt.cpp dsp/signalconditioning/FiltFilt.h |
diffstat | 4 files changed, 37 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/signalconditioning/DFProcess.cpp Wed Jun 05 11:05:58 2019 +0100 +++ b/dsp/signalconditioning/DFProcess.cpp Wed Jun 05 11:18:11 2019 +0100 @@ -32,7 +32,7 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// -DFProcess::DFProcess( DFProcConfig Config ) +DFProcess::DFProcess( DFProcConfig config ) { filtSrc = NULL; filtDst = NULL; @@ -41,7 +41,7 @@ m_FFOrd = 0; - initialise( Config ); + initialise( config ); } DFProcess::~DFProcess() @@ -49,14 +49,14 @@ deInitialise(); } -void DFProcess::initialise( DFProcConfig Config ) +void DFProcess::initialise( DFProcConfig config ) { - m_length = Config.length; - m_winPre = Config.winPre; - m_winPost = Config.winPost; - m_alphaNormParam = Config.AlphaNormParam; + m_length = config.length; + m_winPre = config.winPre; + m_winPost = config.winPost; + m_alphaNormParam = config.AlphaNormParam; - m_isMedianPositive = Config.isMedianPositive; + m_isMedianPositive = config.isMedianPositive; filtSrc = new double[ m_length ]; filtDst = new double[ m_length ]; @@ -70,7 +70,7 @@ m_FiltFilt = new FiltFilt(params); //add delta threshold - m_delta = Config.delta; + m_delta = config.delta; } void DFProcess::deInitialise()
--- a/dsp/signalconditioning/DFProcess.h Wed Jun 05 11:05:58 2019 +0100 +++ b/dsp/signalconditioning/DFProcess.h Wed Jun 05 11:18:11 2019 +0100 @@ -24,16 +24,18 @@ #ifndef QM_DSP_DFPROCESS_H #define QM_DSP_DFPROCESS_H -#include <stdio.h> #include "FiltFilt.h" -struct DFProcConfig{ - unsigned int length; - unsigned int LPOrd; +#include <stdio.h> + +struct DFProcConfig +{ + int length; + int LPOrd; double *LPACoeffs; double *LPBCoeffs; - unsigned int winPre; - unsigned int winPost; + int winPre; + int winPost; double AlphaNormParam; bool isMedianPositive; float delta; //delta threshold used as an offset when computing the smoothed detection function
--- a/dsp/signalconditioning/FiltFilt.cpp Wed Jun 05 11:05:58 2019 +0100 +++ b/dsp/signalconditioning/FiltFilt.cpp Wed Jun 05 11:18:11 2019 +0100 @@ -29,20 +29,20 @@ { } -void FiltFilt::process(double *src, double *dst, unsigned int length) +void FiltFilt::process(double *src, double *dst, int length) { - unsigned int i; + int i; if (length == 0) return; - unsigned int nFilt = m_ord + 1; - unsigned int nFact = 3 * ( nFilt - 1); - unsigned int nExt = length + 2 * nFact; + int nFilt = m_ord + 1; + int nFact = 3 * (nFilt - 1); + int nExt = length + 2 * nFact; double *filtScratchIn = new double[ nExt ]; double *filtScratchOut = new double[ nExt ]; - for( i = 0; i< nExt; i++ ) { + for (i = 0; i < nExt; i++) { filtScratchIn[ i ] = 0.0; filtScratchOut[ i ] = 0.0; } @@ -51,42 +51,43 @@ double sample0 = 2 * src[ 0 ]; double sampleN = 2 * src[ length - 1 ]; - unsigned int index = 0; - for( i = nFact; i > 0; i-- ) { + int index = 0; + for (i = nFact; i > 0; i--) { filtScratchIn[ index++ ] = sample0 - src[ i ]; } index = 0; - for( i = 0; i < nFact; i++ ) { - filtScratchIn[ (nExt - nFact) + index++ ] = sampleN - src[ (length - 2) - i ]; + for (i = 0; i < nFact; i++) { + filtScratchIn[ (nExt - nFact) + index++ ] = + sampleN - src[ (length - 2) - i ]; } index = 0; - for( i = 0; i < length; i++ ) { + for (i = 0; i < length; i++) { filtScratchIn[ i + nFact ] = src[ i ]; } //////////////////////////////// - // Do 0Ph filtering - m_filter.process( filtScratchIn, filtScratchOut, nExt); + // Do 0Ph filtering + m_filter.process(filtScratchIn, filtScratchOut, nExt); // reverse the series for FILTFILT - for ( i = 0; i < nExt; i++) { + for (i = 0; i < nExt; i++) { filtScratchIn[ i ] = filtScratchOut[ nExt - i - 1]; } // do FILTER again - m_filter.process( filtScratchIn, filtScratchOut, nExt); + m_filter.process(filtScratchIn, filtScratchOut, nExt); // reverse the series back - for ( i = 0; i < nExt; i++) { + for (i = 0; i < nExt; i++) { filtScratchIn[ i ] = filtScratchOut[ nExt - i - 1 ]; } - for ( i = 0;i < nExt; i++) { + for (i = 0; i < nExt; i++) { filtScratchOut[ i ] = filtScratchIn[ i ]; } index = 0; - for( i = 0; i < length; i++ ) { + for (i = 0; i < length; i++) { dst[ index++ ] = filtScratchOut[ i + nFact ]; }
--- a/dsp/signalconditioning/FiltFilt.h Wed Jun 05 11:05:58 2019 +0100 +++ b/dsp/signalconditioning/FiltFilt.h Wed Jun 05 11:18:11 2019 +0100 @@ -29,7 +29,7 @@ virtual ~FiltFilt(); void reset(); - void process( double* src, double* dst, unsigned int length ); + void process(double* src, double* dst, int length); private: Filter m_filter;