From c40437430acf4b65d8acb8b084eae8cd2f6f5402 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 11 Jun 2012 10:42:30 +0000 Subject: Make send automation work (#4734). git-svn-id: svn://localhost/ardour2/branches/3.0@12650 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/processor_box.cc | 2 ++ gtk2_ardour/processor_box.h | 2 +- libs/ardour/amp.cc | 23 ++++++++++++++++++++--- libs/ardour/ardour/amp.h | 5 +++++ libs/ardour/ardour/process_thread.h | 1 + libs/ardour/ardour/session.h | 1 + libs/ardour/ardour/thread_buffers.h | 1 + libs/ardour/internal_send.cc | 6 ++---- libs/ardour/process_thread.cc | 11 +++++++++++ libs/ardour/route.cc | 1 + libs/ardour/send.cc | 5 ++--- libs/ardour/session.cc | 6 ++++++ libs/ardour/thread_buffers.cc | 3 +++ 13 files changed, 56 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index fee6f6d503..525aca33e9 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -450,6 +450,8 @@ ProcessorEntry::Control::Control (Glib::RefPtr s, Glib::RefPtrChanged.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ()); } + ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &Control::control_changed)); + control_changed (); set_tooltip (); } diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index a8a84e636c..67a9e315d5 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -156,7 +156,7 @@ private: PBD::ScopedConnection active_connection; PBD::ScopedConnection name_connection; - class Control { + class Control : public sigc::trackable { public: Control (Glib::RefPtr, Glib::RefPtr, boost::shared_ptr, std::string const &); diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index 1579b5dcea..27b29d87e4 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -39,6 +39,7 @@ Amp::Amp (Session& s) , _apply_gain(true) , _apply_gain_automation(false) , _current_gain(1.0) + , _gain_automation_buffer(0) { Evoral::Parameter p (GainAutomation); /* gain range of -inf to +6dB, default 0dB */ @@ -84,7 +85,8 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, if (_apply_gain_automation) { - gain_t* gab = _session.gain_automation_buffer (); + gain_t* gab = _gain_automation_buffer; + assert (gab); for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) { Sample* const sp = i->data(); @@ -440,14 +442,19 @@ Amp::GainControl::internal_to_user (double v) const return accurate_coefficient_to_dB (v); } +/** Write gain automation for this cycle into the buffer previously passed in to + * set_gain_automation_buffer (if we are in automation playback mode and the + * transport is rolling). + */ void Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes) { Glib::Mutex::Lock am (control_lock(), Glib::TRY_LOCK); if (am.locked() && _session.transport_rolling() && _gain_control->automation_playback()) { + assert (_gain_automation_buffer); _apply_gain_automation = _gain_control->list()->curve().rt_safe_get_vector ( - start_frame, end_frame, _session.gain_automation_buffer(), nframes); + start_frame, end_frame, _gain_automation_buffer, nframes); } else { _apply_gain_automation = false; } @@ -470,4 +477,14 @@ Amp::value_as_string (boost::shared_ptr ac) const return Automatable::value_as_string (ac); } - + +/** Sets up the buffer that setup_gain_automation and ::run will use for + * gain automationc curves. Must be called before setup_gain_automation, + * and must be called with process lock held. + */ + +void +Amp::set_gain_automation_buffer (gain_t* g) +{ + _gain_automation_buffer = g; +} diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h index fa2eb98ebf..82f93d312b 100644 --- a/libs/ardour/ardour/amp.h +++ b/libs/ardour/ardour/amp.h @@ -48,6 +48,8 @@ public: bool apply_gain () const { return _apply_gain; } void apply_gain (bool yn) { _apply_gain = yn; } + void set_gain_automation_buffer (gain_t *); + void setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes); bool apply_gain_automation() const { return _apply_gain_automation; } @@ -107,6 +109,9 @@ private: float _current_gain; boost::shared_ptr _gain_control; + + /** Buffer that we should use for gain automation */ + gain_t* _gain_automation_buffer; }; diff --git a/libs/ardour/ardour/process_thread.h b/libs/ardour/ardour/process_thread.h index 36d8b8d3a7..6dd91aa305 100644 --- a/libs/ardour/ardour/process_thread.h +++ b/libs/ardour/ardour/process_thread.h @@ -29,6 +29,7 @@ public: static BufferSet& get_scratch_buffers (ChanCount count = ChanCount::ZERO); static BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO); static gain_t* gain_automation_buffer (); + static gain_t* send_gain_automation_buffer (); static pan_t** pan_automation_buffer (); protected: diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index d47734f6ae..9dd19eb2a1 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -743,6 +743,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi /* buffers for gain and pan */ gain_t* gain_automation_buffer () const; + gain_t* send_gain_automation_buffer () const; pan_t** pan_automation_buffer () const; void ensure_buffer_set (BufferSet& buffers, const ChanCount& howmany); diff --git a/libs/ardour/ardour/thread_buffers.h b/libs/ardour/ardour/thread_buffers.h index f75efa082d..be8cb42282 100644 --- a/libs/ardour/ardour/thread_buffers.h +++ b/libs/ardour/ardour/thread_buffers.h @@ -21,6 +21,7 @@ public: BufferSet* scratch_buffers; BufferSet* mix_buffers; gain_t* gain_automation_buffer; + gain_t* send_gain_automation_buffer; pan_t** pan_automation_buffer; uint32_t npan_buffers; diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index 671936b0ff..26631d0fad 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -176,10 +176,8 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame Amp::apply_simple_gain (mixbufs, nframes, tgain); } - // Can't automate gain for sends or returns yet because we need different buffers - // so that we don't overwrite the main automation data for the route amp - // _amp->setup_gain_automation (start_frame, end_frame, nframes); - + _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ()); + _amp->setup_gain_automation (start_frame, end_frame, nframes); _amp->run (mixbufs, start_frame, end_frame, nframes, true); /* consider metering */ diff --git a/libs/ardour/process_thread.cc b/libs/ardour/process_thread.cc index 55aa692001..ae7466c7f0 100644 --- a/libs/ardour/process_thread.cc +++ b/libs/ardour/process_thread.cc @@ -134,6 +134,17 @@ ProcessThread::gain_automation_buffer() return g; } +gain_t* +ProcessThread::send_gain_automation_buffer() +{ + ThreadBuffers* tb = _private_thread_buffers->get(); + assert (tb); + + gain_t* g = tb->send_gain_automation_buffer; + assert (g); + return g; +} + pan_t** ProcessThread::pan_automation_buffer() { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 1948ba14aa..f215e5d4f6 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -423,6 +423,7 @@ Route::process_output_buffers (BufferSet& bufs, /* figure out if we're going to use gain automation */ if (gain_automation_ok) { + _amp->set_gain_automation_buffer (_session.gain_automation_buffer ()); _amp->setup_gain_automation (start_frame, end_frame, nframes); } else { _amp->apply_gain_automation (false); diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 677b8c2e3b..fb5c6b7b0c 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -137,9 +137,8 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe /* gain control */ - // Can't automate gain for sends or returns yet because we need different buffers - // so that we don't overwrite the main automation data for the route amp - // _amp->setup_gain_automation (start_frame, end_frame, nframes); + _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ()); + _amp->setup_gain_automation (start_frame, end_frame, nframes); _amp->run (sendbufs, start_frame, end_frame, nframes, true); /* deliver to outputs */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 559ca64062..9267832cb1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4082,6 +4082,12 @@ Session::gain_automation_buffer() const return ProcessThread::gain_automation_buffer (); } +gain_t* +Session::send_gain_automation_buffer() const +{ + return ProcessThread::send_gain_automation_buffer (); +} + pan_t** Session::pan_automation_buffer() const { diff --git a/libs/ardour/thread_buffers.cc b/libs/ardour/thread_buffers.cc index 99dd931375..34f6f9828b 100644 --- a/libs/ardour/thread_buffers.cc +++ b/libs/ardour/thread_buffers.cc @@ -32,6 +32,7 @@ ThreadBuffers::ThreadBuffers () , scratch_buffers (new BufferSet) , mix_buffers (new BufferSet) , gain_automation_buffer (0) + , send_gain_automation_buffer (0) , pan_automation_buffer (0) , npan_buffers (0) { @@ -67,6 +68,8 @@ ThreadBuffers::ensure_buffers (ChanCount howmany) delete [] gain_automation_buffer; gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)]; + delete [] send_gain_automation_buffer; + send_gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)]; allocate_pan_automation_buffers (_engine->raw_buffer_size (DataType::AUDIO), howmany.n_audio(), false); } -- cgit v1.2.3