To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / PeakInterpolator.h @ 42:45b4401136f6

History | View | Annotate | Download (2.4 KB)

1 39:822cf7b8e070 Chris
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
/*
3
    This file is Copyright (c) 2012 Chris Cannam
4

5
    Permission is hereby granted, free of charge, to any person
6
    obtaining a copy of this software and associated documentation
7
    files (the "Software"), to deal in the Software without
8
    restriction, including without limitation the rights to use, copy,
9
    modify, merge, publish, distribute, sublicense, and/or sell copies
10
    of the Software, and to permit persons to whom the Software is
11
    furnished to do so, subject to the following conditions:
12

13
    The above copyright notice and this permission notice shall be
14
    included in all copies or substantial portions of the Software.
15

16
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
20
    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21
    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
25
#ifndef _PEAK_INTERPOLATOR_H_
26
#define _PEAK_INTERPOLATOR_H_
27
28
class PeakInterpolator
29
{
30
public:
31
    PeakInterpolator() { }
32
    ~PeakInterpolator() { }
33
34
    /**
35 42:45b4401136f6 Chris
     * Return the interpolated location (i.e. possibly between sample
36
     * point indices) of the peak in the given sampled range.
37
     *
38
     * "The peak" is defined as the (approximate) location of the
39
     * maximum of a function interpolating between the points
40
     * neighbouring the sample index with the maximum value in the
41
     * range.
42
     *
43
     * If multiple local peak samples in the input range are equal,
44
     * i.e. there is more than one apparent peak in the range, the one
45
     * with the lowest index will be used. This is the case even if a
46
     * later peak would be of superior height after interpolation.
47
     */
48
    double findPeakLocation(const double *data, int size);
49
50
    /**
51 39:822cf7b8e070 Chris
     * Return the interpolated location (i.e. between sample point
52 42:45b4401136f6 Chris
     * indices) of the peak whose nearest sample is found at peakIndex
53
     * in the given sampled range. This method allows you to specify
54
     * which peak to find, if local rather than global peaks are of
55
     * interest.
56 39:822cf7b8e070 Chris
     */
57
    double findPeakLocation(const double *data, int size, int peakIndex);
58
};
59
60
#endif