From c411e05b6f9c5738b53f5a94812b6f24d53a86d1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 31 Oct 2017 22:21:12 +0100 Subject: Click-free polarity inversion, also use accelerated (AVX, SSE) Amp --- libs/ardour/polarity_processor.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'libs/ardour/polarity_processor.cc') diff --git a/libs/ardour/polarity_processor.cc b/libs/ardour/polarity_processor.cc index 5604cd4000..42231d9d27 100644 --- a/libs/ardour/polarity_processor.cc +++ b/libs/ardour/polarity_processor.cc @@ -16,9 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "ardour/amp.h" #include "ardour/audio_buffer.h" #include "ardour/phase_control.h" #include "ardour/polarity_processor.h" +#include "ardour/session.h" #include "pbd/i18n.h" @@ -45,29 +47,26 @@ PolarityProcessor::configure_io (ChanCount in, ChanCount out) return false; } + _current_gain.resize (in.n_audio (), 0.f); + return Processor::configure_io (in, out); } void PolarityProcessor::run (BufferSet& bufs, samplepos_t /*start_sample*/, samplepos_t /*end_sample*/, double /*speed*/, pframes_t nframes, bool) { + int chn = 0; if (!_active && !_pending_active) { + /* fade all to unity */ + for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) { + _current_gain[chn] = Amp::apply_gain (*i, _session.nominal_sample_rate(), nframes, _current_gain[chn], 1.0); + } return; } _active = _pending_active; - if (_control->none()) { - return; - } - int chn = 0; - for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) { - Sample* const sp = i->data(); - if (_control->inverted (chn)) { - for (pframes_t nx = 0; nx < nframes; ++nx) { - sp[nx] = -sp[nx]; - } - } + _current_gain[chn] = Amp::apply_gain (*i, _session.nominal_sample_rate(), nframes, _current_gain[chn], _control->inverted (chn) ? -1.f : 1.f); } } -- cgit v1.2.3