annotate plugins/SimilarityPlugin.h @ 266:d04675d44928 tip master

Refer to SDK from Github
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 02 Jun 2021 14:41:26 +0100
parents f96ea0e4b475
children
rev   line source
c@41 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@41 2
c@41 3 /*
c@41 4 * SimilarityPlugin.h
c@41 5 *
c@41 6 * Copyright 2008 Centre for Digital Music, Queen Mary, University of London.
c@135 7
c@135 8 This program is free software; you can redistribute it and/or
c@135 9 modify it under the terms of the GNU General Public License as
c@135 10 published by the Free Software Foundation; either version 2 of the
c@135 11 License, or (at your option) any later version. See the file
c@135 12 COPYING included with this distribution for more information.
c@41 13 */
c@41 14
c@41 15 #ifndef _SIMILARITY_PLUGIN_H_
c@41 16 #define _SIMILARITY_PLUGIN_H_
c@41 17
c@41 18 #include <vamp-sdk/Plugin.h>
c@41 19 #include <vamp-sdk/RealTime.h>
c@41 20
c@47 21 #include <vector>
c@47 22 #include <deque>
c@47 23
c@41 24 class MFCC;
c@42 25 class Chromagram;
c@41 26 class Decimator;
c@41 27
c@41 28 class SimilarityPlugin : public Vamp::Plugin
c@41 29 {
c@41 30 public:
c@41 31 SimilarityPlugin(float inputSampleRate);
c@41 32 virtual ~SimilarityPlugin();
c@41 33
c@41 34 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
c@41 35 void reset();
c@41 36
c@41 37 std::string getIdentifier() const;
c@41 38 std::string getName() const;
c@41 39 std::string getDescription() const;
c@41 40 std::string getMaker() const;
c@41 41 int getPluginVersion() const;
c@41 42 std::string getCopyright() const;
c@41 43
c@41 44 size_t getPreferredStepSize() const;
c@41 45 size_t getPreferredBlockSize() const;
c@41 46 InputDomain getInputDomain() const { return TimeDomain; }
c@41 47
c@41 48 size_t getMinChannelCount() const;
c@41 49 size_t getMaxChannelCount() const;
c@41 50
c@41 51 SimilarityPlugin::ParameterList getParameterDescriptors() const;
c@41 52 float getParameter(std::string param) const;
c@41 53 void setParameter(std::string param, float value);
c@41 54
c@41 55 OutputList getOutputDescriptors() const;
c@41 56
c@41 57 FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp);
c@41 58
c@41 59 FeatureSet getRemainingFeatures();
c@41 60
c@41 61 protected:
c@41 62 int getDecimationFactor() const;
c@41 63
c@42 64 enum Type {
c@42 65 TypeMFCC,
c@42 66 TypeChroma
c@42 67 };
c@42 68
c@42 69 void calculateBlockSize() const;
c@47 70 bool needRhythm() const { return m_rhythmWeighting > m_noRhythm; }
c@47 71 bool needTimbre() const { return m_rhythmWeighting < m_allRhythm; }
c@42 72
c@42 73 Type m_type;
c@41 74 MFCC *m_mfcc;
c@47 75 MFCC *m_rhythmfcc;
c@42 76 Chromagram *m_chromagram;
c@41 77 Decimator *m_decimator;
c@42 78 int m_featureColumnSize;
c@47 79 float m_rhythmWeighting;
c@47 80 float m_rhythmClipDuration;
c@47 81 float m_rhythmClipOrigin;
c@47 82 int m_rhythmClipFrameSize;
c@47 83 int m_rhythmClipFrames;
c@47 84 int m_rhythmColumnSize;
c@178 85 mutable int m_blockSize; // before decimation
c@178 86 int m_fftSize; // after decimation
c@41 87 int m_channels;
c@47 88 int m_processRate;
c@44 89 int m_frameNo;
c@47 90 bool m_done;
c@47 91
c@47 92 static const float m_noRhythm;
c@47 93 static const float m_allRhythm;
c@44 94
c@44 95 std::vector<int> m_lastNonEmptyFrame; // per channel
c@60 96 std::vector<int> m_emptyFrameCount; // per channel
c@41 97
c@43 98 mutable int m_distanceMatrixOutput;
c@43 99 mutable int m_distanceVectorOutput;
c@44 100 mutable int m_sortedVectorOutput;
c@43 101 mutable int m_meansOutput;
c@43 102 mutable int m_variancesOutput;
c@47 103 mutable int m_beatSpectraOutput;
c@43 104
c@42 105 typedef std::vector<double> FeatureColumn;
c@42 106 typedef std::vector<FeatureColumn> FeatureMatrix;
c@42 107 typedef std::vector<FeatureMatrix> FeatureMatrixSet;
c@41 108
c@47 109 typedef std::deque<FeatureColumn> FeatureColumnQueue;
c@47 110 typedef std::vector<FeatureColumnQueue> FeatureQueueSet;
c@47 111
c@42 112 FeatureMatrixSet m_values;
c@47 113 FeatureQueueSet m_rhythmValues;
c@47 114
c@47 115 FeatureMatrix calculateTimbral(FeatureSet &returnFeatures);
c@47 116 FeatureMatrix calculateRhythmic(FeatureSet &returnFeatures);
c@47 117 double getDistance(const FeatureMatrix &timbral,
c@47 118 const FeatureMatrix &rhythmic,
c@47 119 int i, int j);
c@41 120 };
c@41 121
c@41 122 #endif
c@41 123