Mercurial > hg > vamp-tempogram
diff FIRFilter.cpp @ 15:203551cbad47
* FIRFilter now has three output options - take all output elements, first lengthOfInput outputs, or take first lengthOfInput output after group delay
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 14 Aug 2014 11:09:43 +0100 |
parents | c11367df624d |
children | de7213b35755 |
line wrap: on
line diff
--- a/FIRFilter.cpp Thu Aug 14 10:31:49 2014 +0100 +++ b/FIRFilter.cpp Thu Aug 14 11:09:43 2014 +0100 @@ -57,8 +57,9 @@ } void -FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput) +FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput, OutputTypeArgument outputType) { + //Copy to same length FFT buffers for(unsigned int i = 0; i < m_lengthFIRFFT; i++){ m_pFftInput[i] = i < m_lengthInput ? pInput[i] : 0.0; @@ -77,9 +78,13 @@ FFT::inverse(m_lengthFIRFFT, m_pFftFilteredReal, m_pFftFilteredImag, m_pFftOutputReal, m_pFftOutputImag); //copy to output - int offset = ceil(m_numberOfCoefficients/2); - //int offset = 0; - for (unsigned int i = 0; i < m_lengthInput; i++){ + int offset = 0; + unsigned int outputLength = m_lengthInput; + if (outputType == all) outputLength = m_lengthFIRFFT; + else if (outputType == middle) offset = floor((float)m_numberOfCoefficients/2); + else if (outputType != first) cerr << "FIRFilter::process(params) - " << outputType << " is not a valid argument. outputType is set to first." << endl; + + for (unsigned int i = 0; i < outputLength; i++){ pOutput[i] = m_pFftOutputReal[i + offset]; } }