Mercurial > hg > svcore
diff base/Pitch.cpp @ 26:090c22aa726a
* Add the Note layer for pianoroll-type display of note-type data
* Complete the MIDI file importer (well, nearly -- it would be nice to
be able to import the non-note data as other sorts of models, and that's
not done yet).
* Minor refactoring in RealTime etc
author | Chris Cannam |
---|---|
date | Fri, 10 Feb 2006 17:51:36 +0000 |
parents | a7ed14263fe4 |
children | 39ae3dee27b9 |
line wrap: on
line diff
--- a/base/Pitch.cpp Thu Feb 09 18:01:52 2006 +0000 +++ b/base/Pitch.cpp Fri Feb 10 17:51:36 2006 +0000 @@ -45,9 +45,16 @@ "G#%1", "A%1", "A#%1", "B%1" }; +static QString flatNotes[] = { + "C%1", "Db%1", "D%1", "Eb%1", + "E%1", "F%1", "Gb%1", "G%1", + "Ab%1", "A%1", "Bb%1", "B%1" +}; + QString Pitch::getPitchLabel(int midiPitch, - float centsOffset) + float centsOffset, + bool useFlats) { int octave = -2; @@ -60,7 +67,7 @@ octave = midiPitch / 12 - 2; } - QString plain = notes[midiPitch % 12].arg(octave); + QString plain = (useFlats ? flatNotes : notes)[midiPitch % 12].arg(octave); int ic = lrintf(centsOffset); if (ic == 0) return plain; @@ -70,10 +77,11 @@ QString Pitch::getPitchLabelForFrequency(float frequency, - float concertA) + float concertA, + bool useFlats) { float centsOffset = 0.0; int midiPitch = getPitchForFrequency(frequency, ¢sOffset, concertA); - return getPitchLabel(midiPitch, centsOffset); + return getPitchLabel(midiPitch, centsOffset, useFlats); }