Mercurial > hg > vamp-tempogram
comparison FIRFilter.cpp @ 10:17a260410116
Change NULL to 0 throughout
author | Chris Cannam |
---|---|
date | Tue, 12 Aug 2014 16:20:14 +0100 |
parents | be59b4a73f49 |
children | 7680cc4c0073 |
comparison
equal
deleted
inserted
replaced
9:be59b4a73f49 | 10:17a260410116 |
---|---|
12 using Vamp::FFT; | 12 using Vamp::FFT; |
13 | 13 |
14 FIRFilter::FIRFilter(const unsigned int lengthInput, const unsigned int numberOfCoefficients) : | 14 FIRFilter::FIRFilter(const unsigned int lengthInput, const unsigned int numberOfCoefficients) : |
15 m_lengthInput(lengthInput), | 15 m_lengthInput(lengthInput), |
16 m_numberOfCoefficients(numberOfCoefficients), | 16 m_numberOfCoefficients(numberOfCoefficients), |
17 fftInput(NULL), | 17 fftInput(0), |
18 fftCoefficients(NULL), | 18 fftCoefficients(0), |
19 fftReal1(NULL), | 19 fftReal1(0), |
20 fftImag1(NULL), | 20 fftImag1(0), |
21 fftReal2(NULL), | 21 fftReal2(0), |
22 fftImag2(NULL), | 22 fftImag2(0), |
23 fftFilteredReal(NULL), | 23 fftFilteredReal(0), |
24 fftFilteredImag(NULL), | 24 fftFilteredImag(0), |
25 fftOutputReal(NULL), | 25 fftOutputReal(0), |
26 fftOutputImag(NULL) | 26 fftOutputImag(0) |
27 { | 27 { |
28 initialise(); | 28 initialise(); |
29 } | 29 } |
30 | 30 |
31 FIRFilter::~FIRFilter() | 31 FIRFilter::~FIRFilter() |
63 for(int i = 0; i < m_lengthFIRFFT; i++){ | 63 for(int i = 0; i < m_lengthFIRFFT; i++){ |
64 fftInput[i] = i < m_lengthInput ? input[i] : 0.0; | 64 fftInput[i] = i < m_lengthInput ? input[i] : 0.0; |
65 fftCoefficients[i] = i < m_numberOfCoefficients ? coefficients[i] : 0.0; | 65 fftCoefficients[i] = i < m_numberOfCoefficients ? coefficients[i] : 0.0; |
66 } | 66 } |
67 | 67 |
68 FFT::forward(m_lengthFIRFFT, fftInput, NULL, fftReal1, fftImag1); | 68 FFT::forward(m_lengthFIRFFT, fftInput, 0, fftReal1, fftImag1); |
69 FFT::forward(m_lengthFIRFFT, fftCoefficients, NULL, fftReal2, fftImag2); | 69 FFT::forward(m_lengthFIRFFT, fftCoefficients, 0, fftReal2, fftImag2); |
70 | 70 |
71 //Multiply FFT coefficients. Multiplication in freq domain is convolution in time domain. | 71 //Multiply FFT coefficients. Multiplication in freq domain is convolution in time domain. |
72 for (int i = 0; i < m_lengthFIRFFT; i++){ | 72 for (int i = 0; i < m_lengthFIRFFT; i++){ |
73 fftFilteredReal[i] = (fftReal1[i] * fftReal2[i]) - (fftImag1[i] * fftImag2[i]); | 73 fftFilteredReal[i] = (fftReal1[i] * fftReal2[i]) - (fftImag1[i] * fftImag2[i]); |
74 fftFilteredImag[i] = (fftReal1[i] * fftImag2[i]) + (fftReal2[i] * fftImag1[i]); | 74 fftFilteredImag[i] = (fftReal1[i] * fftImag2[i]) + (fftReal2[i] * fftImag1[i]); |
93 delete []fftImag2; | 93 delete []fftImag2; |
94 delete []fftFilteredReal; | 94 delete []fftFilteredReal; |
95 delete []fftFilteredImag; | 95 delete []fftFilteredImag; |
96 delete []fftOutputReal; | 96 delete []fftOutputReal; |
97 delete []fftOutputImag; | 97 delete []fftOutputImag; |
98 fftInput = fftCoefficients = fftReal1 = fftImag1 = fftReal2 = fftImag2 = fftFilteredReal = fftFilteredImag = fftOutputReal = fftOutputImag = NULL; | 98 fftInput = fftCoefficients = fftReal1 = fftImag1 = fftReal2 = fftImag2 = fftFilteredReal = fftFilteredImag = fftOutputReal = fftOutputImag = 0; |
99 } | 99 } |