/Users/richardeakin/projects/libsms/trunk/src/peakDetection.c File Reference

peak detection algorithm and functions More...

#include "sms.h"
Include dependency graph for peakDetection.c:

Functions

static sfloat PeakInterpolation (sfloat fMaxVal, sfloat fLeftBinVal, sfloat fRightBinVal, sfloat *pFDiffFromMax)
 function used for the parabolic interpolation of the spectral peaks
static int FindNextMax (sfloat *pFMagSpectrum, int iHighBinBound, int *pICurrentLoc, sfloat *pFMaxVal, sfloat fMinPeakMag)
 detect the next local maximum in the spectrum
static int FindNextPeak (sfloat *pFMagSpectrum, int iHighestBin, int *pICurrentLoc, sfloat *pFPeakMag, sfloat *pFPeakLoc, sfloat fMinPeakMag)
 function to detect the next spectral peak
static sfloat GetPhaseVal (sfloat *pPhaseSpectrum, sfloat fPeakLoc)
 get the corresponding phase value for a given peak
int sms_detectPeaks (int sizeSpec, sfloat *pMag, sfloat *pPhase, SMS_Peak *pSpectralPeaks, SMS_PeakParams *pPeakParams)
 find the prominent spectral peaks

Detailed Description

peak detection algorithm and functions


Function Documentation

static int FindNextMax ( sfloat *  pFMagSpectrum,
int  iHighBinBound,
int *  pICurrentLoc,
sfloat *  pFMaxVal,
sfloat  fMinPeakMag 
) [static]

detect the next local maximum in the spectrum

stores the value in pFMaxVal

Todo:
export this to sms.h and wrap in pysms
Parameters:
pFMagSpectrum magnitude spectrum
iHighBinBound highest bin to search
pICurrentLoc current bin location
pFMaxVal value of the maximum found
fMinPeakMag minimum magnitude to accept a peak
Returns:
the bin location of the maximum

References sfloat.

Referenced by FindNextPeak().

static int FindNextPeak ( sfloat *  pFMagSpectrum,
int  iHighestBin,
int *  pICurrentLoc,
sfloat *  pFPeakMag,
sfloat *  pFPeakLoc,
sfloat  fMinPeakMag 
) [static]

function to detect the next spectral peak

Parameters:
pFMagSpectrum magnitude spectrum
iHighestBin highest bin to search
pICurrentLoc current bin location
pFPeakMag magnitude value of peak
pFPeakLoc location of peak
fMinPeakMag minimum magnitude to accept a peak
Returns:
1 if found, 0 if not

References FindNextMax(), PeakInterpolation(), and sfloat.

Referenced by sms_detectPeaks().

Here is the call graph for this function:

static sfloat GetPhaseVal ( sfloat *  pPhaseSpectrum,
sfloat  fPeakLoc 
) [static]

get the corresponding phase value for a given peak

performs linear interpolation for a more accurate phase

Parameters:
pPhaseSpectrum phase spectrum
fPeakLoc location of peak
Returns:
the phase value

References PI, sfloat, and TWO_PI.

Referenced by sms_detectPeaks().

static sfloat PeakInterpolation ( sfloat  fMaxVal,
sfloat  fLeftBinVal,
sfloat  fRightBinVal,
sfloat *  pFDiffFromMax 
) [static]

function used for the parabolic interpolation of the spectral peaks

it performs the interpolation in a log scale and stores the location in pFDiffFromMax and

Parameters:
fMaxVal value of max bin
fLeftBinVal value for left bin
fRightBinVal value for right bin
pFDiffFromMax location of the tip as the difference from the top bin
Returns:
the peak height

Referenced by FindNextPeak().

int sms_detectPeaks ( int  sizeSpec,
sfloat *  pMag,
sfloat *  pPhase,
SMS_Peak pSpectralPeaks,
SMS_PeakParams pPeakParams 
)

find the prominent spectral peaks

uses a dB spectrum

Parameters:
sizeSpec size of magnitude spectrum
pMag pointer to power spectrum
pPhase pointer to phase spectrum
pSpectralPeaks pointer to array of peaks
pPeakParams peak detection parameters
Returns:
the number of peaks found

References SMS_Peak::fFreq, SMS_PeakParams::fHighestFreq, FindNextPeak(), SMS_PeakParams::fLowestFreq, SMS_Peak::fMag, SMS_PeakParams::fMinPeakMag, SMS_Peak::fPhase, GetPhaseVal(), SMS_PeakParams::iMaxPeaks, SMS_PeakParams::iSamplingRate, MAX, MIN, and sfloat.

Referenced by sms_analyzeFrame().

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Thu Oct 29 04:08:07 2009 for libsms by  doxygen 1.6.1