Mercurial > hg > vamp-tempogram
comparison TempogramPlugin.h @ 14:c11367df624d
* Renamed NoveltyCurve.* and Spectrogram.* to $(Name)Processor.*
* Aligned novelty curve with audio - when performing FIRFilter::process(params), take inputLength after group delay.
* Removed trail of Spectrogram.
* General tidying!
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 14 Aug 2014 10:31:49 +0100 |
parents | Tempogram.h@7680cc4c0073 |
children | 89bc9e5199d7 |
comparison
equal
deleted
inserted
replaced
13:7680cc4c0073 | 14:c11367df624d |
---|---|
1 | |
2 // This is a skeleton file for use in creating your own plugin | |
3 // libraries. Replace MyPlugin and myPlugin throughout with the name | |
4 // of your first plugin class, and fill in the gaps as appropriate. | |
5 | |
6 //* Should I use initialiseForGRF()? I generally think it's nicer to initialise stuff before processing. It just means that for some reason if somebody needs to process quickly (and have preparation time before) it's a bit easier on the load. | |
7 //* I've taken this approach with NoveltyCurve, Spectrogram and FIRFilter too. Is this a good approach? | |
8 //* The names "cleanUpForGRF()" and "initialise...()" are horrible... | |
9 //* The "m_..." variable name thing (I've been quite inconsitent with that) | |
10 //* Using size_t and not unsigned int? | |
11 //* In Tempogram.h, should the protected methods be private? | |
12 //* NoveltyCurve::NoveltyCurve() calls initialise(). May be overdetermined with amount of info? i.e., constructor takes parameters fftLength, numberOfBlocks... these are dimensions of vector< vector<float> >spectrogram. | |
13 //* When to use function() const? | |
14 //* spectrogram continues for too long? see tempogram output | |
15 //* should WindowFunction::hanning be static? Justification: no initialisation needed (i.e., no need for a constructor!). | |
16 | |
17 | |
18 // Remember to use a different guard symbol in each header! | |
19 #ifndef _TEMPOGRAM_H_ | |
20 #define _TEMPOGRAM_H_ | |
21 | |
22 #include <vamp-sdk/Plugin.h> | |
23 #include "FIRFilter.h" | |
24 #include "WindowFunction.h" | |
25 #include "NoveltyCurveProcessor.h" | |
26 #include "SpectrogramProcessor.h" | |
27 #include <vamp-sdk/FFT.h> | |
28 | |
29 #include <cmath> | |
30 #include <fstream> | |
31 #include <cassert> | |
32 #include <string> | |
33 | |
34 using std::string; | |
35 using std::vector; | |
36 | |
37 class TempogramPlugin : public Vamp::Plugin | |
38 { | |
39 public: | |
40 TempogramPlugin(float inputSampleRate); | |
41 virtual ~TempogramPlugin(); | |
42 | |
43 string getIdentifier() const; | |
44 string getName() const; | |
45 string getDescription() const; | |
46 string getMaker() const; | |
47 int getPluginVersion() const; | |
48 string getCopyright() const; | |
49 | |
50 InputDomain getInputDomain() const; | |
51 size_t getPreferredBlockSize() const; | |
52 size_t getPreferredStepSize() const; | |
53 size_t getMinChannelCount() const; | |
54 size_t getMaxChannelCount() const; | |
55 | |
56 ParameterList getParameterDescriptors() const; | |
57 float getParameter(string identifier) const; | |
58 void setParameter(string identifier, float value); | |
59 | |
60 ProgramList getPrograms() const; | |
61 string getCurrentProgram() const; | |
62 void selectProgram(string name); | |
63 | |
64 OutputList getOutputDescriptors() const; | |
65 | |
66 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | |
67 void reset(); | |
68 | |
69 FeatureSet process(const float *const *inputBuffers, | |
70 Vamp::RealTime timestamp); | |
71 | |
72 FeatureSet getRemainingFeatures(); | |
73 | |
74 protected: | |
75 // plugin-specific data and methods go here | |
76 size_t m_blockSize; | |
77 size_t m_stepSize; | |
78 float m_compressionConstant; | |
79 SpectrogramTransposed m_spectrogram; //spectrogram data | |
80 vector<float> m_noveltyCurve; //novelty curve data | |
81 float m_minDB; | |
82 | |
83 void cleanup(); //used to release anything allocated in initialise() | |
84 string floatToString(float value) const; | |
85 void updateBPMParameters(); | |
86 | |
87 //FFT params for noveltyCurve -> tempogra | |
88 float m_log2WindowLength; | |
89 size_t m_windowLength; | |
90 float m_log2FftLength; | |
91 size_t m_fftLength; | |
92 float m_log2HopSize; | |
93 size_t m_hopSize; | |
94 | |
95 float m_minBPM; // tempogram output bin range min | |
96 float m_maxBPM; // tempogram output bin range max | |
97 unsigned int m_minBin; | |
98 unsigned int m_maxBin; | |
99 | |
100 vector<Vamp::RealTime> ncTimestamps; | |
101 }; | |
102 | |
103 | |
104 #endif |