Mercurial > hg > nnls-chroma
comparison NNLSChroma.cpp @ 175:49cd24ef3402 matthiasm-plugin
Merge
author | Chris Cannam |
---|---|
date | Mon, 02 Nov 2015 12:35:44 +0000 |
parents | 96769283f836 |
children | 2c4ee4d8e805 |
comparison
equal
deleted
inserted
replaced
173:5190d4947ad9 | 175:49cd24ef3402 |
---|---|
436 } | 436 } |
437 | 437 |
438 float notesum = 0; | 438 float notesum = 0; |
439 | 439 |
440 consonance.values.push_back(0); | 440 consonance.values.push_back(0); |
441 for (int iSemitone = 0; iSemitone < 84-24; ++iSemitone) { | 441 |
442 notesum += f3.values[iSemitone] * f3.values[iSemitone] * treblewindow[iSemitone] * treblewindow[iSemitone]; | 442 for (int iSemitone = 0; iSemitone < 84; ++iSemitone) { |
443 float tempconsonance = 0; | 443 float tempconsonance = 0; |
444 int sumlength = 1; | |
444 for (int jSemitone = 1; jSemitone < 24; ++jSemitone) { | 445 for (int jSemitone = 1; jSemitone < 24; ++jSemitone) { |
446 if (iSemitone+jSemitone > 84-1) break; | |
447 sumlength++; | |
445 tempconsonance += f3.values[iSemitone+jSemitone] * (consonancepattern[jSemitone]) * treblewindow[iSemitone+jSemitone]; | 448 tempconsonance += f3.values[iSemitone+jSemitone] * (consonancepattern[jSemitone]) * treblewindow[iSemitone+jSemitone]; |
446 } | 449 } |
447 consonance.values[0] += (f3.values[iSemitone] * tempconsonance * treblewindow[iSemitone]); | 450 notesum += f3.values[iSemitone] * f3.values[iSemitone] * treblewindow[iSemitone] * treblewindow[iSemitone] * sumlength; |
448 } | 451 consonance.values[0] += (f3.values[iSemitone] * tempconsonance * treblewindow[iSemitone]) * sumlength; |
452 } | |
453 // cerr << consonance.values[0] << " " << f3.timestamp << " "<< notesum << endl; | |
449 if (notesum > 0) consonance.values[0] /= notesum; | 454 if (notesum > 0) consonance.values[0] /= notesum; |
455 | |
450 | 456 |
451 f4.values = chroma; | 457 f4.values = chroma; |
452 f5.values = basschroma; | 458 f5.values = basschroma; |
453 chroma.insert(chroma.begin(), basschroma.begin(), basschroma.end()); // just stack the both chromas | 459 chroma.insert(chroma.begin(), basschroma.begin(), basschroma.end()); // just stack the both chromas |
454 f6.values = chroma; | 460 f6.values = chroma; |