diff base/Pitch.cpp @ 894:1341cc1390be tony_integration

Merge from default branch
author Chris Cannam
date Mon, 31 Mar 2014 13:00:17 +0100
parents 451f7f3ab6e7
children d1ce7a4a920b
line wrap: on
line diff
--- a/base/Pitch.cpp	Tue Mar 11 17:32:31 2014 +0000
+++ b/base/Pitch.cpp	Mon Mar 31 13:00:17 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);