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.
22 #include "pbd/xml++.h"
24 #include "ardour/return.h"
25 #include "ardour/session.h"
26 #include "ardour/port.h"
27 #include "ardour/audio_port.h"
28 #include "ardour/buffer_set.h"
29 #include "ardour/meter.h"
30 #include "ardour/panner.h"
31 #include "ardour/io.h"
35 using namespace ARDOUR;
38 Return::Return (Session& s)
39 : IOProcessor (s, string_compose (_("return %1"), (_bitslot = s.next_return_id()) + 1))
41 ProcessorCreated (this); /* EMIT SIGNAL */
44 Return::Return (Session& s, const XMLNode& node)
45 : IOProcessor (s, "return")
47 if (set_state (node)) {
48 throw failed_constructor();
51 ProcessorCreated (this); /* EMIT SIGNAL */
60 Return::get_state(void)
66 Return::state(bool full)
68 XMLNode& node = IOProcessor::state(full);
70 node.add_property ("type", "return");
71 snprintf (buf, sizeof (buf), "%" PRIu32, _bitslot);
72 node.add_property ("bitslot", buf);
78 Return::set_state(const XMLNode& node)
80 XMLNodeList nlist = node.children();
81 XMLNodeIterator niter;
82 const XMLProperty* prop;
84 if ((prop = node.property ("bitslot")) == 0) {
85 _bitslot = _session.next_return_id();
87 sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
88 _session.mark_return_id (_bitslot);
91 const XMLNode* insert_node = &node;
93 /* Return has regular IO automation (gain, pan) */
95 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
96 if ((*niter)->name() == "IOProcessor") {
98 } else if ((*niter)->name() == X_("Automation")) {
99 // _io->set_automation_state (*(*niter), Evoral::Parameter(GainAutomation));
103 IOProcessor::set_state (*insert_node);
109 Return::run_in_place (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
112 _io->collect_input (bufs, nframes, _configured_input);
113 bufs.set_count(_configured_output);
118 Return::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
120 out = in + _io->n_inputs();
125 Return::configure_io (ChanCount in, ChanCount out)
127 if (out != in + _io->n_inputs()) {
131 // Ensure there are enough buffers (since we add some)
132 if (_session.get_scratch_buffers(in).count() < out) {
133 Glib::Mutex::Lock em (_session.engine().process_lock());
134 IO::PortCountChanged(out);
137 Processor::configure_io(in, out);
142 /** Set up the XML description of a return so that its name is unique.
143 * @param state XML return state.
144 * @param session Session.
147 Return::make_unique (XMLNode &state, Session &session)
149 uint32_t const bitslot = session.next_return_id() + 1;
152 snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
153 state.property("bitslot")->set_value (buf);
155 std::string const name = string_compose (_("return %1"), bitslot);
157 state.property("name")->set_value (name);
159 XMLNode* io = state.child ("IO");
161 io->property("name")->set_value (name);