Revert "add an Amp to Delivery, remove it from Send, make use of this in various...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 16 Sep 2015 22:32:28 +0000 (18:32 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 16 Sep 2015 22:38:44 +0000 (18:38 -0400)
This reverts commit 601a34521c2ce1d0167ed2f3c66f2fa6eeeb6b8e.

libs/ardour/amp.cc
libs/ardour/ardour/delivery.h
libs/ardour/ardour/send.h
libs/ardour/delivery.cc
libs/ardour/internal_send.cc
libs/ardour/send.cc

index b7e639b9f5fdb357b833c30f2cd086d45abc2cd4..880fe2575ef60351f923da6afa5ce2893aad6397 100644 (file)
@@ -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 */
index 1b8ff3f87a7af535356cf2e6e424d0838317b6ce..e19eef719fca280f7e2b0d5d75306ce244eee7b8 100644 (file)
@@ -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> 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<PannerShell> _panshell;
-       boost::shared_ptr<Amp> _amp;
 
        gain_t target_gain ();
 
index df9afad55c9d30edd45b9ab589e68a9410bf2d49..17343bff96d6916bb00acea91b0a495a5779b0a7 100644 (file)
@@ -43,6 +43,7 @@ class LIBARDOUR_API Send : public Delivery
 
        bool display_to_user() const;
 
+       boost::shared_ptr<Amp> amp() const { return _amp; }
        boost::shared_ptr<PeakMeter> 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> _amp;
        boost::shared_ptr<PeakMeter> _meter;
        boost::shared_ptr<DelayLine> _delayline;
 
index 5a4fbd3e1defe3c1f5bf5cc481f36fefd29ebd60..1b8a8c5948a3f63db6d74327c15067aa777e6b1c 100644 (file)
@@ -52,7 +52,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pann
        : IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), 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> io, boost::shared_ptr<Pann
        if (_output) {
                _output->changed.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> 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> 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;
        }
 
index fe57176ac7d5e213c3ae44d0965b662b74f55d3a..e8e560c7c082fb198dd8fa9017d69babd91067c0 100644 (file)
@@ -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 ();
        }
-}
+}      
index 2167c4319c4f5ff8209e9d6c40e46ad1d5868b20..9d5fd619c3d486056c20e25dd5cc0792b3811f20 100644 (file)
@@ -86,6 +86,7 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
 
        //boost_debug_shared_ptr_mark_interesting (this, "send");
 
+       _amp.reset (new Amp (_session));
        _meter.reset (new PeakMeter (_session, name()));
 
        _delayline.reset (new DelayLine (_session, name()));
@@ -173,7 +174,7 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe
        sendbufs.read_from (bufs, nframes);
        assert(sendbufs.count() == bufs.count());
 
-       /* automatable gain control */
+       /* gain control */
 
        _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
        _amp->setup_gain_automation (start_frame, end_frame, nframes);