00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PITCHINVERSEPROBLEM_H
00020 #define PITCHINVERSEPROBLEM_H
00021
00022 #include "Typedefs.h"
00023 #include "Debug.h"
00024
00025 #include "PeakDetection.h"
00026 #include "PeakInterpolation.h"
00027
00028 #include <Eigen/LU>
00029
00030 class PitchInverseProblem {
00031 protected:
00032 int _fftSize;
00033 int _halfSize;
00034 Real _lowFrequency;
00035 Real _highFrequency;
00036 int _pitchCount;
00037 int _harmonicCount;
00038 int _frequencyCandidateCount;
00039 Real _peakWidth;
00040
00041 Real _samplerate;
00042
00043 Real _tMin;
00044 Real _tMax;
00045 Real _alpha;
00046 Real _beta;
00047 Real _inharmonicity;
00048 Real _regularisation;
00049
00050 MatrixXR _projectionMatrix;
00051 MatrixXR _inverseProjectionMatrix;
00052
00053 PeakDetection _peak;
00054 PeakInterpolation _peakInterp;
00055
00056 void harmonicWeight(MatrixXR f, Real fMin, Real fMax, int harmonicIndex, MatrixXR* result);
00057 void harmonicSpread(MatrixXR f, Real fMin, Real fMax, int harmonicIndex, MatrixXR* result);
00058 void harmonicPosition(MatrixXR f, Real fMin, Real fMax, int harmonicIndex, MatrixXR* result);
00059 Real harmonicWeight(Real f, Real fMin, Real fMax, int harmonicIndex);
00060 Real harmonicSpread(Real f, Real fMin, Real fMax, int harmonicIndex);
00061 Real harmonicPosition(Real f, Real fMin, Real fMax, int harmonicIndex);
00062
00063 public:
00064 PitchInverseProblem(int fftSize = 1024, Real lowFrequency = 50.0, Real highFrequency = 2100.0, Real samplerate = 44100.0, int pitchCount = 5, int harmonicCount = 10, int frequencyCandidateCount = -1, Real peakWidth = 8);
00065
00066 ~PitchInverseProblem();
00067
00068 void reset();
00069 void setup();
00070
00071 void process(const MatrixXR& spectrum, MatrixXR* pitches, MatrixXR* saliencies, MatrixXR* frequencies);
00072
00073 void projectionMatrix(MatrixXR* matrix) const;
00074
00081 Real lowFrequency() const;
00082
00089 void setLowFrequency( Real frequency, bool callSetup = true );
00090
00097 Real highFrequency() const;
00098
00105 void setHighFrequency( Real frequency, bool callSetup = true );
00106
00113 Real samplerate() const;
00114
00120 void setSamplerate( Real frequency, bool callSetup = true );
00121
00128 int fftSize() const;
00129
00136 void setFftSize( int size, bool callSetup = true );
00137
00148 int frequencyCandidateCount() const;
00149
00159 void setFrequencyCandidateCount( int count, bool callSetup = true );
00160
00167 int peakWidth() const;
00168
00174 void setPeakWidth( int width, bool callSetup = true );
00175
00183 int pitchCount() const;
00184
00190 void setPitchCount( int count, bool callSetup = true );
00191
00199 int harmonicCount() const;
00200
00206 void setHarmonicCount( int count, bool callSetup = true );
00207
00208 };
00209
00210 #endif