diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-12 23:00:15 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-12 23:02:46 +0200 |
commit | 6b5be3d89257fb91a1c8c1b2d166106deb5a6874 (patch) | |
tree | 3b9fadd8e0abe2ec080acf8dbf8f932dd0f54af9 /libs/ardour/parameter_descriptor.cc | |
parent | cd5e86c24a39a7343bfa2089ceaf995ed69342ce (diff) |
Add a new API to format midi-note-names with translation: Do Re Mi...
This deprecates Evoral::midi_note_name(). we don't maintain i18n
for libevoral.
Diffstat (limited to 'libs/ardour/parameter_descriptor.cc')
-rw-r--r-- | libs/ardour/parameter_descriptor.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/ardour/parameter_descriptor.cc b/libs/ardour/parameter_descriptor.cc index 880adfb162..3a7eff9d14 100644 --- a/libs/ardour/parameter_descriptor.cc +++ b/libs/ardour/parameter_descriptor.cc @@ -188,4 +188,34 @@ ParameterDescriptor::update_steps() } } +std::string +ParameterDescriptor::midi_note_name (const uint8_t b) +{ + char buf[8]; + if (b > 127) { + snprintf(buf, sizeof(buf), "%d", b); + return buf; + } + + static const char* notes[] = { + S_("Note|C"), + S_("Note|C#"), + S_("Note|D"), + S_("Note|D#"), + S_("Note|E"), + S_("Note|F"), + S_("Note|F#"), + S_("Note|G"), + S_("Note|G#"), + S_("Note|A"), + S_("Note|A#"), + S_("Note|B") + }; + + /* MIDI note 0 is in octave -1 (in scientific pitch notation) */ + const int octave = b / 12 - 1; + snprintf (buf, sizeof (buf), "%s%d", notes[b % 12], octave); + return buf; +} + } // namespace ARDOUR |