comparison src/TuningDifference.h @ 55:7bdcc40deebe

Revert to having only a single plugin - I think this should be sufficiently backward compatible after all
author Chris Cannam
date Thu, 11 Jul 2019 09:58:56 +0100
parents src/BulkTuningDifference.h@69ab9a6e7aee
children
comparison
equal deleted inserted replaced
54:d96eb87060c6 55:7bdcc40deebe
11 */ 11 */
12 12
13 #ifndef TUNING_DIFFERENCE_H 13 #ifndef TUNING_DIFFERENCE_H
14 #define TUNING_DIFFERENCE_H 14 #define TUNING_DIFFERENCE_H
15 15
16 // This plugin is a thin wrapper around a BulkTuningDifference with 16 #include <vamp-sdk/Plugin.h>
17 // only two channels 17
18 #include "BulkTuningDifference.h" 18 #include <cq/Chromagram.h>
19
20 #include <memory>
19 21
20 using std::string; 22 using std::string;
21 using std::vector; 23 using std::vector;
22 24
23 class TuningDifference : public Vamp::Plugin 25 class TuningDifference : public Vamp::Plugin
56 Vamp::RealTime timestamp); 58 Vamp::RealTime timestamp);
57 59
58 FeatureSet getRemainingFeatures(); 60 FeatureSet getRemainingFeatures();
59 61
60 protected: 62 protected:
61 BulkTuningDifference m_bulk; 63 typedef vector<float> Signal;
64 typedef vector<double> TFeature;
65
66 int m_channelCount;
67 int m_bpo;
68 int m_blockSize;
69 int m_frameCount;
70 float m_maxDuration;
71 int m_maxSemis;
72 bool m_fineTuning;
73
74 std::unique_ptr<Chromagram> m_refChroma;
75 TFeature m_refTotals;
76 std::map<int, TFeature> m_refFeatures; // map from cents-offset to feature
77 Signal m_reference; // we have to retain this when fine-tuning is enabled
78 std::vector<std::shared_ptr<Chromagram>> m_otherChroma;
79 std::vector<TFeature> m_otherTotals;
80
81 Chromagram::Parameters paramsForTuningFrequency(double hz) const;
82 TFeature computeFeatureFromTotals(const TFeature &totals) const;
83 TFeature computeFeatureFromSignal(const Signal &signal, double hz) const;
84 void rotateFeature(TFeature &feature, int rotation) const;
85 double featureDistance(const TFeature &ref, const TFeature &other,
86 int rotation) const;
87 int findBestRotation(const TFeature &ref, const TFeature &other) const;
88 std::pair<int, double> findFineFrequency(const TFeature &rotated,
89 int coarseCents);
90 void getRemainingFeaturesForChannel(int channel, FeatureSet &fs);
62 91
63 mutable std::map<string, int> m_outputs; 92 mutable std::map<string, int> m_outputs;
64 }; 93 };
65 94
95
66 #endif 96 #endif