annotate Tempogram.h @ 13:7680cc4c0073

* Tidying - made length of array variables type size_t and for loops unsigned int, where index > 0. * Window length parameter is now a dropdown box.
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Wed, 13 Aug 2014 14:18:00 +0100
parents 09fb76606b2b
children
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@7 25 #include "NoveltyCurve.h"
c@9 26 #include "Spectrogram.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@0 37 class Tempogram : public Vamp::Plugin
c@0 38 {
c@0 39 public:
c@0 40 Tempogram(float inputSampleRate);
c@0 41 virtual ~Tempogram();
c@0 42
c@0 43 string getIdentifier() const;
c@0 44 string getName() const;
c@0 45 string getDescription() const;
c@0 46 string getMaker() const;
c@0 47 int getPluginVersion() const;
c@0 48 string getCopyright() const;
c@0 49
c@0 50 InputDomain getInputDomain() const;
c@0 51 size_t getPreferredBlockSize() const;
c@0 52 size_t getPreferredStepSize() const;
c@0 53 size_t getMinChannelCount() const;
c@0 54 size_t getMaxChannelCount() const;
c@0 55
c@0 56 ParameterList getParameterDescriptors() const;
c@0 57 float getParameter(string identifier) const;
c@0 58 void setParameter(string identifier, float value);
c@0 59
c@0 60 ProgramList getPrograms() const;
c@0 61 string getCurrentProgram() const;
c@0 62 void selectProgram(string name);
c@0 63
c@0 64 OutputList getOutputDescriptors() const;
c@9 65
c@0 66 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
c@0 67 void reset();
c@0 68
c@0 69 FeatureSet process(const float *const *inputBuffers,
c@0 70 Vamp::RealTime timestamp);
c@0 71
c@0 72 FeatureSet getRemainingFeatures();
c@0 73
c@0 74 protected:
c@0 75 // plugin-specific data and methods go here
c@0 76 size_t m_blockSize;
c@1 77 size_t m_stepSize;
c@13 78 float m_compressionConstant;
c@13 79 vector< vector<float> > m_spectrogram; //spectrogram data
c@13 80 vector<float> m_noveltyCurve; //novelty curve data
c@13 81 float m_minDB;
c@0 82
c@9 83 void cleanup(); //used to release anything allocated in initialise()
c@9 84 string floatToString(float value) const;
c@9 85 void updateBPMParameters();
c@9 86
c@9 87 //FFT params for noveltyCurve -> tempogra
c@13 88 int m_log2WindowLength;
c@13 89 size_t m_windowLength;
c@13 90 size_t m_fftLength;
c@13 91 size_t m_hopSize;
c@9 92
c@13 93 float m_minBPM; // tempogram output bin range min
c@13 94 float m_maxBPM; // tempogram output bin range max
c@13 95 unsigned int m_minBin;
c@13 96 unsigned int m_maxBin;
c@0 97
c@13 98 unsigned int m_numberOfBlocks;
c@0 99
c@0 100 vector<Vamp::RealTime> ncTimestamps;
c@0 101 };
c@0 102
c@0 103
c@0 104 #endif