Mercurial > hg > vamp-tempogram
comparison Spectrogram.cpp @ 10:17a260410116
Change NULL to 0 throughout
author | Chris Cannam |
---|---|
date | Tue, 12 Aug 2014 16:20:14 +0100 |
parents | be59b4a73f49 |
children | d58409ecd720 |
comparison
equal
deleted
inserted
replaced
9:be59b4a73f49 | 10:17a260410116 |
---|---|
14 m_inputLength(inputLength), | 14 m_inputLength(inputLength), |
15 m_windowLength(windowLength), | 15 m_windowLength(windowLength), |
16 m_fftLength(fftLength), | 16 m_fftLength(fftLength), |
17 m_hopSize(hopSize), | 17 m_hopSize(hopSize), |
18 m_numberOfOutputBins(ceil(fftLength/2) + 1), | 18 m_numberOfOutputBins(ceil(fftLength/2) + 1), |
19 fftInput(NULL), | 19 fftInput(0), |
20 fftOutputReal(NULL), | 20 fftOutputReal(0), |
21 fftOutputImag(NULL) | 21 fftOutputImag(0) |
22 { | 22 { |
23 initialise(); | 23 initialise(); |
24 } | 24 } |
25 | 25 |
26 Spectrogram::~Spectrogram(){ | 26 Spectrogram::~Spectrogram(){ |
39 void Spectrogram::cleanup(){ | 39 void Spectrogram::cleanup(){ |
40 delete []fftInput; | 40 delete []fftInput; |
41 delete []fftOutputReal; | 41 delete []fftOutputReal; |
42 delete []fftOutputImag; | 42 delete []fftOutputImag; |
43 | 43 |
44 fftInput = fftOutputReal = fftOutputImag = NULL; | 44 fftInput = fftOutputReal = fftOutputImag = 0; |
45 } | 45 } |
46 | 46 |
47 //process method | 47 //process method |
48 vector< vector<float> > Spectrogram::audioToMagnitudeSpectrogram(const float * const input, const float * window){ | 48 vector< vector<float> > Spectrogram::audioToMagnitudeSpectrogram(const float * const input, const float * window){ |
49 | 49 |
64 } | 64 } |
65 for (int n = m_windowLength; n < m_fftLength; n++){ | 65 for (int n = m_windowLength; n < m_fftLength; n++){ |
66 fftInput[n] = 0.0; | 66 fftInput[n] = 0.0; |
67 } | 67 } |
68 | 68 |
69 FFT::forward(m_fftLength, fftInput, NULL, fftOutputReal, fftOutputImag); | 69 FFT::forward(m_fftLength, fftInput, 0, fftOutputReal, fftOutputImag); |
70 | 70 |
71 //@todo: sample at logarithmic spacing? Leave for host? | 71 //@todo: sample at logarithmic spacing? Leave for host? |
72 for(int k = 0; k < m_numberOfOutputBins; k++){ | 72 for(int k = 0; k < m_numberOfOutputBins; k++){ |
73 spectrogramOutput[k][writeBlockPointer] = (fftOutputReal[k]*fftOutputReal[k] + fftOutputImag[k]*fftOutputImag[k]); //Magnitude or power? | 73 spectrogramOutput[k][writeBlockPointer] = (fftOutputReal[k]*fftOutputReal[k] + fftOutputImag[k]*fftOutputImag[k]); //Magnitude or power? |
74 } | 74 } |