# HG changeset patch # User matthiasm # Date 1287939517 -32400 # Node ID 109d3b2c7105bb1c1db98ab25fcb714b6edfc002 # Parent 1318017141185ec37caccf1ae2d308ac11173034 regarding the chord estimation:\n * tweaked chord templates\n * that means that the original method also changed diff -r 131801714118 -r 109d3b2c7105 Chordino.cpp --- 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 init = vector(nChord,1.0/nChord); vector > 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 chordSequence; diff -r 131801714118 -r 109d3b2c7105 chord.dict --- 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 diff -r 131801714118 -r 109d3b2c7105 chromamethods.cpp --- 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; diff -r 131801714118 -r 109d3b2c7105 viterbi.cpp --- 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 ; diff -r 131801714118 -r 109d3b2c7105 viterbi.o Binary file viterbi.o has changed