Mercurial > hg > nnls-chroma
diff NNLSChroma.cpp @ 104:96769283f836 matthiasm-plugin
debugging consonance (framewise normalisation)
author | matthiasm |
---|---|
date | Sat, 18 Dec 2010 20:07:46 +0900 |
parents | d1398182a072 |
children | 2c4ee4d8e805 |
line wrap: on
line diff
--- a/NNLSChroma.cpp Tue Dec 07 21:27:36 2010 +0900 +++ b/NNLSChroma.cpp Sat Dec 18 20:07:46 2010 +0900 @@ -438,15 +438,21 @@ float notesum = 0; consonance.values.push_back(0); - for (int iSemitone = 0; iSemitone < 84-24; ++iSemitone) { - notesum += f3.values[iSemitone] * f3.values[iSemitone] * treblewindow[iSemitone] * treblewindow[iSemitone]; - float tempconsonance = 0; + + for (int iSemitone = 0; iSemitone < 84; ++iSemitone) { + float tempconsonance = 0; + int sumlength = 1; for (int jSemitone = 1; jSemitone < 24; ++jSemitone) { + if (iSemitone+jSemitone > 84-1) break; + sumlength++; tempconsonance += f3.values[iSemitone+jSemitone] * (consonancepattern[jSemitone]) * treblewindow[iSemitone+jSemitone]; } - consonance.values[0] += (f3.values[iSemitone] * tempconsonance * treblewindow[iSemitone]); + notesum += f3.values[iSemitone] * f3.values[iSemitone] * treblewindow[iSemitone] * treblewindow[iSemitone] * sumlength; + consonance.values[0] += (f3.values[iSemitone] * tempconsonance * treblewindow[iSemitone]) * sumlength; } + // cerr << consonance.values[0] << " " << f3.timestamp << " "<< notesum << endl; if (notesum > 0) consonance.values[0] /= notesum; + f4.values = chroma; f5.values = basschroma;