2 * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2010-2014 David Robillard <d@drobilla.net>
4 * Copyright (C) 2010-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "ardour/midi_automation_list_binder.h"
23 #include "ardour/midi_region.h"
25 #include "midi++/midnam_patch.h"
27 #include "midi_automation_line.h"
28 #include "midi_time_axis.h"
34 MidiAutomationLine::MidiAutomationLine (
35 const std::string& name,
37 ArdourCanvas::Item& parent,
38 boost::shared_ptr<ARDOUR::AutomationList> list,
39 boost::shared_ptr<ARDOUR::MidiRegion> region,
40 Evoral::Parameter parameter,
41 Evoral::TimeConverter<double, ARDOUR::samplepos_t>* converter)
42 : AutomationLine (name, tav, parent, list, parameter, converter)
44 , _parameter (parameter)
49 MementoCommandBinder<ARDOUR::AutomationList>*
50 MidiAutomationLine::memento_command_binder ()
52 return new ARDOUR::MidiAutomationListBinder (_region->midi_source(), _parameter);
56 MidiAutomationLine::get_verbose_cursor_string (double fraction) const
58 using namespace MIDI::Name;
60 if (_parameter.type() != ARDOUR::MidiCCAutomation) {
61 return AutomationLine::get_verbose_cursor_string(fraction);
64 MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(trackview.get_parent());
66 return AutomationLine::get_verbose_cursor_string(fraction);
69 boost::shared_ptr<MasterDeviceNames> device_names(mtv->get_device_names());
71 return AutomationLine::get_verbose_cursor_string(fraction);
74 const std::string& device_mode = mtv->gui_property(X_("midnam-custom-device-mode"));
75 const uint8_t channel = mtv->get_channel_for_add();
77 boost::shared_ptr<const ValueNameList> value_names = device_names->value_name_list_by_control(
78 device_mode, channel, _parameter.id());
80 return AutomationLine::get_verbose_cursor_string(fraction);
83 const uint16_t cc_value = floor(std::max(std::min(fraction * 127.0, 127.0), 0.0));
85 boost::shared_ptr<const Value> value = value_names->max_value_below(cc_value);
87 return AutomationLine::get_verbose_cursor_string(fraction);