Mercurial > hg > vamp-simple-cepstrum
comparison CepstrumPitchTracker.cpp @ 27:44bb93cae288
Change peak-to-next-peak ratio to a difference (because difference of peaks in log values don't vary with signal amplification)
author | Chris Cannam |
---|---|
date | Sat, 07 Jul 2012 21:06:37 +0100 |
parents | a15d8c89a36e |
children | 8a77e4de0d46 |
comparison
equal
deleted
inserted
replaced
25:a15d8c89a36e | 27:44bb93cae288 |
---|---|
528 int n = m_bins; | 528 int n = m_bins; |
529 double *data = new double[n]; | 529 double *data = new double[n]; |
530 filter(rawcep, data); | 530 filter(rawcep, data); |
531 delete[] rawcep; | 531 delete[] rawcep; |
532 | 532 |
533 double abstot = 0.0; | |
534 | |
535 for (int i = 0; i < n; ++i) { | |
536 abstot += fabs(data[i]); | |
537 } | |
538 | |
539 double maxval = 0.0; | 533 double maxval = 0.0; |
540 int maxbin = -1; | 534 int maxbin = -1; |
541 | 535 |
542 for (int i = 0; i < n; ++i) { | 536 for (int i = 0; i < n; ++i) { |
543 if (data[i] > maxval) { | 537 if (data[i] > maxval) { |
564 double cimax = findInterpolatedPeak(data, maxbin); | 558 double cimax = findInterpolatedPeak(data, maxbin); |
565 double peakfreq = m_inputSampleRate / (cimax + m_binFrom); | 559 double peakfreq = m_inputSampleRate / (cimax + m_binFrom); |
566 | 560 |
567 double confidence = 0.0; | 561 double confidence = 0.0; |
568 if (nextPeakVal != 0.0) { | 562 if (nextPeakVal != 0.0) { |
569 confidence = ((maxval / nextPeakVal) - 1.0) / 4.0; | 563 confidence = (maxval - nextPeakVal) / 200.0; |
570 if (confidence > 1.0) confidence = 1.0; | 564 if (confidence > 1.0) confidence = 1.0; |
571 } | 565 } |
572 | 566 |
573 Hypothesis::Estimate e; | 567 Hypothesis::Estimate e; |
574 e.freq = peakfreq; | 568 e.freq = peakfreq; |