annotate TempogramPlugin.h @ 47:cb79f27f0748

Clamp cyclic tempogram min and max BPM to the BPM equivalents of the actual underlying min and max tempogram bins, rather than the "input" min and max BPM (fixed root cause of #1054)
author Chris Cannam
date Mon, 29 Sep 2014 16:20:16 +0100
parents 4cf2d163127b
children b27e42b68c61
rev   line source
Chris@43 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@0 2
Chris@43 3 /*
Chris@43 4 Vamp Tempogram Plugin
Chris@43 5 Carl Bussey, Centre for Digital Music, Queen Mary University of London
Chris@43 6 Copyright 2014 Queen Mary University of London.
Chris@43 7
Chris@43 8 This program is free software; you can redistribute it and/or
Chris@43 9 modify it under the terms of the GNU General Public License as
Chris@43 10 published by the Free Software Foundation; either version 2 of the
Chris@43 11 License, or (at your option) any later version. See the file
Chris@43 12 COPYING included with this distribution for more information.
Chris@43 13 */
c@0 14
c@9 15 //* 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 16 //* I've taken this approach with NoveltyCurve, Spectrogram and FIRFilter too. Is this a good approach?
c@9 17 //* The names "cleanUpForGRF()" and "initialise...()" are horrible...
c@9 18 //* The "m_..." variable name thing (I've been quite inconsitent with that)
c@9 19 //* Using size_t and not unsigned int?
c@9 20 //* In Tempogram.h, should the protected methods be private?
c@9 21 //* 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 22 //* When to use function() const?
c@9 23 //* spectrogram continues for too long? see tempogram output
c@9 24 //* should WindowFunction::hanning be static? Justification: no initialisation needed (i.e., no need for a constructor!).
c@9 25
c@0 26
c@0 27 // Remember to use a different guard symbol in each header!
c@0 28 #ifndef _TEMPOGRAM_H_
c@0 29 #define _TEMPOGRAM_H_
c@0 30
c@0 31 #include <vamp-sdk/Plugin.h>
c@7 32 #include "FIRFilter.h"
c@7 33 #include "WindowFunction.h"
c@14 34 #include "NoveltyCurveProcessor.h"
c@14 35 #include "SpectrogramProcessor.h"
c@25 36 #include "AutocorrelationProcessor.h"
c@7 37 #include <vamp-sdk/FFT.h>
c@9 38
c@7 39 #include <cmath>
c@7 40 #include <fstream>
c@9 41 #include <cassert>
c@9 42 #include <string>
c@25 43 #include <sstream>
c@25 44 #include <stdexcept>
c@0 45
c@0 46 using std::string;
c@0 47 using std::vector;
c@0 48
c@18 49 typedef Spectrogram Tempogram;
c@18 50
c@14 51 class TempogramPlugin : public Vamp::Plugin
c@0 52 {
c@0 53 public:
c@14 54 TempogramPlugin(float inputSampleRate);
c@14 55 virtual ~TempogramPlugin();
c@0 56
c@0 57 string getIdentifier() const;
c@0 58 string getName() const;
c@0 59 string getDescription() const;
c@0 60 string getMaker() const;
c@0 61 int getPluginVersion() const;
c@0 62 string getCopyright() const;
c@0 63
c@0 64 InputDomain getInputDomain() const;
c@0 65 size_t getPreferredBlockSize() const;
c@0 66 size_t getPreferredStepSize() const;
c@0 67 size_t getMinChannelCount() const;
c@0 68 size_t getMaxChannelCount() const;
c@0 69
c@0 70 ParameterList getParameterDescriptors() const;
c@0 71 float getParameter(string identifier) const;
c@0 72 void setParameter(string identifier, float value);
c@0 73
c@0 74 ProgramList getPrograms() const;
c@0 75 string getCurrentProgram() const;
c@0 76 void selectProgram(string name);
c@0 77
c@0 78 OutputList getOutputDescriptors() const;
c@9 79
c@0 80 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
c@0 81 void reset();
c@0 82
c@0 83 FeatureSet process(const float *const *inputBuffers,
c@0 84 Vamp::RealTime timestamp);
c@0 85
c@0 86 FeatureSet getRemainingFeatures();
c@0 87
c@0 88 protected:
c@0 89 // plugin-specific data and methods go here
c@18 90 size_t m_inputBlockSize;
c@18 91 size_t m_inputStepSize;
c@22 92 Spectrogram m_spectrogram; //spectrogram data
c@9 93
c@18 94 //Novelty Curve specific parameters
c@19 95 float m_noveltyCurveMinDB;
c@29 96 float m_noveltyCurveMinV;
c@18 97 float m_noveltyCurveCompressionConstant;
c@9 98
c@18 99 //Tempogram specific parameters
c@18 100 float m_tempogramLog2WindowLength;
c@18 101 size_t m_tempogramWindowLength;
c@18 102 float m_tempogramLog2FftLength;
c@18 103 size_t m_tempogramFftLength;
c@18 104 float m_tempogramLog2HopSize;
c@18 105 size_t m_tempogramHopSize;
c@0 106
c@18 107 float m_tempogramMinBPM; // tempogram output bin range min
c@18 108 float m_tempogramMaxBPM; // tempogram output bin range max
c@18 109 unsigned int m_tempogramMinBin;
c@18 110 unsigned int m_tempogramMaxBin;
c@28 111 unsigned int m_tempogramMinLag;
c@28 112 unsigned int m_tempogramMaxLag;
c@18 113
c@18 114 //Cyclic tempogram parameters
c@18 115 float m_cyclicTempogramMinBPM;
c@18 116 int m_cyclicTempogramNumberOfOctaves;
c@18 117 int m_cyclicTempogramOctaveDivider;
c@19 118
c@19 119 string floatToString(float value) const;
c@22 120 vector< vector<unsigned int> > calculateTempogramNearestNeighbourLogBins() const;
c@22 121 unsigned int bpmToBin(const float &bpm) const;
c@21 122 float binToBPM (const int &bin) const;
c@21 123 bool handleParameterValues();
c@0 124 };
c@0 125
c@0 126
c@0 127 #endif