comparison MonoNoteHMM.cpp @ 133:83978b93aac1 fixedlag

ah, didn't commit when I stopped working... what did I do?
author Matthias Mauch <mail@matthiasmauch.net>
date Mon, 13 Jul 2015 12:10:06 +0100
parents 926c292fa3ff
children 0432723faf03
comparison
equal deleted inserted replaced
132:926c292fa3ff 133:83978b93aac1
35 35
36 size_t nCandidate = pitchProb.size(); 36 size_t nCandidate = pitchProb.size();
37 37
38 // what is the probability of pitched 38 // what is the probability of pitched
39 double pIsPitched = 0; 39 double pIsPitched = 0;
40 for (size_t iCandidate = 0; iCandidate < nCandidate; ++iCandidate) 40 for (size_t iCand = 0; iCand < nCandidate; ++iCand)
41 { 41 {
42 // pIsPitched = pitchProb[iCandidate].second > pIsPitched ? pitchProb[iCandidate].second : pIsPitched; 42 pIsPitched += pitchProb[iCand].second;
43 pIsPitched += pitchProb[iCandidate].second; 43 }
44 } 44
45 45 pIsPitched = pIsPitched * (1-par.priorWeight) +
46 // pIsPitched = std::pow(pIsPitched, (1-par.priorWeight)) * std::pow(par.priorPitchedProb, par.priorWeight); 46 par.priorPitchedProb * par.priorWeight;
47 pIsPitched = pIsPitched * (1-par.priorWeight) + par.priorPitchedProb * par.priorWeight;
48 47
49 vector<double> out = vector<double>(par.n); 48 vector<double> out = vector<double>(par.n);
50 double tempProbSum = 0; 49 double tempProbSum = 0;
51 for (size_t i = 0; i < par.n; ++i) 50 for (size_t i = 0; i < par.n; ++i)
52 { 51 {
57 if (nCandidate > 0) 56 if (nCandidate > 0)
58 { 57 {
59 double minDist = 10000.0; 58 double minDist = 10000.0;
60 double minDistProb = 0; 59 double minDistProb = 0;
61 size_t minDistCandidate = 0; 60 size_t minDistCandidate = 0;
62 for (size_t iCandidate = 0; iCandidate < nCandidate; ++iCandidate) 61 for (size_t iCand = 0; iCand < nCandidate; ++iCand)
63 { 62 {
64 double currDist = std::abs(getMidiPitch(i)-pitchProb[iCandidate].first); 63 double currDist = std::abs(getMidiPitch(i)-
64 pitchProb[iCand].first);
65 if (currDist < minDist) 65 if (currDist < minDist)
66 { 66 {
67 minDist = currDist; 67 minDist = currDist;
68 minDistProb = pitchProb[iCandidate].second; 68 minDistProb = pitchProb[iCand].second;
69 minDistCandidate = iCandidate; 69 minDistCandidate = iCand;
70 } 70 }
71 } 71 }
72 tempProb = std::pow(minDistProb, par.yinTrust) * 72 tempProb = std::pow(minDistProb, par.yinTrust) *
73 boost::math::pdf(pitchDistr[i], 73 boost::math::pdf(pitchDistr[i],
74 pitchProb[minDistCandidate].first); 74 pitchProb[minDistCandidate].first);
172 int fromPitch = iPitch; 172 int fromPitch = iPitch;
173 int toPitch = jPitch; 173 int toPitch = jPitch;
174 double semitoneDistance = 174 double semitoneDistance =
175 std::abs(fromPitch - toPitch) * 1.0 / par.nPPS; 175 std::abs(fromPitch - toPitch) * 1.0 / par.nPPS;
176 176
177 // if (std::fmod(semitoneDistance, 1) == 0 && semitoneDistance > par.minSemitoneDistance) 177
178 if (semitoneDistance == 0 || 178 if (semitoneDistance == 0 ||
179 (semitoneDistance > par.minSemitoneDistance 179 (semitoneDistance > par.minSemitoneDistance
180 && semitoneDistance < par.maxJump)) 180 && semitoneDistance < par.maxJump))
181 { 181 {
182 size_t toIndex = jPitch * par.nSPP; // note attack index 182 size_t toIndex = jPitch * par.nSPP; // note attack index
191 m_to.push_back(toIndex); 191 m_to.push_back(toIndex);
192 } 192 }
193 } 193 }
194 for (size_t i = 0; i < tempTransProbSilent.size(); ++i) 194 for (size_t i = 0; i < tempTransProbSilent.size(); ++i)
195 { 195 {
196 m_transProb.push_back((1-par.pSilentSelftrans) * tempTransProbSilent[i]/probSumSilent); 196 m_transProb.push_back((1-par.pSilentSelftrans) *
197 tempTransProbSilent[i]/probSumSilent);
197 } 198 }
198 } 199 }
199 m_nTrans = m_transProb.size(); 200 m_nTrans = m_transProb.size();
200 m_delta = vector<double>(m_nState); 201 m_delta = vector<double>(m_nState);
201 m_oldDelta = vector<double>(m_nState); 202 m_oldDelta = vector<double>(m_nState);