2 Copyright (C) 2009 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/internal_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 InternalSend::InternalSend (Session& s, Placement p, boost::shared_ptr<IO> dst)
39 : IOProcessor (s, string_compose (_(">%1"), dst->name()), p,
41 DataType::AUDIO, false)
46 destination->input_changed.connect (mem_fun (*this, &InternalSend::destination_io_config_changed));
48 destination_io_config_changed (ConfigurationChanged, this);
50 ProcessorCreated (this); /* EMIT SIGNAL */
53 InternalSend::~InternalSend ()
59 InternalSend::destination_io_config_changed (IOChange c, void* src)
61 if (!(c & ConfigurationChanged)) {
65 _io->disconnect_outputs (this);
67 _io->ensure_io (ChanCount::ZERO, destination->n_inputs(), false, this);
69 PortSet::const_iterator us (_io->outputs().begin());
70 PortSet::const_iterator them (destination->inputs().begin ());
72 for (; us != _io->outputs().end() && them != destination->inputs().end(); ++us, ++them) {
73 (const_cast<Port*>(&(*us)))->connect (const_cast<Port*>(&(*them)));
78 InternalSend::get_state(void)
80 fatal << X_("InternalSend::get_state() called - should never happen") << endmsg;
82 return *(new XMLNode ("foo"));
86 InternalSend::set_state(const XMLNode& node)
88 fatal << X_("InternalSend::set_state() called - should never happen") << endmsg;
94 InternalSend::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
98 // we have to copy the input, because IO::deliver_output may alter the buffers
99 // in-place, which a send must never do. otherwise its gain settings will
100 // affect the signal seen later in the parent Route.
102 // BufferSet& sendbufs = _session.get_mix_buffers(bufs.count());
104 // sendbufs.read_from (bufs, nframes);
105 // assert(sendbufs.count() == bufs.count());
107 _io->deliver_output (bufs, start_frame, end_frame, nframes, offset);
110 if (_io->effective_gain() == 0) {
111 _io->peak_meter().reset();
113 _io->peak_meter().run_in_place(_io->output_buffers(), start_frame, end_frame, nframes, offset);
118 _io->silence (nframes, offset);
120 _io->peak_meter().reset();
126 InternalSend::set_metering (bool yn)
131 /* XXX possible thread hazard here */
132 _io->peak_meter().reset();
137 InternalSend::can_support_io_configuration (const ChanCount& in, ChanCount& out_is_ignored) const
139 /* number of outputs is fixed (though mutable by changing the I/O configuration
143 cerr << "IS: testing I/O config in=" << in.n_audio() << " out=" << out_is_ignored.n_audio() << endl;
145 if (in == _io->n_outputs()) {
153 InternalSend::configure_io (ChanCount in, ChanCount out)
155 cerr << "Configure IS for in " << in.n_audio() << " out = " << out.n_audio() << endl;
157 /* we're transparent no matter what. fight the power. */
163 _io->set_output_maximum (in);
164 _io->set_output_minimum (in);
165 _io->set_input_maximum (ChanCount::ZERO);
166 _io->set_input_minimum (ChanCount::ZERO);
168 out = _io->n_outputs();
170 Processor::configure_io(in, out);
178 InternalSend::output_streams() const
180 // this method reflects the idea that from the perspective of the Route's ProcessorList,
181 // a send is just a passthrough. that doesn't match what the Send actually does with its
182 // data, but since what it does is invisible to the Route, it appears to be a passthrough.
184 return _io->n_outputs ();
188 InternalSend::input_streams() const
190 return _configured_input;
195 InternalSend::expect_inputs (const ChanCount& expected)
197 if (expected != expected_inputs) {
198 expected_inputs = expected;
199 _io->reset_panner ();
204 InternalSend::activate ()
206 Processor::activate ();
210 InternalSend::deactivate ()
212 Processor::deactivate ();