comparison 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
comparison
equal deleted inserted replaced
891:8962f80f5d8e 894:1341cc1390be
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);