2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "ardour/midi_automation_list_binder.h"
21 #include "ardour/midi_region.h"
23 #include "midi++/midnam_patch.h"
25 #include "midi_automation_line.h"
26 #include "midi_time_axis.h"
32 MidiAutomationLine::MidiAutomationLine (
33 const std::string& name,
35 ArdourCanvas::Item& parent,
36 boost::shared_ptr<ARDOUR::AutomationList> list,
37 boost::shared_ptr<ARDOUR::MidiRegion> region,
38 Evoral::Parameter parameter,
39 Evoral::TimeConverter<double, ARDOUR::framepos_t>* converter)
40 : AutomationLine (name, tav, parent, list, parameter, converter)
42 , _parameter (parameter)
47 MementoCommandBinder<ARDOUR::AutomationList>*
48 MidiAutomationLine::memento_command_binder ()
50 return new ARDOUR::MidiAutomationListBinder (_region->midi_source(), _parameter);
54 MidiAutomationLine::get_verbose_cursor_string (double fraction) const
56 using namespace MIDI::Name;
58 if (_parameter.type() != ARDOUR::MidiCCAutomation) {
59 return AutomationLine::get_verbose_cursor_string(fraction);
62 MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(trackview.get_parent());
64 return AutomationLine::get_verbose_cursor_string(fraction);
67 boost::shared_ptr<MasterDeviceNames> device_names(mtv->get_device_names());
69 return AutomationLine::get_verbose_cursor_string(fraction);
72 const std::string& device_mode = mtv->gui_property(X_("midnam-custom-device-mode"));
73 const uint8_t channel = mtv->get_channel_for_add();
75 boost::shared_ptr<const ValueNameList> value_names = device_names->value_name_list_by_control(
76 device_mode, channel, _parameter.id());
78 return AutomationLine::get_verbose_cursor_string(fraction);
81 const uint16_t cc_value = floor(std::max(std::min(fraction * 127.0, 127.0), 0.0));
83 boost::shared_ptr<const Value> value = value_names->max_value_below(cc_value);
85 return AutomationLine::get_verbose_cursor_string(fraction);