From 6877ac820b149fab1cae75633a5efd6dab5adb47 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 2 Dec 2018 02:04:21 +0100 Subject: [PATCH] Don't invalidate AU preset on load This works around async parameter-changed signal emission when loading an AU preset. A simple timeout is used to delay making the preset as modified. --- libs/ardour/ardour/audio_unit.h | 5 +++-- libs/ardour/audio_unit.cc | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 55faf4a08e..454a7d1ce0 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -228,8 +228,9 @@ class LIBARDOUR_API AUPlugin : public ARDOUR::Plugin void discover_factory_presets (); samplepos_t transport_sample; - float transport_speed; - float last_transport_speed; + float transport_speed; + float last_transport_speed; + pframes_t preset_holdoff; static void _parameter_change_listener (void* /*arg*/, void* /*src*/, const AudioUnitEvent* event, UInt64 host_time, Float32 new_value); void parameter_change_listener (void* /*arg*/, void* /*src*/, const AudioUnitEvent* event, UInt64 host_time, Float32 new_value); diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 812d004e6a..559961b0b2 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -452,6 +452,7 @@ AUPlugin::AUPlugin (AudioEngine& engine, Session& session, boost::shared_ptr 0) { + preset_holdoff -= std::min (nframes, preset_holdoff); + } + if (requires_fixed_size_buffers() && (nframes != _last_nframes)) { unit->GlobalReset(); _last_nframes = nframes; @@ -2215,6 +2221,9 @@ AUPlugin::load_preset (PresetRecord r) AUParameterListenerNotify (NULL, NULL, &changedUnit); } } + if (ret) { + preset_holdoff = std::max (_session.get_block_size() * 2.0, _session.sample_rate() * .2); + } return ret && Plugin::load_preset (r); } @@ -3500,7 +3509,11 @@ AUPlugin::parameter_change_listener (void* /*arg*/, void* src, const AudioUnitEv /* whenever we change a parameter, we request that we are NOT notified of the change, so anytime we arrive here, it means that something else (i.e. the plugin GUI) made the change. */ - Plugin::parameter_changed_externally (i->second, new_value); + if (preset_holdoff > 0) { + ParameterChangedExternally (i->second, new_value); + } else { + Plugin::parameter_changed_externally (i->second, new_value); + } break; default: break; -- 2.30.2