changeset 43:2ef9c5d744ab

Couple more parameters
author Chris Cannam
date Thu, 16 May 2019 15:56:07 +0100
parents 475571f398fe
children dcfae9ef87de
files src/TuningDifference.cpp src/TuningDifference.h
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/TuningDifference.cpp	Wed May 15 17:52:47 2019 +0100
+++ b/src/TuningDifference.cpp	Thu May 16 15:56:07 2019 +0100
@@ -36,7 +36,8 @@
     return pitchToFrequency(69, cents, 440.);
 }
 
-static float defaultMaxDuration = 0;
+static float defaultMaxDuration = 0.f;
+static int defaultMaxSemis = 4;
 
 TuningDifference::TuningDifference(float inputSampleRate) :
     Plugin(inputSampleRate),
@@ -44,7 +45,8 @@
     m_refChroma(new Chromagram(paramsForTuningFrequency(440.))),
     m_blockSize(0),
     m_frameCount(0),
-    m_maxDuration(defaultMaxDuration)
+    m_maxDuration(defaultMaxDuration),
+    m_maxSemis(defaultMaxSemis)
 {
 }
 
@@ -67,7 +69,6 @@
 string
 TuningDifference::getDescription() const
 {
-    // Return something helpful here!
     return "Estimate the tuning frequency of a recording, by comparing it to another recording of the same music whose tuning frequency is known";
 }
 
@@ -143,9 +144,17 @@
     desc.unit = "s";
     list.push_back(desc);
     
-    //!!! parameter: max search range
-    //!!! parameter: fine search precision
-    //!!! parameter: max amount of audio to listen to
+    desc.identifier = "maxrange";
+    desc.name = "Maximum range in semitones";
+    desc.description = "The maximum difference in semitones that will be searched.";
+    desc.minValue = 1;
+    desc.maxValue = 11;
+    desc.defaultValue = defaultMaxSemis;
+    desc.isQuantized = true;
+    desc.quantizeStep = 1;
+    desc.unit = "semitones";
+    list.push_back(desc);
+
     return list;
 }
 
@@ -410,8 +419,7 @@
 {
     map<double, int> dists;
 
-    int maxSemis = 4;
-    int maxRotation = (m_bpo * maxSemis) / 12;
+    int maxRotation = (m_bpo * m_maxSemis) / 12;
 
     for (int r = -maxRotation; r <= maxRotation; ++r) {
 	double dist = featureDistance(other, r);
--- a/src/TuningDifference.h	Wed May 15 17:52:47 2019 +0100
+++ b/src/TuningDifference.h	Thu May 16 15:56:07 2019 +0100
@@ -71,6 +71,7 @@
     int m_blockSize;
     int m_frameCount;
     float m_maxDuration;
+    int m_maxSemis;
 
     Chromagram::Parameters paramsForTuningFrequency(double hz) const;
     TFeature computeFeatureFromTotals(const TFeature &totals) const;