2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "ardour/audio_buffer.h"
20 #include "ardour/phase_control.h"
21 #include "ardour/polarity_processor.h"
25 using namespace ARDOUR;
28 PolarityProcessor::PolarityProcessor (Session& s, boost::shared_ptr<PhaseControl> control)
29 : Processor(s, "Polarity")
35 PolarityProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& out)
42 PolarityProcessor::configure_io (ChanCount in, ChanCount out)
44 if (out != in) { // always 1:1
48 return Processor::configure_io (in, out);
52 PolarityProcessor::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool)
54 if (!_active && !_pending_active) {
57 _active = _pending_active;
59 if (_control->none()) {
64 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
65 Sample* const sp = i->data();
66 if (_control->inverted (chn)) {
67 for (pframes_t nx = 0; nx < nframes; ++nx) {
75 PolarityProcessor::state ()
77 XMLNode& node (Processor::state ());
78 node.set_property("type", "polarity");