2 * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2011-2014 David Robillard <d@drobilla.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "ardour/midi_automation_list_binder.h"
21 #include "ardour/automation_list.h"
22 #include "ardour/automation_control.h"
23 #include "ardour/midi_source.h"
24 #include "ardour/midi_model.h"
26 using namespace ARDOUR;
28 MidiAutomationListBinder::MidiAutomationListBinder (boost::shared_ptr<MidiSource> s, Evoral::Parameter p)
35 MidiAutomationListBinder::MidiAutomationListBinder (XMLNode* node, Session::SourceMap const & sources)
36 : _parameter (0, 0, 0)
39 std::string parameter_str;
40 if (!node->get_property ("source-id", id_str) ||
41 !node->get_property ("parameter", parameter_str)) {
45 Session::SourceMap::const_iterator i = sources.find (PBD::ID (id_str));
46 assert (i != sources.end());
47 _source = boost::dynamic_pointer_cast<MidiSource> (i->second);
49 _parameter = EventTypeMap::instance().from_symbol (parameter_str);
53 MidiAutomationListBinder::get () const
55 boost::shared_ptr<MidiModel> model = _source->model ();
58 boost::shared_ptr<AutomationControl> control = model->automation_control (_parameter);
61 return control->alist().get();
65 MidiAutomationListBinder::add_state (XMLNode* node)
67 node->set_property ("source-id", _source->id().to_s());
68 node->set_property ("parameter", EventTypeMap::instance().to_symbol (_parameter));