2 Copyright (C) 2000 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.
21 #include "libardour-config.h"
26 #include <sigc++/bind.h>
28 #include "pbd/failed_constructor.h"
29 #include "pbd/enumwriter.h"
30 #include "pbd/xml++.h"
32 #include "ardour/processor.h"
33 #include "ardour/plugin.h"
34 #include "ardour/port.h"
35 #include "ardour/route.h"
36 #include "ardour/ladspa_plugin.h"
37 #include "ardour/buffer_set.h"
38 #include "ardour/send.h"
39 #include "ardour/port_insert.h"
40 #include "ardour/plugin_insert.h"
43 #include "ardour/vst_plugin.h"
46 #ifdef HAVE_AUDIOUNITS
47 #include "ardour/audio_unit.h"
50 #include "ardour/audioengine.h"
51 #include "ardour/session.h"
52 #include "ardour/types.h"
57 using namespace ARDOUR;
60 sigc::signal<void,Processor*> Processor::ProcessorCreated;
62 // Always saved as Processor, but may be IOProcessor or Send in legacy sessions
63 const string Processor::state_node_name = "Processor";
65 Processor::Processor(Session& session, const string& name)
66 : SessionObject(session, name)
67 , AutomatableControls(session)
68 , _pending_active(false)
70 , _next_ab_is_active(false)
76 Processor::Processor (Session& session, const XMLNode& node)
77 : SessionObject(session, "renameMe")
78 , AutomatableControls(session)
79 , _pending_active(false)
81 , _next_ab_is_active(false)
86 _pending_active = _active;
90 Processor::get_state (void)
97 <Automation [optionally with visible="...." ]>
110 Processor::state (bool full_state)
112 XMLNode* node = new XMLNode (state_node_name);
116 id().print (buf, sizeof (buf));
117 node->add_property("id", buf);
118 node->add_property("name", _name);
119 node->add_property("active", active() ? "yes" : "no");
122 node->add_child_copy (*_extra_xml);
126 XMLNode& automation = Automatable::get_automation_state();
127 if (!automation.children().empty()
128 || !automation.properties().empty()
129 || !_visible_controls.empty()) {
131 for (set<Evoral::Parameter>::iterator x = _visible_controls.begin();
132 x != _visible_controls.end(); ++x) {
133 if (x != _visible_controls.begin()) {
139 automation.add_property ("visible", sstr.str());
140 node->add_child_nocopy (automation);
148 Processor::set_state (const XMLNode& node)
150 const XMLProperty *prop;
151 const XMLProperty *legacy_active = 0;
153 // may not exist for legacy 3.0 sessions
154 if ((prop = node.property ("name")) != 0) {
155 set_name(prop->value());
158 // may not exist for legacy 3.0 sessions
159 if ((prop = node.property ("id")) != 0) {
163 XMLNodeList nlist = node.children();
164 XMLNodeIterator niter;
166 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
168 if ((*niter)->name() == X_("Automation")) {
172 if ((prop = (*niter)->property ("path")) != 0) {
173 old_set_automation_state (*(*niter));
175 set_automation_state (*(*niter), Evoral::Parameter(PluginAutomation));
178 if ((prop = (*niter)->property ("visible")) != 0) {
182 _visible_controls.clear ();
184 sstr << prop->value();
190 // FIXME: other automation types?
191 mark_automation_visible (Evoral::Parameter(PluginAutomation, 0, what), true);
195 } else if ((*niter)->name() == "Extra") {
196 _extra_xml = new XMLNode (*(*niter));
197 } else if ((*niter)->name() == "Redirect") {
198 if ( !(legacy_active = (*niter)->property("active"))) {
199 error << string_compose(_("No %1 property flag in element %2"), "active", (*niter)->name()) << endl;
204 if ((prop = node.property ("active")) == 0) {
205 warning << _("XML node describing a processor is missing the `active' field,"
206 "trying legacy active flag from child node") << endmsg;
208 prop = legacy_active;
210 error << _("No child node with active property") << endmsg;
215 if (_active != string_is_affirmative (prop->value())) {
217 ActiveChanged (); /* EMIT_SIGNAL */
224 Processor::configure_io (ChanCount in, ChanCount out)
226 /* This class assumes 1:1 input:output.static output stream count.
227 Derived classes must override and set _configured_output appropriately
228 if this is not the case
231 _configured_input = in;
232 _configured_output = out;
235 ConfigurationChanged.emit (in, out);