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  ~CL_PitchDetect() override;
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  void reset(fpreal val=0.0) override;
48  int maxFilterSamples() override;
49 
50  void clearSamples(int from);
51 private:
52 
53  // override this function to do the operation you want
54  void doWindowOp(int nsamples,fpreal *dest) override;
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  int operator==(const cl_PitchNode &);
121 
128 };
129 
130 #endif
cl_PitchNode * myPrevHarmonic
fpreal myPitchVolume
fpreal myHintBandwidth
int myHarmonicCompensation
GLuint start
Definition: glcorearb.h:475
fpreal myHarmonicError
UT_Array< cl_PitchNode > myHarmonics
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
< returns > If no error
Definition: snippets.dox:2
#define CL_API
Definition: CL_API.h:10
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:475
fpreal * myWindow
virtual void reset(fpreal val=0.0)
UT_FFT< fpreal > * myTransform
IMATH_HOSTDEVICE constexpr int divs(int x, int y) IMATH_NOEXCEPT
Definition: ImathFun.h:140
GLsizeiptr size
Definition: glcorearb.h:664
fpreal * myFiltered
fpreal * myMultiResults
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLfloat * val
Definition: glcorearb.h:1608
virtual int maxFilterSamples()
fpreal mySingleMag
fpreal myMinJumpLevel
OIIO_FORCEINLINE T log(const T &v)
Definition: simd.h:7688
fpreal myFrequencyHint
cl_PitchNode * myNextHarmonic