diff base/Pitch.cpp @ 433:ad4911230a66

* When displaying an absolute pitch range (number of semitones + number of cents) with a non-negative number of semitones, ensure that the number of cents is also non-negative. e.g. prefer 1+76c over 2-24c. In response to request from Craig Sapp
author Chris Cannam
date Wed, 02 Jul 2008 08:46:47 +0000
parents 0a44caddd9fe
children bdc9bb371a9f
line wrap: on
line diff
--- a/base/Pitch.cpp	Thu Jun 26 12:41:23 2008 +0000
+++ b/base/Pitch.cpp	Wed Jul 02 08:46:47 2008 +0000
@@ -135,6 +135,19 @@
 QString
 Pitch::getLabelForPitchRange(int semis, float cents)
 {
+    if (semis > 0) {
+        while (cents < 0.f) {
+            --semis;
+            cents += 100.f;
+        }
+    }
+    if (semis < 0) {
+        while (cents > 0.f) {
+            ++semis;
+            cents -= 100.f;
+        }
+    }
+
     int ic = lrintf(cents);
 
     if (ic == 0) {