diff base/Pitch.cpp @ 141:4f26f623a8bc

* Finish preferences dialog (as far as it's going at the moment) and connect it up * Fix Parzen window shape (was triangular!) * Various fixes to spectrogram draw coordinates in smoothing mode etc * Draw C keys in grey on the piano
author Chris Cannam
date Fri, 21 Jul 2006 16:03:42 +0000
parents d397ea0a79f5
children e412f65884ee
line wrap: on
line diff
--- a/base/Pitch.cpp	Thu Jul 20 16:51:20 2006 +0000
+++ b/base/Pitch.cpp	Fri Jul 21 16:03:42 2006 +0000
@@ -14,6 +14,7 @@
 */
 
 #include "Pitch.h"
+#include "Preferences.h"
 
 #include <cmath>
 
@@ -22,6 +23,9 @@
 			    float centsOffset,
 			    float concertA)
 {
+    if (concertA <= 0.0) {
+        concertA = Preferences::getInstance()->getTuningFrequency();
+    }
     float p = float(midiPitch) + (centsOffset / 100);
     return concertA * powf(2.0, (p - 69.0) / 12.0);
 }
@@ -31,6 +35,9 @@
 			    float *centsOffsetReturn,
 			    float concertA)
 {
+    if (concertA <= 0.0) {
+        concertA = Preferences::getInstance()->getTuningFrequency();
+    }
     float p = 12.0 * (log(frequency / (concertA / 2.0)) / log(2.0)) + 57.0;
 
     int midiPitch = int(p + 0.00001);
@@ -86,6 +93,9 @@
 				 float concertA,
 				 bool useFlats)
 {
+    if (concertA <= 0.0) {
+        concertA = Preferences::getInstance()->getTuningFrequency();
+    }
     float centsOffset = 0.0;
     int midiPitch = getPitchForFrequency(frequency, &centsOffset, concertA);
     return getPitchLabel(midiPitch, centsOffset, useFlats);