From 3be01ea502addb80f191ff504b4d58b0a0012be9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 26 May 2014 06:58:44 +0200 Subject: [PATCH] apply gain automation on bounce - fixes 5887 --- libs/ardour/amp.cc | 5 ++++- libs/ardour/ardour/session.h | 2 ++ libs/ardour/route.cc | 3 +++ libs/ardour/session.cc | 22 ++++++++++------------ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index 132be2e1c6..29032525f2 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -435,7 +435,10 @@ Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framec { Glib::Threads::Mutex::Lock am (control_lock(), Glib::Threads::TRY_LOCK); - if (am.locked() && _session.transport_rolling() && _gain_control->automation_playback()) { + if (am.locked() + && (_session.transport_rolling() || _session.bounce_processing()) + && _gain_control->automation_playback()) + { assert (_gain_automation_buffer); _apply_gain_automation = _gain_control->list()->curve().rt_safe_get_vector ( start_frame, end_frame, _gain_automation_buffer, nframes); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index a2949c59cc..5f1c02f805 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -994,6 +994,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void unblock_processing() { g_atomic_int_set (&processing_prohibited, 0); } bool processing_blocked() const { return g_atomic_int_get (&processing_prohibited); } + static const framecnt_t bounce_chunk_size; + /* slave tracking */ static const int delta_accumulator_size = 25; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 24cb5aabff..4b899197d2 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -545,6 +545,9 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes, return; } + _amp->set_gain_automation_buffer (_session.gain_automation_buffer ()); + _amp->setup_gain_automation (start, start + nframes, nframes); + for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { if (!include_endpoint && (*i) == endpoint) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index d6add56c6b..04c86dc979 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -125,6 +125,7 @@ PBD::Signal0 Session::FeedbackDetected; PBD::Signal0 Session::SuccessfulGraphSort; PBD::Signal2 Session::VersionMismatch; +const framecnt_t Session::bounce_chunk_size = 65536; static void clean_up_session_event (SessionEvent* ev) { delete ev; } const SessionEvent::RTeventCallback Session::rt_cleanup (clean_up_session_event); @@ -3882,7 +3883,7 @@ Session::update_locations_after_tempo_map_change (Locations::LocationList& loc) void Session::ensure_buffers (ChanCount howmany) { - BufferManager::ensure_buffers (howmany); + BufferManager::ensure_buffers (howmany, bounce_processing() ? bounce_chunk_size : 0); } void @@ -4156,8 +4157,6 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, return result; } - const framecnt_t chunk_size = (256 * 1024)/4; - // block all process callback handling block_processing (); @@ -4172,8 +4171,6 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, _bounce_processing_active = true; - _engine.main_thread()->get_buffers (); - /* call tree *MUST* hold route_lock */ if ((playlist = track.playlist()) == 0) { @@ -4215,7 +4212,8 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, */ need_block_size_reset = true; - track.set_block_size (chunk_size); + track.set_block_size (bounce_chunk_size); + _engine.main_thread()->get_buffers (); position = start; to_do = len; @@ -4223,7 +4221,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, /* create a set of reasonably-sized buffers */ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { - buffers.ensure_buffers(*t, max_proc.get(*t), chunk_size); + buffers.ensure_buffers(*t, max_proc.get(*t), bounce_chunk_size); } buffers.set_count (max_proc); @@ -4235,7 +4233,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, while (to_do && !itt.cancel) { - this_chunk = min (to_do, chunk_size); + this_chunk = min (to_do, bounce_chunk_size); if (track.export_stuff (buffers, start, this_chunk, endpoint, include_endpoint, for_export)) { goto out; @@ -4245,8 +4243,8 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, to_do -= this_chunk; itt.progress = (float) (1.0 - ((double) to_do / len)); - if (latency_skip >= chunk_size) { - latency_skip -= chunk_size; + if (latency_skip >= bounce_chunk_size) { + latency_skip -= bounce_chunk_size; continue; } @@ -4269,7 +4267,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, latency_skip = track.bounce_get_latency (endpoint, include_endpoint, for_export); while (latency_skip && !itt.cancel) { - this_chunk = min (latency_skip, chunk_size); + this_chunk = min (latency_skip, bounce_chunk_size); latency_skip -= this_chunk; buffers.silence (this_chunk, 0); @@ -4316,7 +4314,6 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, } out: - _engine.main_thread()->drop_buffers (); if (!result) { for (vector >::iterator src = srcs.begin(); src != srcs.end(); ++src) { boost::shared_ptr afs = boost::dynamic_pointer_cast(*src); @@ -4340,6 +4337,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, _bounce_processing_active = false; if (need_block_size_reset) { + _engine.main_thread()->drop_buffers (); track.set_block_size (get_block_size()); }