Chris@39: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@39: /* Chris@39: This file is Copyright (c) 2012 Chris Cannam Chris@39: Chris@39: Permission is hereby granted, free of charge, to any person Chris@39: obtaining a copy of this software and associated documentation Chris@39: files (the "Software"), to deal in the Software without Chris@39: restriction, including without limitation the rights to use, copy, Chris@39: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@39: of the Software, and to permit persons to whom the Software is Chris@39: furnished to do so, subject to the following conditions: Chris@39: Chris@39: The above copyright notice and this permission notice shall be Chris@39: included in all copies or substantial portions of the Software. Chris@39: Chris@39: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@39: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@39: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@39: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR Chris@39: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@39: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@39: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@39: */ Chris@39: Chris@39: #ifndef _PEAK_INTERPOLATOR_H_ Chris@39: #define _PEAK_INTERPOLATOR_H_ Chris@39: Chris@39: class PeakInterpolator Chris@39: { Chris@39: public: Chris@39: PeakInterpolator() { } Chris@39: ~PeakInterpolator() { } Chris@39: Chris@39: /** Chris@42: * Return the interpolated location (i.e. possibly between sample Chris@42: * point indices) of the peak in the given sampled range. Chris@42: * Chris@42: * "The peak" is defined as the (approximate) location of the Chris@42: * maximum of a function interpolating between the points Chris@42: * neighbouring the sample index with the maximum value in the Chris@42: * range. Chris@42: * Chris@42: * If multiple local peak samples in the input range are equal, Chris@42: * i.e. there is more than one apparent peak in the range, the one Chris@42: * with the lowest index will be used. This is the case even if a Chris@42: * later peak would be of superior height after interpolation. Chris@42: */ Chris@42: double findPeakLocation(const double *data, int size); Chris@42: Chris@42: /** Chris@39: * Return the interpolated location (i.e. between sample point Chris@42: * indices) of the peak whose nearest sample is found at peakIndex Chris@42: * in the given sampled range. This method allows you to specify Chris@42: * which peak to find, if local rather than global peaks are of Chris@42: * interest. Chris@39: */ Chris@39: double findPeakLocation(const double *data, int size, int peakIndex); Chris@39: }; Chris@39: Chris@39: #endif