Move panner bypass state up to the PannerShell so that it is preserved even when...
[ardour2.git] / libs / ardour / midi_automation_list_binder.cc
blob0f8e4884ca0931dbfa0d6d2a7848884954f85efb
1 /*
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/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)
29 : _source (s)
30 , _parameter (p)
35 MidiAutomationListBinder::MidiAutomationListBinder (XMLNode* node, Session::SourceMap const & sources)
36 : _parameter (0, 0, 0)
38 XMLProperty* source = node->property ("source-id");
39 assert (source);
41 XMLProperty* parameter = node->property ("parameter");
42 assert (parameter);
44 Session::SourceMap::const_iterator i = sources.find (PBD::ID (source->value()));
45 assert (i != sources.end());
46 _source = boost::dynamic_pointer_cast<MidiSource> (i->second);
48 _parameter = EventTypeMap::instance().new_parameter (parameter->value());
51 AutomationList*
52 MidiAutomationListBinder::get ()
54 boost::shared_ptr<MidiModel> model = _source->model ();
55 assert (model);
57 boost::shared_ptr<AutomationControl> control = model->automation_control (_parameter);
58 assert (control);
60 return control->alist().get();
63 void
64 MidiAutomationListBinder::add_state (XMLNode* node)
66 node->add_property ("source-id", _source->id().to_s());
67 node->add_property ("parameter", EventTypeMap::instance().to_symbol (_parameter));