Automation of LV2 plugin properties.
[ardour.git] / libs / ardour / send.cc
index 71cab468794bd26e576cc8f2605022d21bcb3176..87aadf4193ce339b8f5749829111b8f29785b59f 100644 (file)
 #include "pbd/boost_debug.h"
 
 #include "ardour/amp.h"
-#include "ardour/send.h"
-#include "ardour/session.h"
 #include "ardour/buffer_set.h"
-#include "ardour/meter.h"
+#include "ardour/debug.h"
 #include "ardour/io.h"
+#include "ardour/meter.h"
 #include "ardour/panner_shell.h"
+#include "ardour/send.h"
+#include "ardour/session.h"
 
 #include "i18n.h"
 
@@ -73,6 +74,8 @@ Send::name_and_id_new_send (Session& s, Role r, uint32_t& bitslot, bool ignore_b
 Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMaster> mm, Role r, bool ignore_bitslot)
        : Delivery (s, p, mm, name_and_id_new_send (s, r, _bitslot, ignore_bitslot), r)
        , _metering (false)
+       , _delay_in (0)
+       , _delay_out (0)
 {
        if (_role == Listen) {
                /* we don't need to do this but it keeps things looking clean
@@ -86,6 +89,8 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
        _amp.reset (new Amp (_session));
        _meter.reset (new PeakMeter (_session, name()));
 
+       _delayline.reset (new DelayLine (_session, name()));
+
        add_control (_amp->gain_control ());
 
        if (panner_shell()) {
@@ -117,6 +122,35 @@ Send::deactivate ()
        Processor::deactivate ();
 }
 
+void
+Send::set_delay_in(framecnt_t delay)
+{
+       if (!_delayline) return;
+       if (_delay_in == delay) {
+               return;
+       }
+       _delay_in = delay;
+
+       DEBUG_TRACE (DEBUG::LatencyCompensation,
+                       string_compose ("Send::set_delay_in(%1) + %2 = %3\n",
+                               delay, _delay_out, _delay_out + _delay_in));
+       _delayline.get()->set_delay(_delay_out + _delay_in);
+}
+
+void
+Send::set_delay_out(framecnt_t delay)
+{
+       if (!_delayline) return;
+       if (_delay_out == delay) {
+               return;
+       }
+       _delay_out = delay;
+       DEBUG_TRACE (DEBUG::LatencyCompensation,
+                       string_compose ("Send::set_delay_out(%1) + %2 = %3\n",
+                               delay, _delay_in, _delay_out + _delay_in));
+       _delayline.get()->set_delay(_delay_out + _delay_in);
+}
+
 void
 Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
 {
@@ -146,6 +180,8 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe
        _amp->setup_gain_automation (start_frame, end_frame, nframes);
        _amp->run (sendbufs, start_frame, end_frame, nframes, true);
 
+       _delayline->run (sendbufs, start_frame, end_frame, nframes, true);
+
        /* deliver to outputs */
 
        Delivery::run (sendbufs, start_frame, end_frame, nframes, true);
@@ -301,6 +337,11 @@ Send::configure_io (ChanCount in, ChanCount out)
                return false;
        }
 
+       if (_delayline && !_delayline->configure_io(in, out)) {
+               cerr << "send delayline config failed\n";
+               return false;
+       }
+
        reset_panner ();
 
        return true;