comparison examples/PercussionOnsetDetector.cpp @ 270:06cfedd040c7

...
author cannam
date Wed, 26 Nov 2008 13:54:17 +0000
parents 6b30e064cab7
children
comparison
equal deleted inserted replaced
269:91821a3ab0b6 270:06cfedd040c7
243 float sqrmag = real * real + imag * imag; 243 float sqrmag = real * real + imag * imag;
244 244
245 if (m_priorMagnitudes[i] > 0.f) { 245 if (m_priorMagnitudes[i] > 0.f) {
246 float diff = 10.f * log10f(sqrmag / m_priorMagnitudes[i]); 246 float diff = 10.f * log10f(sqrmag / m_priorMagnitudes[i]);
247 247
248 // std::cout << "i=" << i << ", mag=" << mag << ", prior=" << m_priorMagnitudes[i] << ", diff=" << diff << ", threshold=" << m_threshold << std::endl; 248 // std::cout << "i=" << i << ", sqrmag=" << sqrmag << ", prior=" << m_priorMagnitudes[i] << ", diff=" << diff << ", threshold=" << m_threshold << " " << (diff >= m_threshold ? "[*]" : "") << std::endl;
249 249
250 if (diff >= m_threshold) ++count; 250 if (diff >= m_threshold) ++count;
251 } 251 }
252 252
253 m_priorMagnitudes[i] = sqrmag; 253 m_priorMagnitudes[i] = sqrmag;
261 returnFeatures[1].push_back(detectionFunction); 261 returnFeatures[1].push_back(detectionFunction);
262 262
263 if (m_dfMinus2 < m_dfMinus1 && 263 if (m_dfMinus2 < m_dfMinus1 &&
264 m_dfMinus1 >= count && 264 m_dfMinus1 >= count &&
265 m_dfMinus1 > ((100 - m_sensitivity) * m_blockSize) / 200) { 265 m_dfMinus1 > ((100 - m_sensitivity) * m_blockSize) / 200) {
266
267 //std::cout << "result at " << ts << "! (count == " << count << ", prev == " << m_dfMinus1 << ")" << std::endl;
266 268
267 Feature onset; 269 Feature onset;
268 onset.hasTimestamp = true; 270 onset.hasTimestamp = true;
269 onset.timestamp = ts - Vamp::RealTime::frame2RealTime 271 onset.timestamp = ts - Vamp::RealTime::frame2RealTime
270 (m_stepSize, int(m_inputSampleRate + 0.5)); 272 (m_stepSize, int(m_inputSampleRate + 0.5));