fix crash when copy'ing latent plugins
[ardour.git] / libs / vamp-plugins / Onset.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 _ONSET_PLUGIN_H_
18 #define _ONSET_PLUGIN_H_
19
20 #include <vamp-sdk/Plugin.h>
21 #include <aubio/aubio.h>
22
23 #ifdef HAVE_AUBIO4
24 enum OnsetType {
25     OnsetEnergy,
26     OnsetSpecDiff,
27     OnsetHFC,
28     OnsetComplex,
29     OnsetPhase,
30     OnsetKL,
31     OnsetMKL,
32     OnsetSpecFlux // new in 0.4!
33 };
34 #endif
35
36 class Onset : public Vamp::Plugin
37 {
38 public:
39     Onset(float inputSampleRate);
40     virtual ~Onset();
41
42     bool initialise(size_t channels, size_t stepSize, size_t blockSize);
43     void reset();
44
45     InputDomain getInputDomain() const { return TimeDomain; }
46
47     std::string getIdentifier() const;
48     std::string getName() const;
49     std::string getDescription() const;
50     std::string getMaker() const;
51     int getPluginVersion() const;
52     std::string getCopyright() const;
53
54     ParameterList getParameterDescriptors() const;
55     float getParameter(std::string) const;
56     void setParameter(std::string, float);
57
58     size_t getPreferredStepSize() const;
59     size_t getPreferredBlockSize() const;
60
61     OutputList getOutputDescriptors() const;
62
63     FeatureSet process(const float *const *inputBuffers,
64                        Vamp::RealTime timestamp);
65
66     FeatureSet getRemainingFeatures();
67
68 protected:
69     fvec_t *m_ibuf;
70     fvec_t *m_onset;
71 #ifdef HAVE_AUBIO4
72     aubio_onset_t *m_onsetdet;
73     OnsetType m_onsettype;
74     float m_minioi;
75 #else
76     cvec_t *m_fftgrain;
77     aubio_pvoc_t *m_pv;
78     aubio_pickpeak_t *m_peakpick;
79     aubio_onsetdetection_t *m_onsetdet;
80     aubio_onsetdetection_type m_onsettype;
81     size_t m_channelCount;
82 #endif
83     float m_silence;
84     float m_threshold;
85     size_t m_stepSize;
86     size_t m_blockSize;
87     Vamp::RealTime m_delay;
88     Vamp::RealTime m_lastOnset;
89 };
90
91 #endif