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"
27 #include "pbd/types_convert.h"
29 #include "ardour/automatable.h"
30 #include "ardour/chan_count.h"
31 #include "ardour/debug.h"
32 #include "ardour/processor.h"
33 #include "ardour/types.h"
35 #ifdef WINDOWS_VST_SUPPORT
36 #include "ardour/windows_vst_plugin.h"
39 #ifdef AUDIOUNIT_SUPPORT
40 #include "ardour/audio_unit.h"
43 #include "ardour/audioengine.h"
44 #include "ardour/session.h"
45 #include "ardour/types.h"
50 using namespace ARDOUR;
53 namespace ARDOUR { class Session; }
55 // Always saved as Processor, but may be IOProcessor or Send in legacy sessions
56 const string Processor::state_node_name = "Processor";
58 Processor::Processor(Session& session, const string& name)
59 : SessionObject(session, name)
60 , Automatable (session)
61 , _pending_active(false)
63 , _next_ab_is_active(false)
65 , _display_to_user (true)
74 , _playback_offset (0)
78 Processor::Processor (const Processor& other)
79 : Evoral::ControlSet (other)
80 , SessionObject (other.session(), other.name())
81 , Automatable (other.session())
83 , _pending_active(other._pending_active)
84 , _active(other._active)
85 , _next_ab_is_active(false)
87 , _display_to_user (true)
97 Processor::~Processor ()
99 DEBUG_TRACE (DEBUG::Destruction, string_compose ("processor %1 destructor\n", _name));
103 Processor::get_state (void)
110 <Automation [optionally with visible="...." ]>
112 <AutomationList id=N>
125 XMLNode* node = new XMLNode (state_node_name);
127 node->set_property("id", id());
128 node->set_property("name", name());
129 node->set_property("active", active());
132 node->add_child_copy (*_extra_xml);
135 if (!skip_saving_automation) {
136 XMLNode& automation = Automatable::get_automation_xml_state();
137 if (!automation.children().empty() || !automation.properties().empty()) {
138 node->add_child_nocopy (automation);
144 node->set_property("user-latency", _user_latency);
150 Processor::set_state_2X (const XMLNode & node, int /*version*/)
152 XMLProperty const * prop;
154 XMLNodeList children = node.children ();
156 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
158 if ((*i)->name() == X_("IO")) {
160 if ((prop = (*i)->property ("name")) != 0) {
161 set_name (prop->value ());
166 //note: in A2, active state was stored in the Redirect node, not the child IO node
168 * if ((prop = (*i)->property ("active")) != 0) {
169 bool const a = string_is_affirmative (prop->value ());
186 Processor::set_state (const XMLNode& node, int version)
188 if (version < 3000) {
189 return set_state_2X (node, version);
193 // Only testing for the presence of the property not value
194 if (!node.get_property("ignore-name", ignore_name)) {
196 // may not exist for legacy 3.0 sessions
197 if (node.get_property ("name", name)) {
198 /* don't let derived classes have a crack at set_name,
199 as some (like Send) will screw with the one we suggest.
201 Processor::set_name (name);
207 XMLNodeList nlist = node.children();
208 XMLNodeIterator niter;
210 Stateful::save_extra_xml (node);
212 XMLProperty const * prop = 0;
213 XMLProperty const * legacy_active = 0;
215 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
217 if ((*niter)->name() == X_("Automation")) {
219 if ((prop = (*niter)->property ("path")) != 0) {
220 old_set_automation_state (*(*niter));
222 set_automation_xml_state (*(*niter), Evoral::Parameter(PluginAutomation));
225 } else if ((*niter)->name() == "Redirect") {
226 if ( !(legacy_active = (*niter)->property("active"))) {
227 error << string_compose(_("No %1 property flag in element %2"), "active", (*niter)->name()) << endl;
232 if ((prop = node.property ("active")) == 0) {
234 prop = legacy_active;
236 error << _("No child node with active property") << endmsg;
241 bool const a = string_to<bool> (prop->value ()) && !_session.get_bypass_all_loaded_plugins();
250 node.get_property ("user-latency", _user_latency);
255 /** @pre Caller must hold process lock */
257 Processor::configure_io (ChanCount in, ChanCount out)
259 /* This class assumes 1:1 input:output.static output stream count.
260 Derived classes must override and set _configured_output appropriately
261 if this is not the case
264 _configured_input = in;
265 _configured_output = out;
268 ConfigurationChanged (in, out); /* EMIT SIGNAL */
274 Processor::set_display_to_user (bool yn)
276 _display_to_user = yn;
280 Processor::set_pre_fader (bool p)
286 Processor::set_owner (SessionObject* o)
292 Processor::owner() const