Mercurial > hg > vamp-tempogram
comparison FIRFilter.cpp @ 20:de7213b35755
* Removed warnings of comparisons with ints and size_t
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Fri, 15 Aug 2014 15:17:28 +0100 |
parents | 203551cbad47 |
children | c8dd1049b2d3 |
comparison
equal
deleted
inserted
replaced
19:e90a4797e579 | 20:de7213b35755 |
---|---|
49 m_pFftFilteredReal = new double[m_lengthFIRFFT]; | 49 m_pFftFilteredReal = new double[m_lengthFIRFFT]; |
50 m_pFftFilteredImag = new double[m_lengthFIRFFT]; | 50 m_pFftFilteredImag = new double[m_lengthFIRFFT]; |
51 m_pFftOutputReal = new double[m_lengthFIRFFT]; | 51 m_pFftOutputReal = new double[m_lengthFIRFFT]; |
52 m_pFftOutputImag = new double[m_lengthFIRFFT]; | 52 m_pFftOutputImag = new double[m_lengthFIRFFT]; |
53 | 53 |
54 for(unsigned int i = 0; i < m_lengthFIRFFT; i++){ | 54 for(int i = 0; i < (int)m_lengthFIRFFT; i++){ |
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, OutputTypeArgument outputType) | 60 FIRFilter::process(const float* pInput, const float* pCoefficients, float* pOutput, OutputTypeArgument outputType) |
61 { | 61 { |
62 | 62 |
63 //Copy to same length FFT buffers | 63 //Copy to same length FFT buffers |
64 for(unsigned int i = 0; i < m_lengthFIRFFT; i++){ | 64 for(int i = 0; i < (int)m_lengthFIRFFT; i++){ |
65 m_pFftInput[i] = i < m_lengthInput ? pInput[i] : 0.0; | 65 m_pFftInput[i] = i < (int)m_lengthInput ? pInput[i] : 0.0; |
66 m_pFftCoefficients[i] = i < m_numberOfCoefficients ? pCoefficients[i] : 0.0; | 66 m_pFftCoefficients[i] = i < (int)m_numberOfCoefficients ? pCoefficients[i] : 0.0; |
67 } | 67 } |
68 | 68 |
69 FFT::forward(m_lengthFIRFFT, m_pFftInput, 0, m_pFftReal1, m_pFftImag1); | 69 FFT::forward(m_lengthFIRFFT, m_pFftInput, 0, m_pFftReal1, m_pFftImag1); |
70 FFT::forward(m_lengthFIRFFT, m_pFftCoefficients, 0, m_pFftReal2, m_pFftImag2); | 70 FFT::forward(m_lengthFIRFFT, m_pFftCoefficients, 0, m_pFftReal2, m_pFftImag2); |
71 | 71 |
72 //Multiply FFT coefficients. Multiplication in freq domain is convolution in time domain. | 72 //Multiply FFT coefficients. Multiplication in freq domain is convolution in time domain. |
73 for (unsigned int i = 0; i < m_lengthFIRFFT; i++){ | 73 for (int i = 0; i < (int)m_lengthFIRFFT; i++){ |
74 m_pFftFilteredReal[i] = (m_pFftReal1[i] * m_pFftReal2[i]) - (m_pFftImag1[i] * m_pFftImag2[i]); | 74 m_pFftFilteredReal[i] = (m_pFftReal1[i] * m_pFftReal2[i]) - (m_pFftImag1[i] * m_pFftImag2[i]); |
75 m_pFftFilteredImag[i] = (m_pFftReal1[i] * m_pFftImag2[i]) + (m_pFftReal2[i] * m_pFftImag1[i]); | 75 m_pFftFilteredImag[i] = (m_pFftReal1[i] * m_pFftImag2[i]) + (m_pFftReal2[i] * m_pFftImag1[i]); |
76 } | 76 } |
77 | 77 |
78 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); |
79 | 79 |
80 //copy to output | 80 //copy to output |
81 int offset = 0; | 81 int offset = 0; |
82 unsigned int outputLength = m_lengthInput; | 82 int outputLength = m_lengthInput; |
83 if (outputType == all) outputLength = m_lengthFIRFFT; | 83 if (outputType == all) outputLength = (int)m_lengthFIRFFT; |
84 else if (outputType == middle) offset = floor((float)m_numberOfCoefficients/2); | 84 else if (outputType == middle) offset = floor(m_numberOfCoefficients/2.0f); |
85 else if (outputType != first) cerr << "FIRFilter::process(params) - " << outputType << " is not a valid argument. outputType is set to first." << endl; | 85 else if (outputType != first) cerr << "FIRFilter::process(params) - " << outputType << " is not a valid argument. outputType is set to first." << endl; |
86 | 86 |
87 for (unsigned int i = 0; i < outputLength; i++){ | 87 for (int i = 0; i < outputLength; i++){ |
88 pOutput[i] = m_pFftOutputReal[i + offset]; | 88 pOutput[i] = m_pFftOutputReal[i + offset]; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 //remove memory allocations | 92 //remove memory allocations |