comparison NNLSChroma.cpp @ 119:c4d1208e5ea9 monophonicness

tidying up a bit
author Matthias Mauch <mail@matthiasmauch.net>
date Thu, 31 Mar 2011 14:59:11 +0100
parents 5f3d3ea6aab6
children 7a8956e903e1
comparison
equal deleted inserted replaced
118:4663b1f184e8 119:c4d1208e5ea9
248 float consonancemean = 0; 248 float consonancemean = 0;
249 for (int i = 0; i< nConsonance; ++i) { 249 for (int i = 0; i< nConsonance; ++i) {
250 consonancemean += consonancepattern[i]/nConsonance; 250 consonancemean += consonancepattern[i]/nConsonance;
251 } 251 }
252 252
253 // cerr << "consonancemean = " << consonancemean << endl;
254
255 for (int i = 0; i< nConsonance; ++i) { 253 for (int i = 0; i< nConsonance; ++i) {
256 consonancepattern[i] -= consonancemean; 254 consonancepattern[i] -= consonancemean;
257 } 255 }
258 if (debug_on) cerr << "--> getRemainingFeatures" << endl; 256
257 if (debug_on) cerr << "--> getRemainingFeatures" << endl;
259 FeatureSet fsOut; 258 FeatureSet fsOut;
260 if (m_logSpectrum.size() == 0) return fsOut; 259 if (m_logSpectrum.size() == 0) return fsOut;
261 // 260
262 /** Calculate Tuning 261 /** Calculate Tuning
263 calculate tuning from (using the angle of the complex number defined by the 262 calculate tuning from (using the angle of the complex number defined by the
264 cumulative mean real and imag values) 263 cumulative mean real and imag values)
265 **/ 264 **/
266 float meanTuningImag = 0; 265 float meanTuningImag = 0;
275 float floatShift = normalisedtuning * 3 - intShift; // floatShift is a really bad name for this 274 float floatShift = normalisedtuning * 3 - intShift; // floatShift is a really bad name for this
276 275
277 char buffer0 [50]; 276 char buffer0 [50];
278 277
279 sprintf(buffer0, "estimated tuning: %0.1f Hz", cumulativetuning); 278 sprintf(buffer0, "estimated tuning: %0.1f Hz", cumulativetuning);
280 279
281 // cerr << "normalisedtuning: " << normalisedtuning << '\n';
282
283 /** Tune Log-Frequency Spectrogram 280 /** Tune Log-Frequency Spectrogram
284 calculate a tuned log-frequency spectrogram (f2): use the tuning estimated above (kinda f0) to 281 calculate a tuned log-frequency spectrogram (f2): use the tuning estimated above (kinda f0) to
285 perform linear interpolation on the existing log-frequency spectrogram (kinda f1). 282 perform linear interpolation on the existing log-frequency spectrogram (kinda f1).
286 **/ 283 **/
287 cerr << endl << "[NNLS Chroma Plugin] Tuning Log-Frequency Spectrogram ... "; 284 cerr << endl << "[NNLS Chroma Plugin] Tuning Log-Frequency Spectrogram ... ";
288 285
289 float tempValue = 0; 286 float tempValue = 0;
290 float dbThreshold = 0; // relative to the background spectrum 287 float dbThreshold = 0; // relative to the background spectrum
291 float thresh = pow(10,dbThreshold/20); 288 float thresh = pow(10,dbThreshold/20);
292 // cerr << "tune local ? " << m_tuneLocal << endl;
293 int count = 0; 289 int count = 0;
294 290
295 291
296 for (FeatureList::iterator i = m_logSpectrum.begin(); i != m_logSpectrum.end(); ++i) { 292 for (FeatureList::iterator i = m_logSpectrum.begin(); i != m_logSpectrum.end(); ++i) {
297 Feature f1 = *i; 293 Feature f1 = *i;