Mercurial > hg > tuning-difference
comparison src/BulkTuningDifference.h @ 47:f28b34e7ce8d
Add BulkTuningDifference plugin
author | Chris Cannam |
---|---|
date | Tue, 09 Jul 2019 16:14:19 +0100 |
parents | |
children | 69ab9a6e7aee |
comparison
equal
deleted
inserted
replaced
46:1623751c4549 | 47:f28b34e7ce8d |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Centre for Digital Music, Queen Mary University of London. | |
5 | |
6 This program is free software; you can redistribute it and/or | |
7 modify it under the terms of the GNU General Public License as | |
8 published by the Free Software Foundation; either version 2 of the | |
9 License, or (at your option) any later version. See the file | |
10 COPYING included with this distribution for more information. | |
11 */ | |
12 | |
13 #ifndef BULK_TUNING_DIFFERENCE_H | |
14 #define BULK_TUNING_DIFFERENCE_H | |
15 | |
16 #include <vamp-sdk/Plugin.h> | |
17 | |
18 #include <cq/Chromagram.h> | |
19 | |
20 #include <memory> | |
21 | |
22 using std::string; | |
23 using std::vector; | |
24 | |
25 class BulkTuningDifference : public Vamp::Plugin | |
26 { | |
27 public: | |
28 BulkTuningDifference(float inputSampleRate); | |
29 virtual ~BulkTuningDifference(); | |
30 | |
31 string getIdentifier() const; | |
32 string getName() const; | |
33 string getDescription() const; | |
34 string getMaker() const; | |
35 int getPluginVersion() const; | |
36 string getCopyright() const; | |
37 | |
38 InputDomain getInputDomain() const; | |
39 size_t getPreferredBlockSize() const; | |
40 size_t getPreferredStepSize() const; | |
41 size_t getMinChannelCount() const; | |
42 size_t getMaxChannelCount() const; | |
43 | |
44 ParameterList getParameterDescriptors() const; | |
45 float getParameter(string identifier) const; | |
46 void setParameter(string identifier, float value); | |
47 | |
48 ProgramList getPrograms() const; | |
49 string getCurrentProgram() const; | |
50 void selectProgram(string name); | |
51 | |
52 OutputList getOutputDescriptors() const; | |
53 | |
54 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | |
55 void reset(); | |
56 | |
57 FeatureSet process(const float *const *inputBuffers, | |
58 Vamp::RealTime timestamp); | |
59 | |
60 FeatureSet getRemainingFeatures(); | |
61 | |
62 protected: | |
63 typedef vector<float> Signal; | |
64 typedef vector<double> TFeature; | |
65 | |
66 int m_channelCount; | |
67 int m_bpo; | |
68 std::unique_ptr<Chromagram> m_refChroma; | |
69 TFeature m_refTotals; | |
70 TFeature m_refFeature; | |
71 std::vector<Signal> m_others; | |
72 int m_blockSize; | |
73 int m_frameCount; | |
74 float m_maxDuration; | |
75 int m_maxSemis; | |
76 bool m_fineTuning; | |
77 | |
78 Chromagram::Parameters paramsForTuningFrequency(double hz) const; | |
79 TFeature computeFeatureFromTotals(const TFeature &totals) const; | |
80 TFeature computeFeatureFromSignal(const Signal &signal, double hz) const; | |
81 void rotateFeature(TFeature &feature, int rotation) const; | |
82 double featureDistance(const TFeature &other, int rotation = 0) const; | |
83 int findBestRotation(const TFeature &other) const; | |
84 std::pair<int, double> findFineFrequency(int channel, int coarseCents); | |
85 void getRemainingFeaturesForChannel(int channel, FeatureSet &fs); | |
86 | |
87 mutable std::map<string, int> m_outputs; | |
88 }; | |
89 | |
90 | |
91 #endif |