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/send.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 Send::Send (Session& s)
39 : IOProcessor (s, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1))
42 ProcessorCreated (this); /* EMIT SIGNAL */
45 Send::Send (Session& s, const XMLNode& node)
46 : IOProcessor (s, "send")
50 if (set_state (node)) {
51 throw failed_constructor();
54 ProcessorCreated (this); /* EMIT SIGNAL */
69 Send::state(bool full)
71 XMLNode& node = IOProcessor::state(full);
73 node.add_property ("type", "send");
74 snprintf (buf, sizeof (buf), "%" PRIu32, _bitslot);
75 node.add_property ("bitslot", buf);
81 Send::set_state(const XMLNode& node)
83 XMLNodeList nlist = node.children();
84 XMLNodeIterator niter;
85 const XMLProperty* prop;
87 if ((prop = node.property ("bitslot")) == 0) {
88 _bitslot = _session.next_send_id();
90 sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
91 _session.mark_send_id (_bitslot);
94 const XMLNode* insert_node = &node;
96 /* Send has regular IO automation (gain, pan) */
98 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
99 if ((*niter)->name() == "IOProcessor") {
100 insert_node = *niter;
101 } else if ((*niter)->name() == X_("Automation")) {
102 // _io->set_automation_state (*(*niter), Evoral::Parameter(GainAutomation));
106 IOProcessor::set_state (*insert_node);
112 Send::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes)
116 _io->deliver_output (bufs, start_frame, end_frame, nframes);
119 if (_io->effective_gain() == 0) {
120 _io->peak_meter().reset();
122 _io->peak_meter().run_in_place(_io->output_buffers(), start_frame, end_frame, nframes);
127 _io->silence (nframes);
130 _io->peak_meter().reset();
136 Send::set_metering (bool yn)
141 /* XXX possible thread hazard here */
142 _io->peak_meter().reset();
147 Send::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
149 if (_io->input_maximum() == ChanCount::INFINITE
150 && _io->output_maximum() == ChanCount::INFINITE) {
152 /* not configured yet, we can support anything */
155 return true; /* we can support anything the first time we're asked */
159 /* for a send, processor input corresponds to IO output */
161 if (_io->output_maximum() == in) {
171 Send::configure_io (ChanCount in, ChanCount out)
173 /* we're transparent no matter what. fight the power. */
179 /*_io->set_output_maximum (in);
180 _io->set_output_minimum (in);
181 _io->set_input_maximum (ChanCount::ZERO);
182 _io->set_input_minimum (ChanCount::ZERO);*/
184 if (_io->ensure_io (ChanCount::ZERO, in, false, this) != 0) {
188 Processor::configure_io(in, out);
194 /** Set up the XML description of a send so that its name is unique.
195 * @param state XML send state.
196 * @param session Session.
199 Send::make_unique (XMLNode &state, Session &session)
201 uint32_t const bitslot = session.next_send_id() + 1;
204 snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
205 state.property("bitslot")->set_value (buf);
207 std::string const name = string_compose (_("send %1"), bitslot);
209 state.property("name")->set_value (name);
211 XMLNode* io = state.child ("IO");
213 io->property("name")->set_value (name);