Mercurial > hg > beatroot-vamp
comparison AgentList.cpp @ 22:6afcb5edd7ab
Fix compiler warnings, etc
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2013 16:50:40 +0100 |
parents | 33d0b18b2509 |
children | 633ec097fa56 |
comparison
equal
deleted
inserted
replaced
21:d98bc465a116 | 22:6afcb5edd7ab |
---|---|
21 | 21 |
22 void AgentList::removeDuplicates() | 22 void AgentList::removeDuplicates() |
23 { | 23 { |
24 sort(); | 24 sort(); |
25 for (iterator itr = begin(); itr != end(); ++itr) { | 25 for (iterator itr = begin(); itr != end(); ++itr) { |
26 #ifdef DEBUG_BEATROOT | |
27 std::cerr << "removeDuplicates: considering agent " << (*itr)->idNumber << std::endl; | |
28 #endif | |
26 if ((*itr)->phaseScore < 0.0) // already flagged for deletion | 29 if ((*itr)->phaseScore < 0.0) // already flagged for deletion |
27 continue; | 30 continue; |
28 iterator itr2 = itr; | 31 iterator itr2 = itr; |
29 for (++itr2; itr2 != end(); ++itr2) { | 32 for (++itr2; itr2 != end(); ++itr2) { |
30 if ((*itr2)->beatInterval - (*itr)->beatInterval > DEFAULT_BI) | 33 if ((*itr2)->beatInterval - (*itr)->beatInterval > DEFAULT_BI) |
31 break; | 34 break; |
32 if (fabs((*itr)->beatTime - (*itr2)->beatTime) > DEFAULT_BT) | 35 if (fabs((*itr)->beatTime - (*itr2)->beatTime) > DEFAULT_BT) |
33 continue; | 36 continue; |
34 if ((*itr)->phaseScore < (*itr2)->phaseScore) { | 37 if ((*itr)->phaseScore < (*itr2)->phaseScore) { |
38 #ifdef DEBUG_BEATROOT | |
39 std::cerr << "agent " << (*itr)->idNumber << " is similar to but lower-scoring than agent " << (*itr2)->idNumber << ", marking for deletion" << std::endl; | |
40 #endif | |
35 (*itr)->phaseScore = -1.0; // flag for deletion | 41 (*itr)->phaseScore = -1.0; // flag for deletion |
36 if ((*itr2)->topScoreTime < (*itr)->topScoreTime) | 42 if ((*itr2)->topScoreTime < (*itr)->topScoreTime) |
37 (*itr2)->topScoreTime = (*itr)->topScoreTime; | 43 (*itr2)->topScoreTime = (*itr)->topScoreTime; |
38 break; | 44 break; |
39 } else { | 45 } else { |
46 #ifdef DEBUG_BEATROOT | |
47 std::cerr << "agent " << (*itr2)->idNumber << " is similar to but lower-scoring than agent " << (*itr)->idNumber << ", marking for deletion" << std::endl; | |
48 #endif | |
40 (*itr2)->phaseScore = -1.0; // flag for deletion | 49 (*itr2)->phaseScore = -1.0; // flag for deletion |
41 if ((*itr)->topScoreTime < (*itr2)->topScoreTime) | 50 if ((*itr)->topScoreTime < (*itr2)->topScoreTime) |
42 (*itr)->topScoreTime = (*itr2)->topScoreTime; | 51 (*itr)->topScoreTime = (*itr2)->topScoreTime; |
43 } | 52 } |
44 } | 53 } |
113 { | 122 { |
114 double best = -1.0; | 123 double best = -1.0; |
115 Agent *bestAg = 0; | 124 Agent *bestAg = 0; |
116 for (iterator itr = begin(); itr != end(); ++itr) { | 125 for (iterator itr = begin(); itr != end(); ++itr) { |
117 if ((*itr)->events.empty()) continue; | 126 if ((*itr)->events.empty()) continue; |
118 double startTime = (*itr)->events.begin()->time; | |
119 double conf = ((*itr)->phaseScore + (*itr)->tempoScore) / | 127 double conf = ((*itr)->phaseScore + (*itr)->tempoScore) / |
120 (useAverageSalience? (double)(*itr)->beatCount: 1.0); | 128 (useAverageSalience? (double)(*itr)->beatCount: 1.0); |
121 if (conf > best) { | 129 if (conf > best) { |
122 bestAg = *itr; | 130 bestAg = *itr; |
123 best = conf; | 131 best = conf; |