HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CL_PitchDetect.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CL_PitchDetect.h ( Clip Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Detects the most dominant frequency in an audio sample
11  *
12  */
13 
14 #ifndef __CL_PitchDetect__
15 #define __CL_PitchDetect__
16 
17 #include "CL_API.h"
18 #include "CL_SlidingWindow.h"
19 #include <UT/UT_FFT.h>
20 #include <UT/UT_Array.h>
21 #include <SYS/SYS_Types.h>
22 
23 class cl_PitchNode;
24 
26 {
27 public:
28 
29  CL_PitchDetect(int size, fpreal freqres);
30  virtual ~CL_PitchDetect();
31 
32  void setPitchMode(int multi);
33 
34  void setMultiParms(fpreal start, fpreal end, int divs,
35  int log, fpreal *results);
36 
37  void setBandwidth(fpreal low, fpreal high);
38  void setMinLevel(fpreal min);
39  void setFloatingBandwidth(int on, fpreal bandwidth);
40  void setHarmonicCompensation(int on, int correct,fpreal error);
41  void setSmoothJumps(int on, fpreal minjump);
42  void setFrequencyHint(int on, fpreal hint, fpreal bandwidth);
43 
44  void getPitchResult(fpreal &pitch, fpreal &volume);
45  fpreal *getPitchResult();
46 
47  virtual void reset(fpreal val=0.0);
48  virtual int maxFilterSamples();
49 
50  void clearSamples(int from);
51 private:
52 
53  // override this function to do the operation you want
54  virtual void doWindowOp(int nsamples,fpreal *dest);
55 
56  void selectBand();
57  void selectMultipleBands();
58  void detectHarmonics();
59  void designFilter(int size);
60 
61  void setupPitch();
62  void cleanupPitch();
63 
64 protected:
65 
68 
69 
72 
75 
79 
82 
83  int myUseHint;
86 
90 
91  int myMode;
92  int myLogMode;
95 
104 
106 };
107 
109 {
110 public:
111 
113  { myFrequency = mySingleMag = myMag = 0.0; myNextHarmonic = 0;
114  myPrevHarmonic = 0; myAmAHarmonic = 0; }
115 
117  { myFrequency = freq; mySingleMag = myMag = mag; myNextHarmonic = 0;
118  myAmAHarmonic = 0; myPrevHarmonic = 0; }
119 
120  cl_PitchNode & operator=(const cl_PitchNode &);
121  int operator==(const cl_PitchNode &);
122 
129 };
130 
131 #endif
cl_PitchNode * myPrevHarmonic
fpreal myPitchVolume
fpreal myHintBandwidth
int myHarmonicCompensation
GLuint start
Definition: glcorearb.h:474
fpreal myHarmonicError
UT_Array< cl_PitchNode > myHarmonics
GLsizeiptr size
Definition: glcorearb.h:663
int divs(int x, int y)
Definition: ImathFun.h:180
#define CL_API
Definition: CL_API.h:10
SYS_API double log(double x)
Definition: SYS_FPUMath.h:87
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
cl_PitchNode(fpreal freq, fpreal mag)
fpreal myFrequency
fpreal myFloatingBandwidth
GLuint GLuint end
Definition: glcorearb.h:474
fpreal * myWindow
virtual void reset(fpreal val=0.0)
UT_FFT< fpreal > * myTransform
fpreal * myFiltered
double fpreal
Definition: SYS_Types.h:270
fpreal * myMultiResults
GLuint GLfloat * val
Definition: glcorearb.h:1607
virtual int maxFilterSamples()
fpreal mySingleMag
fpreal myMinJumpLevel
fpreal myFrequencyHint
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
cl_PitchNode * myNextHarmonic