22 #ifndef CircularPeakPicking_hxx
23 #define CircularPeakPicking_hxx
48 typedef std::vector<std::pair<double, double> >
PeakList;
51 unsigned int _maxSize;
56 : _maxSize(chromagramSize), _binSize(binSize), _offset(offset)
58 _output.reserve(chromagramSize);
70 std::pair<double,double>
interpolate(
double y0,
double y1,
double y2)
92 double a = y0/2 - y1 + y2/2;
97 double xmax = -b/(a*2);
102 double ymax = b*xmax/2 + y0;
104 return std::make_pair(xmax, ymax);
106 void doIt(
const std::vector<double> & chromagram)
109 unsigned i0=_maxSize-2;
110 unsigned i1=_maxSize-1;
111 for (
unsigned i=0; i<_maxSize; i0=i1, i1=i, i++)
114 if (chromagram[i0] > chromagram[i1])
continue;
115 if (chromagram[i ] >= chromagram[i1])
continue;
117 std::pair<double,double> interpoled=
118 interpolate(chromagram[i0],chromagram[i1],chromagram[i]);
120 interpoled.first+=i0;
122 while (interpoled.first<0) interpoled.first +=_maxSize;
123 while (interpoled.first>=_maxSize) interpoled.first -=_maxSize;
125 interpoled.first*=_binSize;
127 interpoled.first+=_offset;
129 _output.push_back(interpoled);
140 #endif// CircularPeakPicking_hxx