Mercurial > hg > nnls-chroma
comparison Chordino.cpp @ 48:6e76c7710fa1 matthiasm-plugin
removed subtraction in chroma dictionary, added to-the-power-of-1.5 in chordino
author | matthiasm |
---|---|
date | Mon, 25 Oct 2010 16:58:32 +0900 |
parents | 109d3b2c7105 |
children | b6cddb109482 |
comparison
equal
deleted
inserted
replaced
47:ea35e6e804f1 | 48:6e76c7710fa1 |
---|---|
365 tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; | 365 tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; |
366 } | 366 } |
367 for (int iBin = 12; iBin < 24; iBin++) { | 367 for (int iBin = 12; iBin < 24; iBin++) { |
368 tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; | 368 tempchordvalue += m_chorddict[24 * iChord + iBin] * chroma[iBin]; |
369 } | 369 } |
370 if (tempchordvalue < 0) tempchordvalue = 0; | 370 if (iChord == nChord-1) tempchordvalue *= .7; |
371 if (tempchordvalue < 0) tempchordvalue = 0.0; | |
372 tempchordvalue = pow(1.5,tempchordvalue); | |
371 sumchordvalue+=tempchordvalue; | 373 sumchordvalue+=tempchordvalue; |
372 currentChordSalience.push_back(tempchordvalue); | 374 currentChordSalience.push_back(tempchordvalue); |
373 } | 375 } |
374 if (sumchordvalue > 0) { | 376 if (sumchordvalue > 0) { |
375 for (int iChord = 0; iChord < nChord; iChord++) { | 377 for (int iChord = 0; iChord < nChord; iChord++) { |
387 | 389 |
388 bool m_useHMM = true; // this will go into the chordino header file. | 390 bool m_useHMM = true; // this will go into the chordino header file. |
389 if (m_useHMM) { | 391 if (m_useHMM) { |
390 cerr << "[Chordino Plugin] HMM Chord Estimation ... "; | 392 cerr << "[Chordino Plugin] HMM Chord Estimation ... "; |
391 int oldchord = nChord-1; | 393 int oldchord = nChord-1; |
392 double selftransprob = 0.9; | 394 double selftransprob = 0.99; |
393 | 395 |
394 vector<double> init = vector<double>(nChord,1.0/nChord); | 396 // vector<double> init = vector<double>(nChord,1.0/nChord); |
397 vector<double> init = vector<double>(nChord,0); init[nChord-1] = 1; | |
398 | |
395 vector<vector<double> > trans; | 399 vector<vector<double> > trans; |
396 for (int iChord = 0; iChord < nChord; iChord++) { | 400 for (int iChord = 0; iChord < nChord; iChord++) { |
397 vector<double> temp = vector<double>(nChord,(1-selftransprob)/(nChord-1)); | 401 vector<double> temp = vector<double>(nChord,(1-selftransprob)/(nChord-1)); |
398 temp[iChord] = selftransprob; | 402 temp[iChord] = selftransprob; |
399 trans.push_back(temp); | 403 trans.push_back(temp); |
400 } | 404 } |
401 vector<int> chordpath = ViterbiPath(init,trans,chordogram); | 405 vector<int> chordpath = ViterbiPath(init,trans,chordogram); |
406 | |
407 | |
408 Feature chord_feature; // chord estimate | |
409 chord_feature.hasTimestamp = true; | |
410 chord_feature.timestamp = timestamps[0]; | |
411 chord_feature.label = m_chordnames[chordpath[0]]; | |
412 fsOut[0].push_back(chord_feature); | |
402 | 413 |
403 for (int iFrame = 0; iFrame < chordpath.size(); ++iFrame) { | 414 for (int iFrame = 0; iFrame < chordpath.size(); ++iFrame) { |
404 // cerr << chordpath[iFrame] << endl; | 415 // cerr << chordpath[iFrame] << endl; |
405 if (chordpath[iFrame] != oldchord) { | 416 if (chordpath[iFrame] != oldchord ) { |
406 Feature chord_feature; // chord estimate | 417 Feature chord_feature; // chord estimate |
407 chord_feature.hasTimestamp = true; | 418 chord_feature.hasTimestamp = true; |
408 chord_feature.timestamp = timestamps[iFrame]; | 419 chord_feature.timestamp = timestamps[iFrame]; |
409 chord_feature.label = m_chordnames[chordpath[iFrame]]; | 420 chord_feature.label = m_chordnames[chordpath[iFrame]]; |
410 fsOut[0].push_back(chord_feature); | 421 fsOut[0].push_back(chord_feature); |