Merge 0.4.0
[vamp-aubio-plugins.git] / plugins / Notes.h
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
3 /*
4     Vamp feature extraction plugins using Paul Brossier's Aubio library.
5
6     Centre for Digital Music, Queen Mary, University of London.
7     This file copyright 2006 Chris Cannam.
8     
9     This program is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License as
11     published by the Free Software Foundation; either version 2 of the
12     License, or (at your option) any later version.  See the file
13     COPYING included with this distribution for more information.
14
15 */
16
17 #ifndef _NOTES_PLUGIN_H_
18 #define _NOTES_PLUGIN_H_
19
20 #include <vamp-sdk/Plugin.h>
21 #include <aubio/aubio.h>
22
23 #include <deque>
24
25 #include "Types.h"
26
27 class Notes : public Vamp::Plugin
28 {
29 public:
30     Notes(float inputSampleRate);
31     virtual ~Notes();
32
33     bool initialise(size_t channels, size_t stepSize, size_t blockSize);
34     void reset();
35
36     InputDomain getInputDomain() const { return TimeDomain; }
37
38     std::string getIdentifier() const;
39     std::string getName() const;
40     std::string getDescription() const;
41     std::string getMaker() const;
42     int getPluginVersion() const;
43     std::string getCopyright() const;
44
45     ParameterList getParameterDescriptors() const;
46     float getParameter(std::string) const;
47     void setParameter(std::string, float);
48
49     size_t getPreferredStepSize() const;
50     size_t getPreferredBlockSize() const;
51
52     OutputList getOutputDescriptors() const;
53
54     FeatureSet process(const float *const *inputBuffers,
55                        Vamp::RealTime timestamp);
56
57     FeatureSet getRemainingFeatures();
58
59 protected:
60     fvec_t *m_ibuf;
61     fvec_t *m_onset;
62     fvec_t *m_pitch;
63     aubio_onset_t *m_onsetdet;
64     OnsetType m_onsettype;
65     aubio_pitch_t *m_pitchdet;
66     PitchType m_pitchtype;
67     float m_threshold;
68     float m_silence;
69     float m_minioi;
70     size_t m_median;
71     size_t m_stepSize;
72     size_t m_blockSize;
73     int m_minpitch;
74     int m_maxpitch;
75     bool m_wrapRange;
76     bool m_avoidLeaps;
77     std::deque<float> m_notebuf;
78     size_t m_count;
79     Vamp::RealTime m_delay;
80     Vamp::RealTime m_currentOnset;
81     Vamp::RealTime m_lastTimeStamp;
82     float m_currentLevel;
83     bool m_haveCurrent;
84     int m_prevPitch;
85
86     void pushNote(FeatureSet &, const Vamp::RealTime &);
87 };
88
89
90 #endif