Mercurial > hg > tuning-difference
comparison src/TuningDifference.h @ 21:d660db57e902
Rearrange code, include subrepo etc
author | Chris Cannam |
---|---|
date | Thu, 05 Feb 2015 10:13:31 +0000 |
parents | chroma-compare-plugin/TuningDifference.h@9c5ec36c223e |
children | 409ff482cb30 |
comparison
equal
deleted
inserted
replaced
20:331a520cdadb | 21:d660db57e902 |
---|---|
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 TUNING_DIFFERENCE_H | |
14 #define 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 TuningDifference : public Vamp::Plugin | |
26 { | |
27 public: | |
28 TuningDifference(float inputSampleRate); | |
29 virtual ~TuningDifference(); | |
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_bpo; | |
67 std::unique_ptr<Chromagram> m_refChroma; | |
68 TFeature m_refTotals; | |
69 TFeature m_refFeature; | |
70 Signal m_other; | |
71 int m_blockSize; | |
72 int m_frameCount; | |
73 | |
74 Chromagram::Parameters paramsForTuningFrequency(double hz) const; | |
75 TFeature computeFeatureFromTotals(const TFeature &totals) const; | |
76 TFeature computeFeatureFromSignal(const Signal &signal, double hz) const; | |
77 double featureDistance(const TFeature &other, int rotation = 0) const; | |
78 int findBestRotation(const TFeature &other) const; | |
79 std::pair<int, double> findFineFrequency(int coarseCents, double coarseScore); | |
80 | |
81 mutable std::map<string, int> m_outputs; | |
82 }; | |
83 | |
84 | |
85 #endif |