FundFreqDetect.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FundFreqDetect__
00023 #define _FundFreqDetect__
00024 #include <typeinfo>
00025
00026 #include "DataTypes.hxx"
00027 #include "Processing.hxx"
00028 #include "Array.hxx"
00029 #include "FundFreqDetectConfig.hxx"
00030 #include "InPort.hxx"
00031 #include "OutPort.hxx"
00032 #include "OutControl.hxx"
00033 #include "Array.hxx"
00034
00035 namespace CLAM {
00036
00037 class Storage;
00038 class ProcessingConfig;
00039 class Fundamental;
00040 class SpectralPeakArray;
00041 class IndexArray;
00042
00053 class FundFreqDetect: public Processing {
00054 mutable FundFreqDetectConfig mConfig;
00055
00056 const char *GetClassName() const {return "FundFreqDetect";}
00057
00058 bool ConcreteConfigure(const ProcessingConfig&);
00059
00060 InPort<SpectralPeakArray> mInput;
00061 OutPort<Fundamental> mOutput;
00062 FloatOutControl mFundFreqValue;
00063
00064 public:
00065 FundFreqDetect();
00066
00067 FundFreqDetect(const FundFreqDetectConfig &c);
00068
00069 ~FundFreqDetect();
00070
00071 const ProcessingConfig &GetConfig() const;
00072
00073 bool Do(void);
00074
00076 bool Do(SpectralPeakArray& input,Fundamental& fund);
00077 private:
00078
00079 inline TData WeightCandidate(TData freq, const SpectralPeakArray&, const DataArray& magFactor, const DataArray& magFactor34q,
00080 const DataArray& magFactor4r,int maxNMP, int maxNPM) const;
00081 inline int GetClosestPeak(TData freq, int firstPeak, const IndexArray & peakIndexes, const DataArray & peakFrequencies) const;
00082 inline TData GetClosestHarmonic(TData peak, TData fundfreq, TData oneOverFundFreq) const;
00083 inline bool IsGoodCandidate(TData freq) const;
00084
00086 TData mnMaxCandidates;
00088 TData mReferenceFundFreq;
00089 TData mLowestFundFreq;
00090 TData mHighestFundFreq;
00091
00093 TData mMaxCandMagDiff;
00094
00096 TData mMaxFundFreqError;
00098 TSize mnInt;
00099
00102 TData mPMp, mPMq, mPMr, mMPp, mMPq, mMPr;
00103 TSize mPMnPeaks, mMPnPeaks;
00104 TData mPMCont, mMPCont;
00105 };
00106
00107 }
00108
00109 #endif // _FUNFREQ_DETECT_
00110