comparison examples/FixedTempoEstimator.cpp @ 271:23352e424631

* minor adjustments, avoid a stupid memory leak
author cannam
date Wed, 26 Nov 2008 22:36:47 +0000
parents 88ef5ffdbe8d
children c97e70ed5abc
comparison
equal deleted inserted replaced
270:06cfedd040c7 271:23352e424631
246 246
247 return list; 247 return list;
248 } 248 }
249 249
250 bool 250 bool
251 FixedTempoEstimator::D::initialise(size_t channels, 251 FixedTempoEstimator::D::initialise(size_t, size_t stepSize, size_t blockSize)
252 size_t stepSize, size_t blockSize)
253 { 252 {
254 m_stepSize = stepSize; 253 m_stepSize = stepSize;
255 m_blockSize = blockSize; 254 m_blockSize = blockSize;
256 255
257 float dfLengthSecs = m_maxdflen; 256 float dfLengthSecs = m_maxdflen;
404 403
405 // Calculate the raw autocorrelation of the detection function 404 // Calculate the raw autocorrelation of the detection function
406 405
407 for (int i = 0; i < n/2; ++i) { 406 for (int i = 0; i < n/2; ++i) {
408 407
409 for (int j = i; j < n-1; ++j) { 408 for (int j = i; j < n; ++j) {
410 m_r[i] += m_df[j] * m_df[j - i]; 409 m_r[i] += m_df[j] * m_df[j - i];
411 } 410 }
412 411
413 m_r[i] /= n - i - 1; 412 m_r[i] /= n - i - 1;
414 } 413 }
525 int p0 = tempo2lag(t1); 524 int p0 = tempo2lag(t1);
526 int p1 = tempo2lag(t0); 525 int p1 = tempo2lag(t0);
527 526
528 std::map<float, int> candidates; 527 std::map<float, int> candidates;
529 528
530 for (int i = p0; i <= p1 && i < n/2-1; ++i) { 529 for (int i = p0; i <= p1 && i+1 < n/2; ++i) {
531 530
532 if (m_fr[i] > m_fr[i-1] && 531 if (m_fr[i] > m_fr[i-1] &&
533 m_fr[i] > m_fr[i+1]) { 532 m_fr[i] > m_fr[i+1]) {
534 533
535 // This is a peak in the filtered autocorrelation: stick 534 // This is a peak in the filtered autocorrelation: stick
620 { 619 {
621 } 620 }
622 621
623 FixedTempoEstimator::~FixedTempoEstimator() 622 FixedTempoEstimator::~FixedTempoEstimator()
624 { 623 {
624 delete m_d;
625 } 625 }
626 626
627 string 627 string
628 FixedTempoEstimator::getIdentifier() const 628 FixedTempoEstimator::getIdentifier() const
629 { 629 {