Mercurial > hg > qm-dsp
diff dsp/signalconditioning/DFProcess.cpp @ 483:fdaa63607c15
Untabify, indent, tidy
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 31 May 2019 11:54:32 +0100 |
parents | 7461bf03194e |
children | b1f72e469ec8 |
line wrap: on
line diff
--- a/dsp/signalconditioning/DFProcess.cpp Fri May 31 11:02:28 2019 +0100 +++ b/dsp/signalconditioning/DFProcess.cpp Fri May 31 11:54:32 2019 +0100 @@ -35,7 +35,7 @@ DFProcess::DFProcess( DFProcConfig Config ) { filtSrc = NULL; - filtDst = NULL; + filtDst = NULL; m_filtScratchIn = NULL; m_filtScratchOut = NULL; @@ -62,11 +62,13 @@ filtDst = new double[ m_length ]; Filter::Parameters params; - params.a = std::vector<double>(Config.LPACoeffs, Config.LPACoeffs + Config.LPOrd + 1); - params.b = std::vector<double>(Config.LPBCoeffs, Config.LPBCoeffs + Config.LPOrd + 1); + params.a = std::vector<double> + (Config.LPACoeffs, Config.LPACoeffs + Config.LPOrd + 1); + params.b = std::vector<double> + (Config.LPBCoeffs, Config.LPBCoeffs + Config.LPOrd + 1); m_FiltFilt = new FiltFilt(params); - + //add delta threshold m_delta = Config.delta; } @@ -74,13 +76,9 @@ void DFProcess::deInitialise() { delete [] filtSrc; - delete [] filtDst; - delete [] m_filtScratchIn; - delete [] m_filtScratchOut; - delete m_FiltFilt; } @@ -108,76 +106,71 @@ double* scratch = new double[ m_length ]; - for( i = 0; i < m_winPre; i++) - { - if (index >= m_length) break; + for( i = 0; i < m_winPre; i++) { + + if (index >= m_length) { + break; + } - k = i + m_winPost + 1; + k = i + m_winPost + 1; - for( j = 0; j < k; j++) - { - y[ j ] = src[ j ]; - } - scratch[ index ] = MathUtilities::median( y, k ); - index++; + for( j = 0; j < k; j++) { + y[ j ] = src[ j ]; + } + scratch[ index ] = MathUtilities::median( y, k ); + index++; } - for( i = 0; i + m_winPost + m_winPre < m_length; i ++) - { - if (index >= m_length) break; + for( i = 0; i + m_winPost + m_winPre < m_length; i ++) { + + if (index >= m_length) { + break; + } + + l = 0; + for( j = i; j < ( i + m_winPost + m_winPre + 1); j++) { + y[ l ] = src[ j ]; + l++; + } - - l = 0; - for( j = i; j < ( i + m_winPost + m_winPre + 1); j++) - { - y[ l ] = src[ j ]; - l++; - } - - scratch[ index++ ] = MathUtilities::median( y, (m_winPost + m_winPre + 1 )); + scratch[index] = MathUtilities::median( y, (m_winPost + m_winPre + 1 )); + index++; } - for( i = std::max( m_length - m_winPost, 1); i < m_length; i++) - { - if (index >= m_length) break; + for( i = std::max( m_length - m_winPost, 1); i < m_length; i++) { + + if (index >= m_length) { + break; + } - k = std::max( i - m_winPre, 1); + k = std::max( i - m_winPre, 1); - l = 0; - for( j = k; j < m_length; j++) - { - y[ l ] = src[ j ]; - - l++; - } - - scratch[ index++ ] = MathUtilities::median( y, l); + l = 0; + for( j = k; j < m_length; j++) { + y[ l ] = src[ j ]; + l++; + } + + scratch[index] = MathUtilities::median( y, l); + index++; } - - for( i = 0; i < m_length; i++ ) - { - //add a delta threshold used as an offset when computing the smoothed detection function - //(helps to discard noise when detecting peaks) - val = src[ i ] - scratch[ i ] - m_delta; - - if( m_isMedianPositive ) - { - if( val > 0 ) - { - dst[ i ] = val; - } - else - { - dst[ i ] = 0; - } - } - else - { - dst[ i ] = val; - } + for( i = 0; i < m_length; i++ ) { + //add a delta threshold used as an offset when computing the smoothed detection function + //(helps to discard noise when detecting peaks) + val = src[ i ] - scratch[ i ] - m_delta; + + if( m_isMedianPositive ) { + if( val > 0 ) { + dst[ i ] = val; + } else { + dst[ i ] = 0; + } + } else { + dst[ i ] = val; + } } - + delete [] y; delete [] scratch; } @@ -193,8 +186,7 @@ MathUtilities::getAlphaNorm( src, m_length, m_alphaNormParam, &DFAlphaNorm ); - for (int i = 0; i < m_length; i++) - { - dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm; + for (int i = 0; i < m_length; i++) { + dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm; } }