From 96cc1dbe80f0378ca010c1c5ac37913958193360 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 16 Sep 2015 18:32:28 -0400 Subject: [PATCH] Revert "add an Amp to Delivery, remove it from Send, make use of this in various ::run() methods" This reverts commit 601a34521c2ce1d0167ed2f3c66f2fa6eeeb6b8e. --- libs/ardour/amp.cc | 12 +---- libs/ardour/ardour/delivery.h | 5 +-- libs/ardour/ardour/send.h | 2 + libs/ardour/delivery.cc | 83 ++++++++++------------------------- libs/ardour/internal_send.cc | 25 ++++++----- libs/ardour/send.cc | 3 +- 6 files changed, 45 insertions(+), 85 deletions(-) diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index b7e639b9f5..880fe2575e 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -133,19 +133,9 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, _current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, dg, _midi_amp); - } else if (_current_gain == GAIN_COEFF_ZERO) { - - /* gain has not changed, and is zero. small - * optimization here. - */ - - bufs.silence (nframes, 0); - } else if (_current_gain != GAIN_COEFF_UNITY) { - /* gain has not changed, but its non-unity and - * isn't zero, so we have to do something - */ + /* gain has not changed, but its non-unity */ if (_midi_amp) { /* don't Trim midi velocity -- only relevant for Midi on Audio tracks */ diff --git a/libs/ardour/ardour/delivery.h b/libs/ardour/ardour/delivery.h index 1b8ff3f87a..e19eef719f 100644 --- a/libs/ardour/ardour/delivery.h +++ b/libs/ardour/ardour/delivery.h @@ -34,7 +34,6 @@ class MuteMaster; class PannerShell; class Panner; class Pannable; -class Amp; class LIBARDOUR_API Delivery : public IOProcessor { @@ -68,8 +67,6 @@ public: bool set_name (const std::string& name); std::string display_name() const; - boost::shared_ptr amp() const { return _amp; } - Role role() const { return _role; } bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool configure_io (ChanCount in, ChanCount out); @@ -109,8 +106,8 @@ public: protected: Role _role; BufferSet* _output_buffers; + gain_t _current_gain; boost::shared_ptr _panshell; - boost::shared_ptr _amp; gain_t target_gain (); diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h index df9afad55c..17343bff96 100644 --- a/libs/ardour/ardour/send.h +++ b/libs/ardour/ardour/send.h @@ -43,6 +43,7 @@ class LIBARDOUR_API Send : public Delivery bool display_to_user() const; + boost::shared_ptr amp() const { return _amp; } boost::shared_ptr meter() const { return _meter; } bool metering() const { return _metering; } @@ -77,6 +78,7 @@ class LIBARDOUR_API Send : public Delivery protected: bool _metering; + boost::shared_ptr _amp; boost::shared_ptr _meter; boost::shared_ptr _delayline; diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 5a4fbd3e1d..1b8a8c5948 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -52,7 +52,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr io, boost::shared_ptr(), (role_requires_output_ports (r) ? io : boost::shared_ptr()), name) , _role (r) , _output_buffers (new BufferSet()) - , _amp (new Amp (s)) + , _current_gain (GAIN_COEFF_UNITY) , _no_outs_cuz_we_no_monitor (false) , _mute_master (mm) , _no_panner_reset (false) @@ -68,8 +68,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr io, boost::shared_ptrchanged.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - - _amp->activate (); } /* deliver to a new IO object */ @@ -78,7 +76,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr pannable, boost::sha : IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name, "", DataType::AUDIO, (r == Send)) , _role (r) , _output_buffers (new BufferSet()) - , _amp (new Amp (s)) + , _current_gain (GAIN_COEFF_UNITY) , _no_outs_cuz_we_no_monitor (false) , _mute_master (mm) , _no_panner_reset (false) @@ -94,17 +92,16 @@ Delivery::Delivery (Session& s, boost::shared_ptr pannable, boost::sha if (_output) { _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2)); } - - _amp->activate (); } + Delivery::~Delivery() { - DEBUG_TRACE (DEBUG::Destruction, string_compose ("delivery %1 destructor\n", _name)); + DEBUG_TRACE (DEBUG::Destruction, string_compose ("delivery %1 destructor\n", _name)); /* this object should vanish from any signal callback lists that it is on before we get any further. The full qualification - of the method name is not necessary, but is here to make it + of the method name is not necessary, but is here to make it clear that this call is about signals, not data flow connections. */ @@ -238,7 +235,6 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf PortSet& ports (_output->ports()); gain_t tgain; - bool need_amp = true; if (_output->n_ports ().get (_output->default_type()) == 0) { goto out; @@ -263,59 +259,28 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf tgain = target_gain (); - if (tgain < GAIN_COEFF_SMALL && _amp->gain() < GAIN_COEFF_SMALL) { - - /* special case (but very common) fast path: - * - * if we are supposed to be silent, and we were already silent, - * then short-circuit the computation in Amp and just put silence into - * our output(s) - */ - - _output->silence (nframes); - - if (!result_required) { - /* if !result_required, then the buffers won't actually - * be used. This means we don't actually need to silence - * them, because we've already filled the output ports - * with silence. - * - * but we just noted that result_required is true, - * and so we do need to run the amp to ensure - * that the buffers are silenced. - */ - need_amp = false; - } - } - - if (need_amp) { - - bufs.set_count (output_buffers().count ()); + if (tgain != _current_gain) { + /* target gain has changed */ - if (_role != Main) { + _current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain); - /* inserts, external and internal sends have - * automatable gain and the Amp::run() method has - * already been executed by the time we get here. - * - * XXX we do not expose the automatable gain for - * Inserts as of September 2015. - */ + } else if (tgain < GAIN_COEFF_SMALL) { - } else { - - /* main outs have no automatable gain, the amp is just - * used for ramping gain changes caused by monitoring - * state changes. - */ - - _amp->set_gain (tgain, this); - _amp->run (bufs, 0, 0, nframes, false); + /* we were quiet last time, and we're still supposed to be quiet. + Silence the outputs, and make sure the buffers are quiet too, + */ + _output->silence (nframes); + if (result_required) { + bufs.set_count (output_buffers().count ()); + Amp::apply_simple_gain (bufs, nframes, GAIN_COEFF_ZERO); } - - } else { goto out; + + } else if (tgain != GAIN_COEFF_UNITY) { + + /* target gain has not changed, but is not unity */ + Amp::apply_simple_gain (bufs, nframes, tgain); } // Speed quietning @@ -429,7 +394,7 @@ Delivery::pan_outs () const { if (_output) { return _output->n_ports().n_audio(); - } + } return _configured_output.n_audio(); } @@ -497,7 +462,7 @@ Delivery::flush_buffers (framecnt_t nframes) if (!_output) { return; } - + PortSet& ports (_output->ports()); for (PortSet::iterator i = ports.begin(); i != ports.end(); ++i) { @@ -548,7 +513,7 @@ Delivery::target_gain () we're not monitoring, then be quiet. */ - if (_role == Main && _session.config.get_use_monitor_fades() && _no_outs_cuz_we_no_monitor) { + if (_no_outs_cuz_we_no_monitor) { return GAIN_COEFF_ZERO; } diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index fe57176ac7..e8e560c7c0 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -148,10 +148,10 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame } else { if (role() == Listen) { /* We're going to the monitor bus, so discard MIDI data */ - + uint32_t const bufs_audio = bufs.count().get (DataType::AUDIO); uint32_t const mixbufs_audio = mixbufs.count().get (DataType::AUDIO); - + /* monitor-section has same number of channels as master-bus (on creation). * * There is no clear answer what should happen when trying to PFL or AFL @@ -190,21 +190,26 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame gain_t tgain = target_gain (); - _amp->set_gain (tgain, this); + if (tgain != _current_gain) { + + /* target gain has changed */ + + _current_gain = Amp::apply_gain (mixbufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain); + + } else if (tgain == GAIN_COEFF_ZERO) { - if (tgain == GAIN_COEFF_ZERO && _amp->gain() == GAIN_COEFF_ZERO) { /* we were quiet last time, and we're still supposed to be quiet. - */ + */ _meter->reset (); Amp::apply_simple_gain (mixbufs, nframes, GAIN_COEFF_ZERO); goto out; - } + } else if (tgain != GAIN_COEFF_UNITY) { - /* These two calls will either set up gain automation or mark - the amp as ready to use a simple scalar gain. - */ + /* target gain has not changed, but is not zero or unity */ + Amp::apply_simple_gain (mixbufs, nframes, tgain); + } _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ()); _amp->setup_gain_automation (start_frame, end_frame, nframes); @@ -395,4 +400,4 @@ InternalSend::cycle_start (pframes_t /*nframes*/) for (BufferSet::audio_iterator b = mixbufs.audio_begin(); b != mixbufs.audio_end(); ++b) { b->prepare (); } -} +} diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 2167c4319c..9d5fd619c3 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -86,6 +86,7 @@ Send::Send (Session& s, boost::shared_ptr p, boost::shared_ptrset_gain_automation_buffer (_session.send_gain_automation_buffer ()); _amp->setup_gain_automation (start_frame, end_frame, nframes); -- 2.30.2