Mercurial > hg > vamp-tempogram
comparison 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 |
comparison
equal
deleted
inserted
replaced
14:c11367df624d | 15:203551cbad47 |
---|---|
55 m_pFftInput[i] = m_pFftCoefficients[i] = m_pFftReal1[i] = m_pFftImag1[i] = m_pFftReal2[i] = m_pFftImag2[i] = m_pFftFilteredReal[i] = m_pFftFilteredImag[i] = m_pFftOutputReal[i] = m_pFftOutputImag[i] = 0.0; | 55 m_pFftInput[i] = m_pFftCoefficients[i] = m_pFftReal1[i] = m_pFftImag1[i] = m_pFftReal2[i] = m_pFftImag2[i] = m_pFftFilteredReal[i] = m_pFftFilteredImag[i] = m_pFftOutputReal[i] = m_pFftOutputImag[i] = 0.0; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void | 59 void |
60 FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput) | 60 FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput, OutputTypeArgument outputType) |
61 { | 61 { |
62 | |
62 //Copy to same length FFT buffers | 63 //Copy to same length FFT buffers |
63 for(unsigned int i = 0; i < m_lengthFIRFFT; i++){ | 64 for(unsigned int i = 0; i < m_lengthFIRFFT; i++){ |
64 m_pFftInput[i] = i < m_lengthInput ? pInput[i] : 0.0; | 65 m_pFftInput[i] = i < m_lengthInput ? pInput[i] : 0.0; |
65 m_pFftCoefficients[i] = i < m_numberOfCoefficients ? pCoefficients[i] : 0.0; | 66 m_pFftCoefficients[i] = i < m_numberOfCoefficients ? pCoefficients[i] : 0.0; |
66 } | 67 } |
75 } | 76 } |
76 | 77 |
77 FFT::inverse(m_lengthFIRFFT, m_pFftFilteredReal, m_pFftFilteredImag, m_pFftOutputReal, m_pFftOutputImag); | 78 FFT::inverse(m_lengthFIRFFT, m_pFftFilteredReal, m_pFftFilteredImag, m_pFftOutputReal, m_pFftOutputImag); |
78 | 79 |
79 //copy to output | 80 //copy to output |
80 int offset = ceil(m_numberOfCoefficients/2); | 81 int offset = 0; |
81 //int offset = 0; | 82 unsigned int outputLength = m_lengthInput; |
82 for (unsigned int i = 0; i < m_lengthInput; i++){ | 83 if (outputType == all) outputLength = m_lengthFIRFFT; |
84 else if (outputType == middle) offset = floor((float)m_numberOfCoefficients/2); | |
85 else if (outputType != first) cerr << "FIRFilter::process(params) - " << outputType << " is not a valid argument. outputType is set to first." << endl; | |
86 | |
87 for (unsigned int i = 0; i < outputLength; i++){ | |
83 pOutput[i] = m_pFftOutputReal[i + offset]; | 88 pOutput[i] = m_pFftOutputReal[i + offset]; |
84 } | 89 } |
85 } | 90 } |
86 | 91 |
87 //remove memory allocations | 92 //remove memory allocations |