diff base/Pitch.cpp @ 892:451f7f3ab6e7

Make octave numbering configurable, and change default to C4 = middle C
author Chris Cannam
date Thu, 27 Mar 2014 13:32:56 +0000
parents bdc9bb371a9f
children d1ce7a4a920b
line wrap: on
line diff
--- a/base/Pitch.cpp	Tue Mar 11 17:29:44 2014 +0000
+++ b/base/Pitch.cpp	Thu Mar 27 13:32:56 2014 +0000
@@ -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);