comparison src/MatchPipeline.cpp @ 237:2f3ecf5d2651 subsequence

Actually implement the subsequence match plugin
author Chris Cannam
date Fri, 03 Jul 2020 17:32:38 +0100
parents 39fe8728e1ca
children
comparison
equal deleted inserted replaced
236:39fe8728e1ca 237:2f3ecf5d2651
90 } 90 }
91 #endif 91 #endif
92 92
93 m_feeder.feed(c1, c2); 93 m_feeder.feed(c1, c2);
94 94
95 if (aboveThreshold(c1)) m_lastFrameIn1 = m_frameNo; 95 if (isAboveEndingThreshold(c1)) m_lastFrameIn1 = m_frameNo;
96 if (aboveThreshold(c2)) m_lastFrameIn2 = m_frameNo; 96 if (isAboveEndingThreshold(c2)) m_lastFrameIn2 = m_frameNo;
97 97
98 #ifdef DEBUG_MATCH_PIPELINE 98 #ifdef DEBUG_MATCH_PIPELINE
99 cerr << "last frames are " << m_lastFrameIn1 << ", " << m_lastFrameIn2 99 cerr << "last frames are " << m_lastFrameIn1 << ", " << m_lastFrameIn2
100 << endl; 100 << endl;
101 #endif 101 #endif
116 c1 = m_c1; 116 c1 = m_c1;
117 c2 = m_c2; 117 c2 = m_c2;
118 } 118 }
119 119
120 bool 120 bool
121 MatchPipeline::aboveThreshold(const feature_t &f) 121 MatchPipeline::isAboveEndingThreshold(const feature_t &f)
122 { 122 {
123 // This threshold is used only to determine when either of the
124 // input streams has ended -- the last frame for a stream is
125 // considered to be the last one that was above the
126 // threshold. This is different from the silence threshold in
127 // FeatureConditioner.
128 double threshold = 1e-4f; 123 double threshold = 1e-4f;
129 double sum = 0.f; 124 double sum = 0.f;
130 for (int i = 0; i < int(f.size()); ++i) { 125 for (int i = 0; i < int(f.size()); ++i) {
131 sum += f[i] * f[i]; 126 sum += f[i] * f[i];
132 } 127 }
133 #ifdef DEBUG_MATCH_PIPELINE 128 #ifdef DEBUG_MATCH_PIPELINE
134 cerr << "aboveThreshold: sum " << sum << ", threshold " << threshold 129 cerr << "isAboveEndingThreshold: sum " << sum
130 << ", threshold " << threshold
135 << ", returning " << (sum >= threshold) << endl; 131 << ", returning " << (sum >= threshold) << endl;
136 #endif 132 #endif
137 return (sum >= threshold); 133 return (sum >= threshold);
138 } 134 }
139 135