extensive changes to PresentationInfo API
[ardour.git] / libs / ardour / internal_send.cc
index fe57176ac7d5e213c3ae44d0965b662b74f55d3a..1c42993d4fa91247b2cce263507c4f4a58c939d0 100644 (file)
@@ -74,10 +74,10 @@ InternalSend::init_gain ()
 {
        if (_role == Listen) {
                /* send to monitor bus is always at unity */
-               _amp->set_gain (GAIN_COEFF_UNITY, this);
+               _gain_control->set_value (GAIN_COEFF_UNITY, PBD::Controllable::NoGroup);
        } else {
                /* aux sends start at -inf dB */
-               _amp->set_gain (GAIN_COEFF_ZERO, this);
+               _gain_control->set_value (GAIN_COEFF_ZERO, PBD::Controllable::NoGroup);
        }
 }
 
@@ -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);
@@ -269,7 +274,7 @@ InternalSend::get_state()
 int
 InternalSend::set_state (const XMLNode& node, int version)
 {
-       const XMLProperty* prop;
+       XMLProperty const * prop;
 
        init_gain ();