comparison 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
comparison
equal deleted inserted replaced
901:68e880e0b857 912:2175c2ebd5c6
99 QString 99 QString
100 Pitch::getPitchLabel(int midiPitch, 100 Pitch::getPitchLabel(int midiPitch,
101 float centsOffset, 101 float centsOffset,
102 bool useFlats) 102 bool useFlats)
103 { 103 {
104 int octave = -2; 104 int baseOctave = Preferences::getInstance()->getOctaveOfLowestMIDINote();
105 int octave = baseOctave;
106
107 // Note, this only gets the right octave number at octave
108 // boundaries because Cb is enharmonic with B (not B#) and B# is
109 // enharmonic with C (not Cb). So neither B# nor Cb will be
110 // spelled from a MIDI pitch + flats flag in isolation.
105 111
106 if (midiPitch < 0) { 112 if (midiPitch < 0) {
107 while (midiPitch < 0) { 113 while (midiPitch < 0) {
108 midiPitch += 12; 114 midiPitch += 12;
109 --octave; 115 --octave;
110 } 116 }
111 } else { 117 } else {
112 octave = midiPitch / 12 - 2; 118 octave = midiPitch / 12 + baseOctave;
113 } 119 }
114 120
115 QString plain = (useFlats ? flatNotes : notes)[midiPitch % 12].arg(octave); 121 QString plain = (useFlats ? flatNotes : notes)[midiPitch % 12].arg(octave);
116 122
117 int ic = lrintf(centsOffset); 123 int ic = lrintf(centsOffset);