comparison dsp/chromagram/Chromagram.cpp @ 228:b7f01ab7045e

* Give the chromagram an alternative entry point passing in frequency domain data * Centre the Hamming windows and do an fftshift when calculating sparse kernel
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 15 May 2006 15:07:27 +0000
parents 49844bc8a895
children 2e3f5d2d62c1
comparison
equal deleted inserted replaced
227:f06672e8db10 228:b7f01ab7045e
111 } 111 }
112 112
113 113
114 double* Chromagram::process( double *data ) 114 double* Chromagram::process( double *data )
115 { 115 {
116 //initialise chromadata to 0 116 // FFT of current frame
117 for (unsigned i=0; i<m_BPO; i++) 117 m_FFT->process( m_frameSize, 0, data, NULL, m_FFTRe, m_FFTIm );
118 m_chromadata[i]=0; 118
119 return process(m_FFTRe, m_FFTIm);
120 }
121
122 double* Chromagram::process( double *real, double *imag )
123 {
124 // initialise chromadata to 0
125 for (unsigned i = 0; i < m_BPO; i++) m_chromadata[i] = 0;
119 126
120 double cmax = 0.0; 127 double cmax = 0.0;
121 double cval = 0; 128 double cval = 0;
122 129
123 // FFT of current frame
124 m_FFT->process( m_frameSize, 0, data, NULL, m_FFTRe, m_FFTIm );
125
126 // Calculate ConstantQ frame 130 // Calculate ConstantQ frame
127 m_ConstantQ->process( m_FFTRe, m_FFTIm, m_CQRe, m_CQIm ); 131 m_ConstantQ->process( real, imag, m_CQRe, m_CQIm );
128 132
129 // add each octave of cq data into Chromagram 133 // add each octave of cq data into Chromagram
130 const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1; 134 const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1;
131 for (unsigned octave=0; octave<=octaves; octave++) 135 for (unsigned octave = 0; octave <= octaves; octave++)
132 { 136 {
133 unsigned firstBin = octave*m_BPO; 137 unsigned firstBin = octave*m_BPO;
134 for (unsigned i=0; i<m_BPO; i++) 138 for (unsigned i = 0; i < m_BPO; i++)
135 { 139 {
136 m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]); 140 m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]);
137 } 141 }
138 } 142 }
139 143