Detection of a given harmonic. More...
#include "sms.h"
Defines | |
| #define | N_FUND_HARM 6 |
| #define | N_HARM_PEAKS 4 |
| #define | FREQ_DEV_THRES .07 |
| #define | MAG_PERC_THRES .6 |
| #define | HARM_RATIO_THRES .8 |
Functions | |
| static int | GetClosestPeak (int iPeakCandidate, int nHarm, SMS_Peak *pSpectralPeaks, int *pICurrentPeak, int iRefHarmonic) |
| get closest peak to a given harmonic of the possible fundamental | |
| static int | ComparePeak (sfloat fRefHarmMag, SMS_Peak *pSpectralPeaks, int nCand, sfloat fRefHarmMagDiffFromMax) |
| checks if peak is substantial | |
| int | CheckIfHarmonic (sfloat fFundFreq, SMS_HarmCandidate *pCHarmonic, int nCand) |
| check if the current peak is a harmonic of one of the candidates | |
| static int | GoodCandidate (int iPeak, SMS_Peak *pSpectralPeaks, SMS_HarmCandidate *pCHarmonic, int nCand, SMS_PeakParams *pPeakParams, sfloat fRefFundamental) |
| consider a peak as a possible candidate and give it a weight value, | |
| static int | GetBestCandidate (SMS_HarmCandidate *pCHarmonic, int iRefHarmonic, int nGoodPeaks, sfloat fPrevFund) |
| choose the best fundamental out of all the candidates | |
| void | sms_harmDetection (SMS_AnalFrame *pFrame, sfloat fRefFundamental, SMS_PeakParams *pPeakParams) |
| main harmonic detection function | |
Detection of a given harmonic.
| #define FREQ_DEV_THRES .07 |
threshold for deviation from perfect harmonics
Referenced by GoodCandidate().
| #define HARM_RATIO_THRES .8 |
threshold for percentage of harmonics found
Referenced by GoodCandidate().
| #define MAG_PERC_THRES .6 |
threshold for magnitude of harmonics with respect to the total magnitude
Referenced by GoodCandidate().
| #define N_FUND_HARM 6 |
number of harmonics to use for fundamental detection
Referenced by ComparePeak(), and GoodCandidate().
| #define N_HARM_PEAKS 4 |
number of peaks to check as possible ref harmonics
Referenced by sms_harmDetection().
| int CheckIfHarmonic | ( | sfloat | fFundFreq, | |
| SMS_HarmCandidate * | pCHarmonic, | |||
| int | nCand | |||
| ) |
check if the current peak is a harmonic of one of the candidates
| fFundFreq | frequency of peak to be tested | |
| pCHarmonic | all candidates accepted | |
| nCand | location of las candidate |
Referenced by GoodCandidate().
| static int ComparePeak | ( | sfloat | fRefHarmMag, | |
| SMS_Peak * | pSpectralPeaks, | |||
| int | nCand, | |||
| sfloat | fRefHarmMagDiffFromMax | |||
| ) | [static] |
checks if peak is substantial
check if peak is larger enough to be considered a fundamental without any further testing or too small to be considered
| fRefHarmMag | magnitude of possible fundamental | |
| pSpectralPeaks | all the peaks | |
| nCand | number of existing candidates | |
| fRefHarmMagDiffFromMax | value to judge the peak based on the difference of its magnitude compared to the reference |
References SMS_Peak::fMag, N_FUND_HARM, and sfloat.
Referenced by GoodCandidate().
| static int GetBestCandidate | ( | SMS_HarmCandidate * | pCHarmonic, | |
| int | iRefHarmonic, | |||
| int | nGoodPeaks, | |||
| sfloat | fPrevFund | |||
| ) | [static] |
choose the best fundamental out of all the candidates
| pCHarmonic | array of candidates | |
| iRefHarmonic | reference harmonic number | |
| nGoodPeaks | number of candiates | |
| fPrevFund | reference fundamental |
References SMS_HarmCandidate::fFreq, and sfloat.
Referenced by sms_harmDetection().
| static int GetClosestPeak | ( | int | iPeakCandidate, | |
| int | nHarm, | |||
| SMS_Peak * | pSpectralPeaks, | |||
| int * | pICurrentPeak, | |||
| int | iRefHarmonic | |||
| ) | [static] |
get closest peak to a given harmonic of the possible fundamental
| iPeakCandidate | peak number of possible fundamental | |
| nHarm | number of harmonic | |
| pSpectralPeaks | pointer to all the peaks | |
| pICurrentPeak | pointer to the last peak taken | |
| iRefHarmonic | reference harmonic number |
References sfloat.
Referenced by GoodCandidate().
| static int GoodCandidate | ( | int | iPeak, | |
| SMS_Peak * | pSpectralPeaks, | |||
| SMS_HarmCandidate * | pCHarmonic, | |||
| int | nCand, | |||
| SMS_PeakParams * | pPeakParams, | |||
| sfloat | fRefFundamental | |||
| ) | [static] |
consider a peak as a possible candidate and give it a weight value,
| iPeak | iPeak number to be considered | |
| pSpectralPeaks | all the peaks | |
| pCHarmonic | all the candidates | |
| nCand | candidate number that is to be filled | |
| pPeakParams | analysis parameters | |
| fRefFundamental | previous fundamental |
References CheckIfHarmonic(), ComparePeak(), SMS_HarmCandidate::fFreq, SMS_Peak::fFreq, SMS_HarmCandidate::fFreqDev, SMS_HarmCandidate::fHarmRatio, SMS_HarmCandidate::fMag, SMS_Peak::fMag, SMS_HarmCandidate::fMagPerc, SMS_PeakParams::fRefHarmMagDiffFromMax, FREQ_DEV_THRES, GetClosestPeak(), HARM_RATIO_THRES, SMS_PeakParams::iRefHarmonic, SMS_PeakParams::iSoundType, MAG_PERC_THRES, N_FUND_HARM, sfloat, and SMS_SOUND_TYPE_NOTE.
Referenced by sms_harmDetection().

| void sms_harmDetection | ( | SMS_AnalFrame * | pFrame, | |
| sfloat | fRefFundamental, | |||
| SMS_PeakParams * | pPeakParams | |||
| ) |
main harmonic detection function
find a given harmonic peak from a set of spectral peaks, put the frequency of the fundamental in the current frame
| pFrame | pointer to current frame | |
| fRefFundamental | frequency of previous frame | |
| pPeakParams | pointer to analysis parameters |
is it possible to use pSpectralPeaks instead of SMS_AnalFrame?
move pCHarmonic array to SMS_AnalFrame structure
<
References SMS_HarmCandidate::fFreq, SMS_Peak::fFreq, SMS_AnalFrame::fFundamental, SMS_PeakParams::fHighestFundamental, SMS_PeakParams::fLowestFreq, SMS_Peak::fMag, GetBestCandidate(), GoodCandidate(), SMS_PeakParams::iRefHarmonic, N_HARM_PEAKS, SMS_AnalFrame::pSpectralPeaks, and sfloat.
Referenced by sms_analyzeFrame().

1.6.1