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@41
|
7 * All rights reserved.
|
c@41
|
8 */
|
c@41
|
9
|
c@41
|
10 #ifndef _SIMILARITY_PLUGIN_H_
|
c@41
|
11 #define _SIMILARITY_PLUGIN_H_
|
c@41
|
12
|
c@41
|
13 #include <vamp-sdk/Plugin.h>
|
c@41
|
14 #include <vamp-sdk/RealTime.h>
|
c@41
|
15
|
c@47
|
16 #include <vector>
|
c@47
|
17 #include <deque>
|
c@47
|
18
|
c@41
|
19 class MFCC;
|
c@42
|
20 class Chromagram;
|
c@41
|
21 class Decimator;
|
c@41
|
22
|
c@41
|
23 class SimilarityPlugin : public Vamp::Plugin
|
c@41
|
24 {
|
c@41
|
25 public:
|
c@41
|
26 SimilarityPlugin(float inputSampleRate);
|
c@41
|
27 virtual ~SimilarityPlugin();
|
c@41
|
28
|
c@41
|
29 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
|
c@41
|
30 void reset();
|
c@41
|
31
|
c@41
|
32 std::string getIdentifier() const;
|
c@41
|
33 std::string getName() const;
|
c@41
|
34 std::string getDescription() const;
|
c@41
|
35 std::string getMaker() const;
|
c@41
|
36 int getPluginVersion() const;
|
c@41
|
37 std::string getCopyright() const;
|
c@41
|
38
|
c@41
|
39 size_t getPreferredStepSize() const;
|
c@41
|
40 size_t getPreferredBlockSize() const;
|
c@41
|
41 InputDomain getInputDomain() const { return TimeDomain; }
|
c@41
|
42
|
c@41
|
43 size_t getMinChannelCount() const;
|
c@41
|
44 size_t getMaxChannelCount() const;
|
c@41
|
45
|
c@41
|
46 SimilarityPlugin::ParameterList getParameterDescriptors() const;
|
c@41
|
47 float getParameter(std::string param) const;
|
c@41
|
48 void setParameter(std::string param, float value);
|
c@41
|
49
|
c@41
|
50 OutputList getOutputDescriptors() const;
|
c@41
|
51
|
c@41
|
52 FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp);
|
c@41
|
53
|
c@41
|
54 FeatureSet getRemainingFeatures();
|
c@41
|
55
|
c@41
|
56 protected:
|
c@41
|
57 int getDecimationFactor() const;
|
c@41
|
58
|
c@42
|
59 enum Type {
|
c@42
|
60 TypeMFCC,
|
c@42
|
61 TypeChroma
|
c@42
|
62 };
|
c@42
|
63
|
c@42
|
64 void calculateBlockSize() const;
|
c@47
|
65 bool needRhythm() const { return m_rhythmWeighting > m_noRhythm; }
|
c@47
|
66 bool needTimbre() const { return m_rhythmWeighting < m_allRhythm; }
|
c@42
|
67
|
c@42
|
68 Type m_type;
|
c@41
|
69 MFCC *m_mfcc;
|
c@47
|
70 MFCC *m_rhythmfcc;
|
c@42
|
71 Chromagram *m_chromagram;
|
c@41
|
72 Decimator *m_decimator;
|
c@42
|
73 int m_featureColumnSize;
|
c@47
|
74 float m_rhythmWeighting;
|
c@47
|
75 float m_rhythmClipDuration;
|
c@47
|
76 float m_rhythmClipOrigin;
|
c@47
|
77 int m_rhythmClipFrameSize;
|
c@47
|
78 int m_rhythmClipFrames;
|
c@47
|
79 int m_rhythmColumnSize;
|
c@47
|
80 mutable size_t m_blockSize; // before decimation
|
c@47
|
81 size_t m_fftSize; // after decimation
|
c@41
|
82 int m_channels;
|
c@47
|
83 int m_processRate;
|
c@44
|
84 int m_frameNo;
|
c@47
|
85 bool m_done;
|
c@47
|
86
|
c@47
|
87 static const float m_noRhythm;
|
c@47
|
88 static const float m_allRhythm;
|
c@44
|
89
|
c@44
|
90 std::vector<int> m_lastNonEmptyFrame; // per channel
|
c@41
|
91
|
c@43
|
92 mutable int m_distanceMatrixOutput;
|
c@43
|
93 mutable int m_distanceVectorOutput;
|
c@44
|
94 mutable int m_sortedVectorOutput;
|
c@43
|
95 mutable int m_meansOutput;
|
c@43
|
96 mutable int m_variancesOutput;
|
c@47
|
97 mutable int m_beatSpectraOutput;
|
c@43
|
98
|
c@42
|
99 typedef std::vector<double> FeatureColumn;
|
c@42
|
100 typedef std::vector<FeatureColumn> FeatureMatrix;
|
c@42
|
101 typedef std::vector<FeatureMatrix> FeatureMatrixSet;
|
c@41
|
102
|
c@47
|
103 typedef std::deque<FeatureColumn> FeatureColumnQueue;
|
c@47
|
104 typedef std::vector<FeatureColumnQueue> FeatureQueueSet;
|
c@47
|
105
|
c@42
|
106 FeatureMatrixSet m_values;
|
c@47
|
107 FeatureQueueSet m_rhythmValues;
|
c@47
|
108
|
c@47
|
109 FeatureMatrix calculateTimbral(FeatureSet &returnFeatures);
|
c@47
|
110 FeatureMatrix calculateRhythmic(FeatureSet &returnFeatures);
|
c@47
|
111 double getDistance(const FeatureMatrix &timbral,
|
c@47
|
112 const FeatureMatrix &rhythmic,
|
c@47
|
113 int i, int j);
|
c@41
|
114 };
|
c@41
|
115
|
c@41
|
116 #endif
|
c@41
|
117
|