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 "pbd/xml++.h"
28 #include "ardour/automatable.h"
29 #include "ardour/chan_count.h"
30 #include "ardour/processor.h"
31 #include "ardour/types.h"
33 #ifdef WINDOWS_VST_SUPPORT
34 #include "ardour/windows_vst_plugin.h"
37 #ifdef AUDIOUNIT_SUPPORT
38 #include "ardour/audio_unit.h"
41 #include "ardour/audioengine.h"
42 #include "ardour/session.h"
43 #include "ardour/types.h"
48 using namespace ARDOUR;
51 namespace ARDOUR { class Session; }
53 // Always saved as Processor, but may be IOProcessor or Send in legacy sessions
54 const string Processor::state_node_name = "Processor";
56 Processor::Processor(Session& session, const string& name)
57 : SessionObject(session, name)
58 , Automatable (session)
59 , _pending_active(false)
61 , _next_ab_is_active(false)
63 , _display_to_user (true)
72 Processor::Processor (const Processor& other)
73 : Evoral::ControlSet (other)
74 , SessionObject (other.session(), other.name())
75 , Automatable (other.session())
77 , _pending_active(other._pending_active)
78 , _active(other._active)
79 , _next_ab_is_active(false)
81 , _display_to_user (true)
91 Processor::get_state (void)
98 <Automation [optionally with visible="...." ]>
100 <AutomationList id=N>
111 Processor::state (bool full_state)
113 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_xml_state();
127 if (!automation.children().empty() || !automation.properties().empty()) {
128 node->add_child_nocopy (automation);
134 snprintf (buf, sizeof (buf), "%" PRId64, _user_latency);
135 node->add_property("user-latency", buf);
141 Processor::set_state_2X (const XMLNode & node, int /*version*/)
143 XMLProperty const * prop;
145 XMLNodeList children = node.children ();
147 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
149 if ((*i)->name() == X_("IO")) {
151 if ((prop = (*i)->property ("name")) != 0) {
152 set_name (prop->value ());
157 //note: in A2, active state was stored in the Redirect node, not the child IO node
159 * if ((prop = (*i)->property ("active")) != 0) {
160 bool const a = string_is_affirmative (prop->value ());
177 Processor::set_state (const XMLNode& node, int version)
179 if (version < 3000) {
180 return set_state_2X (node, version);
183 XMLProperty const * prop;
184 XMLProperty const * legacy_active = 0;
185 bool leave_name_alone = (node.property ("ignore-name") != 0);
187 if (!leave_name_alone) {
188 // may not exist for legacy 3.0 sessions
189 if ((prop = node.property ("name")) != 0) {
190 /* don't let derived classes have a crack at set_name,
191 as some (like Send) will screw with the one we suggest.
193 Processor::set_name (prop->value());
199 XMLNodeList nlist = node.children();
200 XMLNodeIterator niter;
202 Stateful::save_extra_xml (node);
204 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
206 if ((*niter)->name() == X_("Automation")) {
208 XMLProperty const * prop;
210 if ((prop = (*niter)->property ("path")) != 0) {
211 old_set_automation_state (*(*niter));
213 set_automation_xml_state (*(*niter), Evoral::Parameter(PluginAutomation));
216 } else if ((*niter)->name() == "Redirect") {
217 if ( !(legacy_active = (*niter)->property("active"))) {
218 error << string_compose(_("No %1 property flag in element %2"), "active", (*niter)->name()) << endl;
223 if ((prop = node.property ("active")) == 0) {
225 prop = legacy_active;
227 error << _("No child node with active property") << endmsg;
232 bool const a = string_is_affirmative (prop->value ()) && !_session.get_bypass_all_loaded_plugins();
241 if ((prop = node.property ("user-latency")) != 0) {
242 _user_latency = atoi (prop->value ());
248 /** @pre Caller must hold process lock */
250 Processor::configure_io (ChanCount in, ChanCount out)
252 /* This class assumes 1:1 input:output.static output stream count.
253 Derived classes must override and set _configured_output appropriately
254 if this is not the case
257 _configured_input = in;
258 _configured_output = out;
261 ConfigurationChanged (in, out); /* EMIT SIGNAL */
267 Processor::set_display_to_user (bool yn)
269 _display_to_user = yn;
273 Processor::set_pre_fader (bool p)
279 Processor::set_ui (void* p)
285 Processor::set_owner (SessionObject* o)
291 Processor::owner() const