diff base/Pitch.cpp @ 906:654990320867

Merge from 899:bc0ff66102a8
author Chris Cannam
date Wed, 07 May 2014 15:17:51 +0100
parents 451f7f3ab6e7
children d1ce7a4a920b
line wrap: on
line diff
--- a/base/Pitch.cpp	Wed May 07 15:17:43 2014 +0100
+++ b/base/Pitch.cpp	Wed May 07 15:17:51 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);