X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_automation_line.cc;h=9a40ebbac3bea154c23a414e98f458e817b382ee;hb=25ec63968c0e792217a015c402ac52ae59a85e3b;hp=c6bb8335aaa1b3711dbde1c310970aeb244cfa9c;hpb=451c5c4d062d096f637d2ed243f4e27757829f96;p=ardour.git diff --git a/gtk2_ardour/midi_automation_line.cc b/gtk2_ardour/midi_automation_line.cc old mode 100755 new mode 100644 index c6bb8335aa..9a40ebbac3 --- a/gtk2_ardour/midi_automation_line.cc +++ b/gtk2_ardour/midi_automation_line.cc @@ -18,19 +18,28 @@ */ #include "ardour/midi_automation_list_binder.h" +#include "ardour/midi_region.h" + +#include "midi++/midnam_patch.h" + #include "midi_automation_line.h" +#include "midi_time_axis.h" + +#include "pbd/i18n.h" using namespace std; MidiAutomationLine::MidiAutomationLine ( - const std::string& name, TimeAxisView& tav, ArdourCanvas::Group& group, - boost::shared_ptr list, - boost::shared_ptr region, - Evoral::Parameter parameter, - const Evoral::TimeConverter* converter - ) : AutomationLine (name, tav, group, list, converter) - , _region (region) - , _parameter (parameter) + const std::string& name, + TimeAxisView& tav, + ArdourCanvas::Item& parent, + boost::shared_ptr list, + boost::shared_ptr region, + Evoral::Parameter parameter, + Evoral::TimeConverter* converter) + : AutomationLine (name, tav, parent, list, parameter, converter) + , _region (region) + , _parameter (parameter) { } @@ -40,3 +49,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(trackview.get_parent()); + if (!mtv) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + boost::shared_ptr 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 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 value = value_names->max_value_below(cc_value); + if (!value) { + return AutomationLine::get_verbose_cursor_string(fraction); + } + + return value->name(); +} +