Mercurial > hg > nnls-chroma
changeset 44:109d3b2c7105 matthiasm-plugin
regarding the chord estimation:\n * tweaked chord templates\n * that means that the original method also changed
author | matthiasm |
---|---|
date | Mon, 25 Oct 2010 01:58:37 +0900 |
parents | 131801714118 |
children | 976833b7a463 |
files | Chordino.cpp chord.dict chromamethods.cpp viterbi.cpp viterbi.o |
diffstat | 5 files changed, 43 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/Chordino.cpp Mon Oct 25 00:52:39 2010 +0900 +++ b/Chordino.cpp Mon Oct 25 01:58:37 2010 +0900 @@ -362,11 +362,12 @@ for (int iChord = 0; iChord < nChord; iChord++) { tempchordvalue = 0; for (int iBin = 0; iBin < 12; iBin++) { - tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; + tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; } for (int iBin = 12; iBin < 24; iBin++) { tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; } + if (tempchordvalue < 0) tempchordvalue = 0; sumchordvalue+=tempchordvalue; currentChordSalience.push_back(tempchordvalue); } @@ -386,9 +387,9 @@ bool m_useHMM = true; // this will go into the chordino header file. if (m_useHMM) { - + cerr << "[Chordino Plugin] HMM Chord Estimation ... "; int oldchord = nChord-1; - double selftransprob = 0.1; + double selftransprob = 0.9; vector<double> init = vector<double>(nChord,1.0/nChord); vector<vector<double> > trans; @@ -417,7 +418,7 @@ I just take the local chord estimates ("currentChordSalience") and average them over time, then take the maximum. Very simple, don't do this at home... */ - cerr << "[NNLS Chroma Plugin] Chord Estimation ... "; + cerr << "[Chordino Plugin] Simple Chord Estimation ... "; count = 0; int halfwindowlength = m_inputSampleRate / m_stepSize; vector<int> chordSequence;
--- a/chord.dict Mon Oct 25 00:52:39 2010 +0900 +++ b/chord.dict Mon Oct 25 01:58:37 2010 +0900 @@ -21,8 +21,8 @@ dim=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0 aug=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 =0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0 -=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 -# 7sus4=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0 +=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 +7=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,1,0 ### Rock'n'Roll # :1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
--- a/chromamethods.cpp Mon Oct 25 00:52:39 2010 +0900 +++ b/chromamethods.cpp Mon Oct 25 01:58:37 2010 +0900 @@ -365,18 +365,37 @@ for (unsigned kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(1.0); // normalise - float sum = 0; - for (int i = 0; i < loadedChordDict.size(); i++) { - sum += pow(loadedChordDict[i],2); - if (i % 24 == 23) { - float invertedsum = 1.0/sqrt(sum); - for (int k = 0; k < 24; k++) { - loadedChordDict[i-k] *= invertedsum; - } - sum = 0; + // float sum = 0; + // for (int i = 0; i < loadedChordDict.size(); i++) { + // sum += pow(loadedChordDict[i],2); + // if (i % 24 == 23) { + // float invertedsum = 1.0/sqrt(sum); + // for (int k = 0; k < 24; k++) { + // loadedChordDict[i-k] *= invertedsum; + // } + // sum = 0; + // } + // + // } + + + for (int iChord = 0; iChord < loadedChordDict.size()/24; iChord++) { + float sum = 0; + float stand = 0; + for (int iST = 0; iST < 24; ++iST) { + sum += loadedChordDict[24 * iChord + iST]; } - + for (int iST = 0; iST < 24; ++iST) { + loadedChordDict[24 * iChord + iST] -= sum/24; + stand += pow(loadedChordDict[24 * iChord + iST],2)/24; + } + stand = sqrt(stand); + for (int iST = 0; iST < 24; ++iST) { + loadedChordDict[24 * iChord + iST] /= stand; + } + } + nChord = 0;
--- a/viterbi.cpp Mon Oct 25 00:52:39 2010 +0900 +++ b/viterbi.cpp Mon Oct 25 01:58:37 2010 +0900 @@ -39,11 +39,13 @@ for (int jState = 0; jState < nState; ++jState) { int bestState = nState - 1; double bestValue = 0; - for (int iState = 0; iState < nState; ++iState) { - double currentValue = delta[iFrame-1][iState] * trans[iState][jState]; - if (currentValue > bestValue) { - bestValue = currentValue; - bestState = iState; + if (obs[iFrame][jState] > 0) { + for (int iState = 0; iState < nState; ++iState) { + double currentValue = delta[iFrame-1][iState] * trans[iState][jState]; + if (currentValue > bestValue) { + bestValue = currentValue; + bestState = iState; + } } } // cerr << bestState <<" ::: " << bestValue << endl ;