2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2006 Paul Davis
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "pbd/xml++.h"
24 #include "ardour/audioengine.h"
25 #include "ardour/buffer.h"
26 #include "ardour/buffer_set.h"
27 #include "ardour/io.h"
28 #include "ardour/session.h"
29 #include "ardour/sidechain.h"
33 using namespace ARDOUR;
37 SideChain::SideChain (Session& s, const std::string& name)
38 : IOProcessor (s, true, false, name)
42 SideChain::~SideChain ()
48 SideChain::state (bool full)
50 XMLNode& node = IOProcessor::state (full);
51 node.add_property ("type", "sidechain");
57 SideChain::set_state (const XMLNode& node, int version)
59 IOProcessor::set_state (node, version);
64 SideChain::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
66 if (_input->n_ports () == ChanCount::ZERO) {
67 // inplace pass-through
71 if (!_active && !_pending_active) {
73 for (DataType::iterator t = DataType::begin (); t != DataType::end (); ++t) {
74 for (uint32_t out = _configured_input.get (*t); out < bufs.count ().get (*t); ++out) {
75 bufs.get (*t, out).silence (nframes);
81 _input->collect_input (bufs, nframes, _configured_input);
82 bufs.set_count (_configured_output);
84 _active = _pending_active;
88 SideChain::can_support_io_configuration (const ChanCount& in, ChanCount& out)
90 out = in + _input->n_ports ();
95 SideChain::configure_io (ChanCount in, ChanCount out)
97 if (out != in + _input->n_ports ()) {
98 /* disabled for now - see PluginInsert::configure_io() */
101 return Processor::configure_io (in, out);