From babf75d871ee253fbe32c50737aa110a4fffa36f Mon Sep 17 00:00:00 2001 From: Sampo Savolainen Date: Tue, 5 Sep 2006 17:53:54 +0000 Subject: Fix declicking for phase inverted routes by stopping process_output_buffers() from inverting the phase of a buffer twice. Also fixed bug in apply_declick() which resulted in incorrect phases for even buffers of p-reversed routes. git-svn-id: svn://localhost/ardour2/trunk@906 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/io.cc | 13 ++++++++----- libs/ardour/route.cc | 14 +++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'libs') diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 494401b080..242d94c2d7 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -203,18 +203,21 @@ IO::apply_declick (vector& bufs, uint32_t nbufs, jack_nframes_t nframe /* now ensure the rest of the buffer has the target value applied, if necessary. */ - + if (declick != nframes) { + float this_target; if (invert_polarity) { - target = -target; + this_target = -target; + } else { + this_target = target; } - if (target == 0.0) { + if (this_target == 0.0) { memset (&buffer[declick], 0, sizeof (Sample) * (nframes - declick)); - } else if (target != 1.0) { + } else if (this_target != 1.0) { for (jack_nframes_t nx = declick; nx < nframes; ++nx) { - buffer[nx] *= target; + buffer[nx] *= this_target; } } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 45040750b4..4f8a6ffd18 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -262,17 +262,17 @@ Route::process_output_buffers (vector& bufs, uint32_t nbufs, -------------------------------------------------------------------------------------------------- */ if (declick > 0) { - apply_declick (bufs, nbufs, nframes, 0.0, 1.0, _phase_invert); + apply_declick (bufs, nbufs, nframes, 0.0, 1.0, false); _pending_declick = 0; } else if (declick < 0) { - apply_declick (bufs, nbufs, nframes, 1.0, 0.0, _phase_invert); + apply_declick (bufs, nbufs, nframes, 1.0, 0.0, false); _pending_declick = 0; } else { /* no global declick */ if (solo_gain != dsg) { - apply_declick (bufs, nbufs, nframes, solo_gain, dsg, _phase_invert); + apply_declick (bufs, nbufs, nframes, solo_gain, dsg, false); solo_gain = dsg; } } @@ -289,7 +289,7 @@ Route::process_output_buffers (vector& bufs, uint32_t nbufs, } if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) { - apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert); + apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false); mute_gain = dmg; mute_declick_applied = true; } @@ -359,7 +359,7 @@ Route::process_output_buffers (vector& bufs, uint32_t nbufs, if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) { - apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert); + apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false); mute_gain = dmg; mute_declick_applied = true; } @@ -525,7 +525,7 @@ Route::process_output_buffers (vector& bufs, uint32_t nbufs, } if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) { - apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert); + apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false); mute_gain = dmg; mute_declick_applied = true; } @@ -570,7 +570,7 @@ Route::process_output_buffers (vector& bufs, uint32_t nbufs, ----------------------------------------------------------------------*/ if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) { - apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert); + apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false); mute_gain = dmg; mute_declick_applied = true; } -- cgit v1.2.3