summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-06-11 17:14:18 +0200
committerRobin Gareus <robin@gareus.org>2014-06-11 17:14:18 +0200
commitca3c9cae6e36b3d7d0f0192fe6eb46d5e33dd2e9 (patch)
treef90b55d4fd7401834b3f59719f54b424eb5275c0 /libs
parent626b2daa8294e8ddb5526c1c6a9540f72b2bd063 (diff)
basic integration of delaylines (still un-nused)
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/debug.h1
-rw-r--r--libs/ardour/ardour/route.h3
-rw-r--r--libs/ardour/ardour/send.h11
-rw-r--r--libs/ardour/debug.cc1
-rw-r--r--libs/ardour/delivery.cc1
-rw-r--r--libs/ardour/internal_send.cc2
-rw-r--r--libs/ardour/route.cc23
-rw-r--r--libs/ardour/send.cc35
-rw-r--r--libs/ardour/session_state.cc16
9 files changed, 88 insertions, 5 deletions
diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h
index 889a99b9ca..9a7b0a495f 100644
--- a/libs/ardour/ardour/debug.h
+++ b/libs/ardour/ardour/debug.h
@@ -35,6 +35,7 @@ namespace PBD {
LIBARDOUR_API extern uint64_t SnapBBT;
LIBARDOUR_API extern uint64_t Configuration;
LIBARDOUR_API extern uint64_t Latency;
+ LIBARDOUR_API extern uint64_t LatencyCompensation;
LIBARDOUR_API extern uint64_t Peaks;
LIBARDOUR_API extern uint64_t Processors;
LIBARDOUR_API extern uint64_t ProcessThreads;
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 7eb115490d..ff06724731 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -54,6 +54,7 @@
namespace ARDOUR {
class Amp;
+class DelayLine;
class Delivery;
class IOProcessor;
class Panner;
@@ -190,6 +191,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
PeakMeter& peak_meter() { return *_meter.get(); }
const PeakMeter& peak_meter() const { return *_meter.get(); }
boost::shared_ptr<PeakMeter> shared_peak_meter() const { return _meter; }
+ boost::shared_ptr<DelayLine> delay_line() const { return _delayline; }
void flush_processors ();
@@ -547,6 +549,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
boost::shared_ptr<Amp> _amp;
boost::shared_ptr<PeakMeter> _meter;
+ boost::shared_ptr<DelayLine> _delayline;
boost::shared_ptr<Processor> the_instrument_unlocked() const;
diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h
index a9d2c5dacd..17343bff96 100644
--- a/libs/ardour/ardour/send.h
+++ b/libs/ardour/ardour/send.h
@@ -26,6 +26,7 @@
#include "ardour/ardour.h"
#include "ardour/delivery.h"
+#include "ardour/delayline.h"
namespace ARDOUR {
@@ -59,6 +60,12 @@ class LIBARDOUR_API Send : public Delivery
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out);
+ /* latency compensation */
+ void set_delay_in (framecnt_t);
+ void set_delay_out (framecnt_t);
+ framecnt_t get_delay_in () const { return _delay_in; }
+ framecnt_t get_delay_out () const { return _delay_out; }
+
void activate ();
void deactivate ();
@@ -73,6 +80,7 @@ class LIBARDOUR_API Send : public Delivery
bool _metering;
boost::shared_ptr<Amp> _amp;
boost::shared_ptr<PeakMeter> _meter;
+ boost::shared_ptr<DelayLine> _delayline;
private:
/* disallow copy construction */
@@ -82,6 +90,9 @@ class LIBARDOUR_API Send : public Delivery
int set_state_2X (XMLNode const &, int);
uint32_t _bitslot;
+
+ framecnt_t _delay_in;
+ framecnt_t _delay_out;
};
} // namespace ARDOUR
diff --git a/libs/ardour/debug.cc b/libs/ardour/debug.cc
index 869916cca8..69f2663aa8 100644
--- a/libs/ardour/debug.cc
+++ b/libs/ardour/debug.cc
@@ -31,6 +31,7 @@ uint64_t PBD::DEBUG::MidiDiskstreamIO = PBD::new_debug_bit ("mididiskstreamio");
uint64_t PBD::DEBUG::SnapBBT = PBD::new_debug_bit ("snapbbt");
uint64_t PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration");
uint64_t PBD::DEBUG::Latency = PBD::new_debug_bit ("latency");
+uint64_t PBD::DEBUG::LatencyCompensation = PBD::new_debug_bit ("latencycompensation");
uint64_t PBD::DEBUG::Peaks = PBD::new_debug_bit ("peaks");
uint64_t PBD::DEBUG::Processors = PBD::new_debug_bit ("processors");
uint64_t PBD::DEBUG::ProcessThreads = PBD::new_debug_bit ("processthreads");
diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc
index 8c12d44e51..3edf2cae69 100644
--- a/libs/ardour/delivery.cc
+++ b/libs/ardour/delivery.cc
@@ -249,6 +249,7 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf
processing pathway that wants to use this->output_buffers() for some reason.
*/
+ // TODO delayline -- latency-compensation
output_buffers().get_backend_port_addresses (ports, nframes);
// this Delivery processor is not a derived type, and thus we assume
diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc
index 17a3ca1f42..23d9221086 100644
--- a/libs/ardour/internal_send.cc
+++ b/libs/ardour/internal_send.cc
@@ -202,6 +202,8 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
_amp->setup_gain_automation (start_frame, end_frame, nframes);
_amp->run (mixbufs, start_frame, end_frame, nframes, true);
+ _delayline->run (mixbufs, start_frame, end_frame, nframes, true);
+
/* consider metering */
if (_metering) {
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 11f8ac2595..f3e7d90bbe 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -47,6 +47,7 @@
#include "ardour/internal_return.h"
#include "ardour/internal_send.h"
#include "ardour/meter.h"
+#include "ardour/delayline.h"
#include "ardour/midi_buffer.h"
#include "ardour/midi_port.h"
#include "ardour/monitor_processor.h"
@@ -142,6 +143,11 @@ Route::init ()
_output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
_output->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::output_port_count_changing, this, _1));
+ if (!is_master() && !is_monitor() && !is_auditioner()) {
+ _delayline.reset (new DelayLine (_session, _name));
+ add_processor (_delayline, PreFader);
+ }
+
/* add amp processor */
_amp.reset (new Amp (_session));
@@ -1431,7 +1437,7 @@ Route::clear_processors (Placement p)
seen_amp = true;
}
- if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs) {
+ if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline) {
/* you can't remove these */
@@ -1498,7 +1504,7 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
/* these can never be removed */
- if (processor == _amp || processor == _meter || processor == _main_outs) {
+ if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline) {
return 0;
}
@@ -1615,7 +1621,7 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams*
/* these can never be removed */
- if (processor == _amp || processor == _meter || processor == _main_outs) {
+ if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline) {
++i;
continue;
}
@@ -2580,6 +2586,9 @@ Route::set_processor_state (const XMLNode& node)
} else if (prop->value() == "meter") {
_meter->set_state (**niter, Stateful::current_state_version);
new_order.push_back (_meter);
+ } else if (prop->value() == "delay") {
+ _delayline->set_state (**niter, Stateful::current_state_version);
+ new_order.push_back (_delayline);
} else if (prop->value() == "main-outs") {
_main_outs->set_state (**niter, Stateful::current_state_version);
} else if (prop->value() == "intreturn") {
@@ -4101,6 +4110,10 @@ Route::setup_invisible_processors ()
}
}
+ if (!is_master() && !is_monitor() && !is_auditioner()) {
+ new_processors.push_front (_delayline);
+ }
+
/* MONITOR CONTROL */
if (_monitor_control && is_monitor ()) {
@@ -4257,6 +4270,10 @@ Route::non_realtime_locate (framepos_t pos)
_pannable->transport_located (pos);
}
+ if (_delayline.get()) {
+ _delayline.get()->flush();
+ }
+
{
//Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc
index 71cab46879..02365e967c 100644
--- a/libs/ardour/send.cc
+++ b/libs/ardour/send.cc
@@ -73,6 +73,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 +88,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()) {
@@ -118,6 +122,30 @@ Send::deactivate ()
}
void
+Send::set_delay_in(framecnt_t delay)
+{
+ if (!_delayline) return;
+ if (_delay_in == delay) {
+ return;
+ }
+ _delay_in = delay;
+ cerr << "SEND DELAY Pre: " << delay << "\n";
+ _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;
+ cerr << "SEND DELAY Post: " << delay << "\n";
+ _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)
{
if (_output->n_ports() == ChanCount::ZERO) {
@@ -146,6 +174,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 +331,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;
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 6a06863e9e..8999927729 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1421,7 +1421,13 @@ Session::XMLRouteFactory (const XMLNode& node, int version)
ret = track;
} else {
- boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML")));
+ enum Route::Flag flags = Route::Flag(0);
+ const XMLProperty* prop = node.property("flags");
+ if (prop) {
+ flags = Route::Flag (string_2_enum (prop->value(), flags));
+ }
+
+ boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML"), flags));
if (r->init () == 0 && r->set_state (node, version) == 0) {
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
@@ -1493,7 +1499,13 @@ Session::XMLRouteFactory_2X (const XMLNode& node, int version)
ret = track;
} else {
- boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML")));
+ enum Route::Flag flags = Route::Flag(0);
+ const XMLProperty* prop = node.property("flags");
+ if (prop) {
+ flags = Route::Flag (string_2_enum (prop->value(), flags));
+ }
+
+ boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML"), flags));
if (r->init () == 0 && r->set_state (node, version) == 0) {
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS