Mercurial > hg > tuning-difference
diff 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 |
line wrap: on
line diff
--- a/src/TuningDifference.h Thu Jul 11 09:19:21 2019 +0100 +++ b/src/TuningDifference.h Thu Jul 11 09:58:56 2019 +0100 @@ -13,9 +13,11 @@ #ifndef TUNING_DIFFERENCE_H #define TUNING_DIFFERENCE_H -// This plugin is a thin wrapper around a BulkTuningDifference with -// only two channels -#include "BulkTuningDifference.h" +#include <vamp-sdk/Plugin.h> + +#include <cq/Chromagram.h> + +#include <memory> using std::string; using std::vector; @@ -58,9 +60,37 @@ FeatureSet getRemainingFeatures(); protected: - BulkTuningDifference m_bulk; + typedef vector<float> Signal; + typedef vector<double> TFeature; + + int m_channelCount; + int m_bpo; + int m_blockSize; + int m_frameCount; + float m_maxDuration; + int m_maxSemis; + bool m_fineTuning; + + std::unique_ptr<Chromagram> m_refChroma; + TFeature m_refTotals; + std::map<int, TFeature> m_refFeatures; // map from cents-offset to feature + Signal m_reference; // we have to retain this when fine-tuning is enabled + std::vector<std::shared_ptr<Chromagram>> m_otherChroma; + std::vector<TFeature> m_otherTotals; + + Chromagram::Parameters paramsForTuningFrequency(double hz) const; + TFeature computeFeatureFromTotals(const TFeature &totals) const; + TFeature computeFeatureFromSignal(const Signal &signal, double hz) const; + void rotateFeature(TFeature &feature, int rotation) const; + double featureDistance(const TFeature &ref, const TFeature &other, + int rotation) const; + int findBestRotation(const TFeature &ref, const TFeature &other) const; + std::pair<int, double> findFineFrequency(const TFeature &rotated, + int coarseCents); + void getRemainingFeaturesForChannel(int channel, FeatureSet &fs); mutable std::map<string, int> m_outputs; }; + #endif