00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __CL_PitchDetect__
00023 #define __CL_PitchDetect__
00024
00025 #include "CL_API.h"
00026 #include <UT/UT_RefArray.h>
00027 #include "CL_SlidingWindow.h"
00028
00029 class UT_FFT;
00030 class cl_PitchNode;
00031
00032 class CL_API CL_PitchDetect : public CL_SlidingWindow
00033 {
00034 public:
00035
00036 CL_PitchDetect(int size, float freqres);
00037 virtual ~CL_PitchDetect();
00038
00039 void setPitchMode(int multi);
00040
00041 void setMultiParms(float start, float end, int divs,
00042 int log, float *results);
00043
00044 void setBandwidth(float low, float high);
00045 void setMinLevel(float min);
00046 void setFloatingBandwidth(int on, float bandwidth);
00047 void setHarmonicCompensation(int on, int correct,float error);
00048 void setSmoothJumps(int on, float minjump);
00049 void setFrequencyHint(int on, float hint, float bandwidth);
00050
00051 void getPitchResult(float &pitch, float &volume);
00052 float *getPitchResult();
00053
00054 virtual void reset(float val=0.0F);
00055 virtual int maxFilterSamples();
00056
00057 void clearSamples(int from);
00058 private:
00059
00060
00061 virtual void doWindowOp(int nsamples,float *dest);
00062
00063 void selectBand();
00064 void selectMultipleBands();
00065 void detectHarmonics();
00066 void designFilter(int size);
00067
00068 void setupPitch();
00069 void cleanupPitch();
00070
00071 protected:
00072
00073 float myMinLevel;
00074 float myFreqRes;
00075
00076
00077 float myLowFreq;
00078 float myHighFreq;
00079
00080 int myFloatingBandwidthOn;
00081 float myFloatingBandwidth;
00082
00083 int myHarmonicCompensation;
00084 float myHarmonicError;
00085 int myHarmonicCorrect;
00086
00087 int mySmoothJumps;
00088 float myMinJumpLevel;
00089
00090 int myUseHint;
00091 float myFrequencyHint;
00092 float myHintBandwidth;
00093
00094 float myLastFreq;
00095 float myPitchFreq;
00096 float myPitchVolume;
00097
00098 int myMode;
00099 int myLogMode;
00100 int myDivisions;
00101 float *myMultiResults;
00102
00103 float *myWindow;
00104 float *myData;
00105 float *myReal;
00106 float *myImag;
00107 float *myKernel;
00108 float *myFiltered;
00109 int myKernelSize;
00110 UT_FFT *myTransform;
00111
00112 UT_RefArray<cl_PitchNode> myHarmonics;
00113 };
00114
00115 class CL_API cl_PitchNode
00116 {
00117 public:
00118
00119 cl_PitchNode()
00120 { myFrequency = mySingleMag = myMag = 0.0F; myNextHarmonic = 0;
00121 myPrevHarmonic = 0; myAmAHarmonic = 0; }
00122
00123 cl_PitchNode(float freq, float mag)
00124 { myFrequency = freq; mySingleMag = myMag = mag; myNextHarmonic = 0;
00125 myAmAHarmonic = 0; myPrevHarmonic = 0; }
00126
00127 cl_PitchNode & operator=(const cl_PitchNode &);
00128 int operator==(const cl_PitchNode &);
00129
00130 float myFrequency;
00131 float myMag;
00132 float mySingleMag;
00133 cl_PitchNode *myNextHarmonic;
00134 cl_PitchNode *myPrevHarmonic;
00135 int myAmAHarmonic;
00136 };
00137
00138 #endif