summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-06 17:02:55 -0500
committerDavid Robillard <d@drobilla.net>2014-01-10 20:51:54 -0500
commit72d8ca89e2f4b2e194b2bbd99261deb5b2108a40 (patch)
tree4e187229cf6cad791d4b8f0896a265d0f3574662 /gtk2_ardour
parent0fe968a140cab6270b9480059cb173e7f7b33322 (diff)
Support midnam controller value labels.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/automation_line.h2
-rw-r--r--gtk2_ardour/midi_automation_line.cc43
-rw-r--r--gtk2_ardour/midi_automation_line.h2
3 files changed, 46 insertions, 1 deletions
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index 405fc63e11..054e84e789 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -112,7 +112,7 @@ public:
ArdourCanvas::Item& parent_group() const { return _parent_group; }
ArdourCanvas::Item& grab_item() const { return *line; }
- std::string get_verbose_cursor_string (double) const;
+ virtual std::string get_verbose_cursor_string (double) const;
std::string get_verbose_cursor_relative_string (double, double) const;
std::string fraction_to_string (double) const;
std::string fraction_to_relative_string (double, double) const;
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();
+}
+
diff --git a/gtk2_ardour/midi_automation_line.h b/gtk2_ardour/midi_automation_line.h
index 2e1195a16b..df4db06c2c 100644
--- a/gtk2_ardour/midi_automation_line.h
+++ b/gtk2_ardour/midi_automation_line.h
@@ -34,6 +34,8 @@ public:
MementoCommandBinder<ARDOUR::AutomationList>* memento_command_binder ();
+ virtual std::string get_verbose_cursor_string (double) const;
+
private:
boost::shared_ptr<ARDOUR::MidiRegion> _region;
Evoral::Parameter _parameter;