To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / CepstrumPitchTracker.h @ 6:291c75f6e837

History | View | Annotate | Download (2.94 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
/*
3
    Permission is hereby granted, free of charge, to any person
4
    obtaining a copy of this software and associated documentation
5
    files (the "Software"), to deal in the Software without
6
    restriction, including without limitation the rights to use, copy,
7
    modify, merge, publish, distribute, sublicense, and/or sell copies
8
    of the Software, and to permit persons to whom the Software is
9
    furnished to do so, subject to the following conditions:
10

11
    The above copyright notice and this permission notice shall be
12
    included in all copies or substantial portions of the Software.
13

14
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
18
    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19
    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
*/
22

    
23
#ifndef _CEPSTRUM_PITCH_H_
24
#define _CEPSTRUM_PITCH_H_
25

    
26
#include <vamp-sdk/Plugin.h>
27

    
28
class CepstrumPitchTracker : public Vamp::Plugin
29
{
30
public:
31
    CepstrumPitchTracker(float inputSampleRate);
32
    virtual ~CepstrumPitchTracker();
33

    
34
    std::string getIdentifier() const;
35
    std::string getName() const;
36
    std::string getDescription() const;
37
    std::string getMaker() const;
38
    int getPluginVersion() const;
39
    std::string getCopyright() const;
40

    
41
    InputDomain getInputDomain() const;
42
    size_t getPreferredBlockSize() const;
43
    size_t getPreferredStepSize() const;
44
    size_t getMinChannelCount() const;
45
    size_t getMaxChannelCount() const;
46

    
47
    ParameterList getParameterDescriptors() const;
48
    float getParameter(std::string identifier) const;
49
    void setParameter(std::string identifier, float value);
50

    
51
    ProgramList getPrograms() const;
52
    std::string getCurrentProgram() const;
53
    void selectProgram(std::string name);
54

    
55
    OutputList getOutputDescriptors() const;
56

    
57
    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
58
    void reset();
59

    
60
    FeatureSet process(const float *const *inputBuffers,
61
                       Vamp::RealTime timestamp);
62

    
63
    FeatureSet getRemainingFeatures();
64

    
65
protected:
66
    size_t m_channels;
67
    size_t m_stepSize;
68
    size_t m_blockSize;
69
    float m_fmin;
70
    float m_fmax;
71
    int m_histlen;
72
    int m_vflen;
73

    
74
    int m_binFrom;
75
    int m_binTo;
76
    int m_bins; // count of "interesting" bins, those returned in m_cepOutput
77

    
78
    double **m_history;
79
    
80
    int m_prevpeak;
81
    double m_prevprop;
82

    
83
    double calculatePeakProportion(const double *data, double abstot, int n);
84
    bool acceptPeak(int n, double peakProportion);
85

    
86
    void filter(const double *in, double *out);
87
    void fft(unsigned int n, bool inverse,
88
             double *ri, double *ii, double *ro, double *io);
89
};
90

    
91
#endif