22 #ifndef SemitoneCenterFinder_hxx
23 #define SemitoneCenterFinder_hxx
35 typedef std::vector<std::pair<double, double> >
PeakList;
37 unsigned _histogramSize;
38 unsigned * _histogram;
39 unsigned _binsPerSemitone;
45 _histogram =
new unsigned[_histogramSize];
46 for (
unsigned int i=0; i<_histogramSize; i++)
53 void doIt(
unsigned int nPeaks,
const double * peakPositions,
const double * peakValues)
55 for (
unsigned int i=0; i<nPeaks; i++)
57 double semitonePosition = std::fmod(peakPositions[i],_binsPerSemitone);
58 unsigned histogramBin=semitonePosition*_histogramSize/_binsPerSemitone+0.5;
59 _histogram[histogramBin]++;
65 unsigned maxOcurrences=0;
66 for (
unsigned int i=0; i<_histogramSize; i++)
68 if (_histogram[i]<=maxOcurrences)
continue;
69 maxOcurrences=_histogram[i];
72 return maxPos*_binsPerSemitone/float(_histogramSize);
78 #endif// SemitoneCenterFinder_hxx