ardour
midi_automation_line.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
21 #include "ardour/midi_region.h"
22 
23 #include "midi++/midnam_patch.h"
24 
25 #include "midi_automation_line.h"
26 #include "midi_time_axis.h"
27 
28 #include "i18n.h"
29 
30 using namespace std;
31 
33  const std::string& name,
34  TimeAxisView& tav,
35  ArdourCanvas::Item& parent,
38  Evoral::Parameter parameter,
40  : AutomationLine (name, tav, parent, list, parameter, converter)
41  , _region (region)
42  , _parameter (parameter)
43 {
44 
45 }
46 
49 {
51 }
52 
53 string
55 {
56  using namespace MIDI::Name;
57 
60  }
61 
62  MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(trackview.get_parent());
63  if (!mtv) {
65  }
66 
68  if (!device_names) {
70  }
71 
72  const std::string& device_mode = mtv->gui_property(X_("midnam-custom-device-mode"));
73  const uint8_t channel = mtv->get_channel_for_add();
74 
75  boost::shared_ptr<const ValueNameList> value_names = device_names->value_name_list_by_control(
76  device_mode, channel, _parameter.id());
77  if (!value_names) {
79  }
80 
81  const uint16_t cc_value = floor(std::max(std::min(fraction * 127.0, 127.0), 0.0));
82 
83  boost::shared_ptr<const Value> value = value_names->max_value_below(cc_value);
84  if (!value) {
86  }
87 
88  return value->name();
89 }
90 
MidiAutomationLine(const std::string &, TimeAxisView &, ArdourCanvas::Item &, boost::shared_ptr< ARDOUR::AutomationList >, boost::shared_ptr< ARDOUR::MidiRegion >, Evoral::Parameter, Evoral::TimeConverter< double, ARDOUR::framepos_t > *converter=0)
TimeAxisView * get_parent()
std::string gui_property(const std::string &property_name) const
Definition: axis_view.cc:67
Definition: Beats.hpp:239
uint8_t get_channel_for_add() const
Evoral::Parameter _parameter
#define X_(Text)
Definition: i18n.h:13
virtual std::string get_verbose_cursor_string(double) const
TimeAxisView & trackview
MementoCommandBinder< ARDOUR::AutomationList > * memento_command_binder()
const char * name
uint32_t id() const
Definition: Parameter.hpp:49
uint32_t type() const
Definition: Parameter.hpp:47
boost::shared_ptr< MidiSource > midi_source(uint32_t n=0) const
Definition: midi_region.cc:390
virtual std::string get_verbose_cursor_string(double) const
boost::shared_ptr< ARDOUR::MidiRegion > _region
boost::shared_ptr< MIDI::Name::MasterDeviceNames > get_device_names()