Mercurial > hg > nnls-chroma
comparison chromamethods.cpp @ 135:75a46075bf4e darwintunes
Initialise logFreqMatrix elements to zero before loop to ensure none gets missed
author | Chris Cannam |
---|---|
date | Thu, 10 May 2012 11:32:05 +0100 |
parents | b115fa66c695 |
children | 02ab98e51436 |
comparison
equal
deleted
inserted
replaced
134:57bf719bce30 | 135:75a46075bf4e |
---|---|
141 for (int iOS = 0; iOS < 2 * oversampling; ++iOS) { | 141 for (int iOS = 0; iOS < 2 * oversampling; ++iOS) { |
142 float cosp = cospuls(oversampled_f[iOS],fft_f[1],fft_width); | 142 float cosp = cospuls(oversampled_f[iOS],fft_f[1],fft_width); |
143 fft_activation.push_back(cosp); | 143 fft_activation.push_back(cosp); |
144 // cerr << cosp << endl; | 144 // cerr << cosp << endl; |
145 } | 145 } |
146 | |
147 for (int i = 0; i < nFFT * cq_f.size(); ++i) { | |
148 outmatrix[i] = 0.f; | |
149 } | |
146 | 150 |
147 float cq_activation; | 151 float cq_activation; |
148 for (int iFFT = 1; iFFT < nFFT; ++iFFT) { | 152 for (int iFFT = 1; iFFT < nFFT; ++iFFT) { |
149 // find frequency stretch where the oversampled vector can be non-zero (i.e. in a window of width fft_width around the current frequency) | 153 // find frequency stretch where the oversampled vector can be non-zero (i.e. in a window of width fft_width around the current frequency) |
150 int curr_start = oversampling * iFFT - oversampling; | 154 int curr_start = oversampling * iFFT - oversampling; |
151 int curr_end = oversampling * iFFT + oversampling; // don't know if I should add "+1" here | 155 int curr_end = oversampling * iFFT + oversampling; // don't know if I should add "+1" here |
152 // cerr << oversampled_f[curr_start] << " " << fft_f[iFFT] << " " << oversampled_f[curr_end] << endl; | 156 // cerr << oversampled_f[curr_start] << " " << fft_f[iFFT] << " " << oversampled_f[curr_end] << endl; |
153 for (int iCQ = 0; iCQ < (int)cq_f.size(); ++iCQ) { | 157 for (int iCQ = 0; iCQ < (int)cq_f.size(); ++iCQ) { |
154 outmatrix[iFFT + nFFT * iCQ] = 0; | |
155 if (cq_f[iCQ] * pow(2.0, 0.084) + fft_width > fft_f[iFFT] && cq_f[iCQ] * pow(2.0, -0.084 * 2) - fft_width < fft_f[iFFT]) { // within a generous neighbourhood | 158 if (cq_f[iCQ] * pow(2.0, 0.084) + fft_width > fft_f[iFFT] && cq_f[iCQ] * pow(2.0, -0.084 * 2) - fft_width < fft_f[iFFT]) { // within a generous neighbourhood |
156 for (int iOS = curr_start; iOS < curr_end; ++iOS) { | 159 for (int iOS = curr_start; iOS < curr_end; ++iOS) { |
157 cq_activation = pitchCospuls(oversampled_f[iOS],cq_f[iCQ],binspersemitone*12); | 160 cq_activation = pitchCospuls(oversampled_f[iOS],cq_f[iCQ],binspersemitone*12); |
158 // cerr << oversampled_f[iOS] << " " << cq_f[iCQ] << " " << cq_activation << endl; | 161 // cerr << oversampled_f[iOS] << " " << cq_f[iCQ] << " " << cq_activation << endl; |
159 outmatrix[iFFT + nFFT * iCQ] += cq_activation * fft_activation[iOS-curr_start]; | 162 outmatrix[iFFT + nFFT * iCQ] += cq_activation * fft_activation[iOS-curr_start]; |