Chris@8
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@8
|
2 /*
|
Chris@8
|
3 Permission is hereby granted, free of charge, to any person
|
Chris@8
|
4 obtaining a copy of this software and associated documentation
|
Chris@8
|
5 files (the "Software"), to deal in the Software without
|
Chris@8
|
6 restriction, including without limitation the rights to use, copy,
|
Chris@8
|
7 modify, merge, publish, distribute, sublicense, and/or sell copies
|
Chris@8
|
8 of the Software, and to permit persons to whom the Software is
|
Chris@8
|
9 furnished to do so, subject to the following conditions:
|
Chris@8
|
10
|
Chris@8
|
11 The above copyright notice and this permission notice shall be
|
Chris@8
|
12 included in all copies or substantial portions of the Software.
|
Chris@8
|
13
|
Chris@8
|
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Chris@8
|
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
Chris@8
|
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
Chris@8
|
17 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
Chris@8
|
18 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
Chris@8
|
19 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
Chris@8
|
20 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Chris@8
|
21 */
|
Chris@8
|
22
|
Chris@8
|
23 #ifndef _CEPSTRUM_PITCH_H_
|
Chris@8
|
24 #define _CEPSTRUM_PITCH_H_
|
Chris@8
|
25
|
Chris@8
|
26 #include <vamp-sdk/Plugin.h>
|
Chris@8
|
27
|
Chris@8
|
28 class CepstrumPitchTracker : public Vamp::Plugin
|
Chris@8
|
29 {
|
Chris@8
|
30 public:
|
Chris@8
|
31 CepstrumPitchTracker(float inputSampleRate);
|
Chris@8
|
32 virtual ~CepstrumPitchTracker();
|
Chris@8
|
33
|
Chris@8
|
34 std::string getIdentifier() const;
|
Chris@8
|
35 std::string getName() const;
|
Chris@8
|
36 std::string getDescription() const;
|
Chris@8
|
37 std::string getMaker() const;
|
Chris@8
|
38 int getPluginVersion() const;
|
Chris@8
|
39 std::string getCopyright() const;
|
Chris@8
|
40
|
Chris@8
|
41 InputDomain getInputDomain() const;
|
Chris@8
|
42 size_t getPreferredBlockSize() const;
|
Chris@8
|
43 size_t getPreferredStepSize() const;
|
Chris@8
|
44 size_t getMinChannelCount() const;
|
Chris@8
|
45 size_t getMaxChannelCount() const;
|
Chris@8
|
46
|
Chris@8
|
47 ParameterList getParameterDescriptors() const;
|
Chris@8
|
48 float getParameter(std::string identifier) const;
|
Chris@8
|
49 void setParameter(std::string identifier, float value);
|
Chris@8
|
50
|
Chris@8
|
51 ProgramList getPrograms() const;
|
Chris@8
|
52 std::string getCurrentProgram() const;
|
Chris@8
|
53 void selectProgram(std::string name);
|
Chris@8
|
54
|
Chris@8
|
55 OutputList getOutputDescriptors() const;
|
Chris@8
|
56
|
Chris@8
|
57 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
|
Chris@8
|
58 void reset();
|
Chris@8
|
59
|
Chris@8
|
60 FeatureSet process(const float *const *inputBuffers,
|
Chris@8
|
61 Vamp::RealTime timestamp);
|
Chris@8
|
62
|
Chris@8
|
63 FeatureSet getRemainingFeatures();
|
Chris@8
|
64
|
Chris@8
|
65 protected:
|
Chris@8
|
66 size_t m_channels;
|
Chris@8
|
67 size_t m_stepSize;
|
Chris@8
|
68 size_t m_blockSize;
|
Chris@8
|
69 float m_fmin;
|
Chris@8
|
70 float m_fmax;
|
Chris@8
|
71 int m_histlen;
|
Chris@10
|
72 int m_vflen;
|
Chris@8
|
73
|
Chris@8
|
74 int m_binFrom;
|
Chris@8
|
75 int m_binTo;
|
Chris@8
|
76 int m_bins; // count of "interesting" bins, those returned in m_cepOutput
|
Chris@8
|
77
|
Chris@8
|
78 double **m_history;
|
Chris@8
|
79
|
Chris@11
|
80 int m_prevpeak;
|
Chris@11
|
81 double m_prevprop;
|
Chris@11
|
82
|
Chris@11
|
83 double calculatePeakProportion(const double *data, double abstot, int n);
|
Chris@11
|
84 bool acceptPeak(int n, double peakProportion);
|
Chris@11
|
85
|
Chris@8
|
86 void filter(const double *in, double *out);
|
Chris@8
|
87 void fft(unsigned int n, bool inverse,
|
Chris@8
|
88 double *ri, double *ii, double *ro, double *io);
|
Chris@8
|
89 };
|
Chris@8
|
90
|
Chris@8
|
91 #endif
|