mark session dirty when plugin pin mapping changes
[ardour.git] / libs / ardour / sidechain.cc
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2006 Paul Davis
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include <algorithm>
21
22 #include "pbd/xml++.h"
23
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"
30
31 #include "i18n.h"
32
33 using namespace ARDOUR;
34 using namespace PBD;
35
36
37 SideChain::SideChain (Session& s, const std::string& name)
38         : IOProcessor (s, true, false, name)
39 {
40 }
41
42 SideChain::~SideChain ()
43 {
44 }
45
46 XMLNode&
47 SideChain::state (bool full)
48 {
49         XMLNode& node = IOProcessor::state (full);
50         node.add_property ("type", "sidechain");
51         return node;
52 }
53
54
55 int
56 SideChain::set_state (const XMLNode& node, int version)
57 {
58         IOProcessor::set_state (node, version);
59         return 0;
60 }
61
62 void
63 SideChain::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
64 {
65         if (_input->n_ports () == ChanCount::ZERO) {
66                 // inplace pass-through
67                 return;
68         }
69
70         if (!_active && !_pending_active) {
71                 // zero buffers
72                 for (DataType::iterator t = DataType::begin (); t != DataType::end (); ++t) {
73                         for (uint32_t out = _configured_input.get (*t); out < bufs.count ().get (*t); ++out) {
74                                 bufs.get (*t, out).silence (nframes);
75                         }
76                 }
77                 return;
78         }
79
80         _input->collect_input (bufs, nframes, _configured_input);
81         bufs.set_count (_configured_output);
82
83         _active = _pending_active;
84 }
85
86 bool
87 SideChain::can_support_io_configuration (const ChanCount& in, ChanCount& out)
88 {
89         out = in + _input->n_ports ();
90         return true;
91 }
92
93 bool
94 SideChain::configure_io (ChanCount in, ChanCount out)
95 {
96         if (out != in + _input->n_ports ()) {
97                 /* disabled for now - see PluginInsert::configure_io() */
98                 // return false;
99         }
100         return Processor::configure_io (in, out);
101 }