1
////////////////////////////////////////////////////////////////////////////////
3
/// The routine detects highest value on an array of values and calculates the
4
/// precise peak location as a mass-center of the 'hump' around the peak value.
6
/// Author : Copyright (c) Olli Parviainen
7
/// Author e-mail : oparviai 'at' iki.fi
8
/// SoundTouch WWW: http://www.surina.net/soundtouch
10
////////////////////////////////////////////////////////////////////////////////
12
// Last changed : $Date: 2006/09/18 07:31:49 $
13
// File revision : $Revision: 1.2 $
15
// $Id: PeakFinder.h,v 1.2 2006/09/18 07:31:49 richardash1981 Exp $
17
////////////////////////////////////////////////////////////////////////////////
21
// SoundTouch audio processing library
22
// Copyright (c) Olli Parviainen
24
// This library is free software; you can redistribute it and/or
25
// modify it under the terms of the GNU Lesser General Public
26
// License as published by the Free Software Foundation; either
27
// version 2.1 of the License, or (at your option) any later version.
29
// This library is distributed in the hope that it will be useful,
30
// but WITHOUT ANY WARRANTY; without even the implied warranty of
31
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32
// Lesser General Public License for more details.
34
// You should have received a copy of the GNU Lesser General Public
35
// License along with this library; if not, write to the Free Software
36
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38
////////////////////////////////////////////////////////////////////////////////
40
#ifndef _PeakFinder_H_
41
#define _PeakFinder_H_
46
/// Min, max allowed peak positions within the data vector
49
/// Calculates the mass center between given vector items.
50
float calcMassCenter(const float *data, ///< Data vector.
51
int firstPos, ///< Index of first vector item beloging to the peak.
52
int lastPos ///< Index of last vector item beloging to the peak.
55
/// Finds the data vector index where the monotoniously decreasing signal crosses the
57
int findCrossingLevel(const float *data, ///< Data vector.
58
float level, ///< Goal crossing level.
59
int peakpos, ///< Peak position index within the data vector.
60
int direction /// Direction where to proceed from the peak: 1 = right, -1 = left.
63
/// Finds the 'ground' level, i.e. smallest level between two neighbouring peaks, to right-
64
/// or left-hand side of the given peak position.
65
int findGround(const float *data, /// Data vector.
66
int peakpos, /// Peak position index within the data vector.
67
int direction /// Direction where to proceed from the peak: 1 = right, -1 = left.
74
/// Detect exact peak position of the data vector by finding the largest peak 'hump'
75
/// and calculating the mass-center location of the peak hump.
77
/// \return The exact mass-center location of the largest peak hump.
78
float detectPeak(const float *data, /// Data vector to be analyzed. The data vector has
79
/// to be at least 'maxPos' items long.
80
int minPos, ///< Min allowed peak location within the vector data.
81
int maxPos ///< Max allowed peak location within the vector data.
85
#endif // _PeakFinder_H_