changeset 704:286bd8bb13cc

Record relative pitch in alignment model for display
author Chris Cannam
date Thu, 15 Aug 2019 18:18:46 +0100
parents e4d92aaa689c
children beefce638f91
files framework/Align.cpp
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Align.cpp	Wed Aug 14 13:55:12 2019 +0100
+++ b/framework/Align.cpp	Thu Aug 15 18:18:46 2019 +0100
@@ -408,10 +408,19 @@
     transform.setParameter("minfreq", 250);
 //    transform.setParameter("usechroma", 1);
 
+    int cents = 0;
+    
     if (tuningFrequency != 0.f) {
         transform.setParameter("freq2", tuningFrequency);
+
+        double centsOffset = 0.f;
+        int pitch = Pitch::getPitchForFrequency(tuningFrequency, &centsOffset);
+        cents = int(round((pitch - 69) * 100 + centsOffset));
+        SVCERR << "frequency " << tuningFrequency << " yields cents offset " << centsOffset << " and pitch " << pitch << " -> cents " << cents << endl;
     }
 
+    alignmentModel->setRelativePitch(cents);
+    
     SVDEBUG << "Align::alignModel: Alignment transform step size " << transform.getStepSize() << ", block size " << transform.getBlockSize() << endl;
 
     ModelTransformerFactory *mtf = ModelTransformerFactory::getInstance();