diff options
author | David Robillard <d@drobilla.net> | 2014-01-06 17:02:55 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-01-10 20:51:54 -0500 |
commit | 72d8ca89e2f4b2e194b2bbd99261deb5b2108a40 (patch) | |
tree | 4e187229cf6cad791d4b8f0896a265d0f3574662 /gtk2_ardour/midi_automation_line.cc | |
parent | 0fe968a140cab6270b9480059cb173e7f7b33322 (diff) |
Support midnam controller value labels.
Diffstat (limited to 'gtk2_ardour/midi_automation_line.cc')
-rw-r--r-- | gtk2_ardour/midi_automation_line.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gtk2_ardour/midi_automation_line.cc b/gtk2_ardour/midi_automation_line.cc index a61c17601a..971944266f 100644 --- a/gtk2_ardour/midi_automation_line.cc +++ b/gtk2_ardour/midi_automation_line.cc @@ -18,7 +18,11 @@ */ #include "ardour/midi_automation_list_binder.h" +#include "midi++/midnam_patch.h" #include "midi_automation_line.h" +#include "midi_time_axis.h" + +#include "i18n.h" using namespace std; @@ -42,3 +46,42 @@ MidiAutomationLine::memento_command_binder () { return new ARDOUR::MidiAutomationListBinder (_region->midi_source(), _parameter); } + +string +MidiAutomationLine::get_verbose_cursor_string (double fraction) const +{ + using namespace MIDI::Name; + + if (_parameter.type() != ARDOUR::MidiCCAutomation) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(trackview.get_parent()); + if (!mtv) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + boost::shared_ptr<MasterDeviceNames> device_names(mtv->get_device_names()); + if (!device_names) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + const std::string& device_mode = mtv->gui_property(X_("midnam-custom-device-mode")); + const uint8_t channel = mtv->get_channel_for_add(); + + boost::shared_ptr<const ValueNameList> value_names = device_names->value_name_list_by_control( + device_mode, channel, _parameter.id()); + if (!value_names) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + const uint16_t cc_value = floor(std::max(std::min(fraction * 127.0, 127.0), 0.0)); + + boost::shared_ptr<const Value> value = value_names->max_value_below(cc_value); + if (!value) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + return value->name(); +} + |