Modify ParameterDescriptor::midi_note_name() to offer chance to get a non-octave-version
This commit is contained in:
parent
22efa2bf17
commit
55a0aadc74
@ -50,7 +50,7 @@ struct LIBARDOUR_API ParameterDescriptor : public Evoral::ParameterDescriptor
|
|||||||
HZ, ///< Frequency in Hertz
|
HZ, ///< Frequency in Hertz
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string midi_note_name (uint8_t, bool translate=true);
|
static std::string midi_note_name (uint8_t, bool translate = true, bool with_octave = true);
|
||||||
|
|
||||||
/** Dual of midi_note_name, convert a note name into its midi note number. */
|
/** Dual of midi_note_name, convert a note name into its midi note number. */
|
||||||
typedef std::map<std::string, uint8_t> NameNumMap;
|
typedef std::map<std::string, uint8_t> NameNumMap;
|
||||||
|
@ -252,7 +252,7 @@ ParameterDescriptor::update_steps()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
ParameterDescriptor::midi_note_name (const uint8_t b, bool translate)
|
ParameterDescriptor::midi_note_name (const uint8_t b, bool translate, bool with_octave)
|
||||||
{
|
{
|
||||||
char buf[16];
|
char buf[16];
|
||||||
if (b > 127) {
|
if (b > 127) {
|
||||||
@ -279,9 +279,14 @@ ParameterDescriptor::midi_note_name (const uint8_t b, bool translate)
|
|||||||
S_("Note|B")
|
S_("Note|B")
|
||||||
};
|
};
|
||||||
|
|
||||||
/* MIDI note 0 is in octave -1 (in scientific pitch notation) */
|
|
||||||
const int octave = b / 12 - 1;
|
|
||||||
const size_t p = b % 12;
|
const size_t p = b % 12;
|
||||||
|
|
||||||
|
/* MIDI note 0 is in octave -1 (in scientific pitch notation) */
|
||||||
|
if (!with_octave) {
|
||||||
|
return translate ? notes[p] : en_notes[p];
|
||||||
|
}
|
||||||
|
|
||||||
|
const int octave = b / 12 - 1;
|
||||||
snprintf (buf, sizeof (buf), "%s%d", translate ? notes[p] : en_notes[p], octave);
|
snprintf (buf, sizeof (buf), "%s%d", translate ? notes[p] : en_notes[p], octave);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user