changeset 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 113cf8781bd1
children 5a13b76cd034
files base/Pitch.cpp
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
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) {