diff base/Pitch.cpp @ 912:2175c2ebd5c6 tonioni

Merge from default branch
author Chris Cannam
date Wed, 14 May 2014 09:58:07 +0100
parents 451f7f3ab6e7
children d1ce7a4a920b
line wrap: on
line diff
--- a/base/Pitch.cpp	Sat Apr 26 22:22:19 2014 +0100
+++ b/base/Pitch.cpp	Wed May 14 09:58:07 2014 +0100
@@ -101,7 +101,13 @@
 		     float centsOffset,
 		     bool useFlats)
 {
-    int octave = -2;
+    int baseOctave = Preferences::getInstance()->getOctaveOfLowestMIDINote();
+    int octave = baseOctave;
+
+    // Note, this only gets the right octave number at octave
+    // boundaries because Cb is enharmonic with B (not B#) and B# is
+    // enharmonic with C (not Cb). So neither B# nor Cb will be
+    // spelled from a MIDI pitch + flats flag in isolation.
 
     if (midiPitch < 0) {
 	while (midiPitch < 0) {
@@ -109,7 +115,7 @@
 	    --octave;
 	}
     } else {
-	octave = midiPitch / 12 - 2;
+	octave = midiPitch / 12 + baseOctave;
     }
 
     QString plain = (useFlats ? flatNotes : notes)[midiPitch % 12].arg(octave);