annotate TempogramPlugin.h @ 23:7d36c742a183

* Tidying in TempogramPlugin.cpp
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Tue, 19 Aug 2014 17:40:10 +0100
parents 99380ba63be6
children fe23998968b4
rev   line source
c@0 1
c@0 2 // This is a skeleton file for use in creating your own plugin
c@0 3 // libraries. Replace MyPlugin and myPlugin throughout with the name
c@0 4 // of your first plugin class, and fill in the gaps as appropriate.
c@0 5
c@9 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.
c@9 7 //* I've taken this approach with NoveltyCurve, Spectrogram and FIRFilter too. Is this a good approach?
c@9 8 //* The names "cleanUpForGRF()" and "initialise...()" are horrible...
c@9 9 //* The "m_..." variable name thing (I've been quite inconsitent with that)
c@9 10 //* Using size_t and not unsigned int?
c@9 11 //* In Tempogram.h, should the protected methods be private?
c@9 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.
c@9 13 //* When to use function() const?
c@9 14 //* spectrogram continues for too long? see tempogram output
c@9 15 //* should WindowFunction::hanning be static? Justification: no initialisation needed (i.e., no need for a constructor!).
c@9 16
c@0 17
c@0 18 // Remember to use a different guard symbol in each header!
c@0 19 #ifndef _TEMPOGRAM_H_
c@0 20 #define _TEMPOGRAM_H_
c@0 21
c@0 22 #include <vamp-sdk/Plugin.h>
c@7 23 #include "FIRFilter.h"
c@7 24 #include "WindowFunction.h"
c@14 25 #include "NoveltyCurveProcessor.h"
c@14 26 #include "SpectrogramProcessor.h"
c@7 27 #include <vamp-sdk/FFT.h>
c@9 28
c@7 29 #include <cmath>
c@7 30 #include <fstream>
c@9 31 #include <cassert>
c@9 32 #include <string>
c@0 33
c@0 34 using std::string;
c@0 35 using std::vector;
c@0 36
c@18 37 typedef Spectrogram Tempogram;
c@18 38
c@14 39 class TempogramPlugin : public Vamp::Plugin
c@0 40 {
c@0 41 public:
c@14 42 TempogramPlugin(float inputSampleRate);
c@14 43 virtual ~TempogramPlugin();
c@0 44
c@0 45 string getIdentifier() const;
c@0 46 string getName() const;
c@0 47 string getDescription() const;
c@0 48 string getMaker() const;
c@0 49 int getPluginVersion() const;
c@0 50 string getCopyright() const;
c@0 51
c@0 52 InputDomain getInputDomain() const;
c@0 53 size_t getPreferredBlockSize() const;
c@0 54 size_t getPreferredStepSize() const;
c@0 55 size_t getMinChannelCount() const;
c@0 56 size_t getMaxChannelCount() const;
c@0 57
c@0 58 ParameterList getParameterDescriptors() const;
c@0 59 float getParameter(string identifier) const;
c@0 60 void setParameter(string identifier, float value);
c@0 61
c@0 62 ProgramList getPrograms() const;
c@0 63 string getCurrentProgram() const;
c@0 64 void selectProgram(string name);
c@0 65
c@0 66 OutputList getOutputDescriptors() const;
c@9 67
c@0 68 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
c@0 69 void reset();
c@0 70
c@0 71 FeatureSet process(const float *const *inputBuffers,
c@0 72 Vamp::RealTime timestamp);
c@0 73
c@0 74 FeatureSet getRemainingFeatures();
c@0 75
c@0 76 protected:
c@0 77 // plugin-specific data and methods go here
c@18 78 size_t m_inputBlockSize;
c@18 79 size_t m_inputStepSize;
c@22 80 Spectrogram m_spectrogram; //spectrogram data
c@9 81
c@18 82 //Novelty Curve specific parameters
c@19 83 float m_noveltyCurveMinDB;
c@18 84 float m_noveltyCurveCompressionConstant;
c@9 85
c@18 86 //Tempogram specific parameters
c@18 87 float m_tempogramLog2WindowLength;
c@18 88 size_t m_tempogramWindowLength;
c@18 89 float m_tempogramLog2FftLength;
c@18 90 size_t m_tempogramFftLength;
c@18 91 float m_tempogramLog2HopSize;
c@18 92 size_t m_tempogramHopSize;
c@0 93
c@18 94 float m_tempogramMinBPM; // tempogram output bin range min
c@18 95 float m_tempogramMaxBPM; // tempogram output bin range max
c@18 96 unsigned int m_tempogramMinBin;
c@18 97 unsigned int m_tempogramMaxBin;
c@18 98
c@18 99 //Cyclic tempogram parameters
c@18 100 float m_cyclicTempogramMinBPM;
c@18 101 int m_cyclicTempogramNumberOfOctaves;
c@18 102 int m_cyclicTempogramOctaveDivider;
c@19 103
c@19 104 string floatToString(float value) const;
c@22 105 vector< vector<unsigned int> > calculateTempogramNearestNeighbourLogBins() const;
c@22 106 unsigned int bpmToBin(const float &bpm) const;
c@21 107 float binToBPM (const int &bin) const;
c@21 108 bool handleParameterValues();
c@0 109 };
c@0 110
c@0 111
c@0 112 #endif