diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 9573db6e04..c437ac79e8 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -154,6 +154,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee void add_slave (std::shared_ptr, bool); void remove_slave (std::shared_ptr); + void set_non_realtime (bool); bool write_from_ui(uint32_t index, uint32_t protocol, @@ -226,6 +227,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee double _current_bpm; double _prev_time_scale; ///< previous Port::speed_ratio PBD::ID _insert_id; + bool _non_realtime; std::string _plugin_state_dir; uint32_t _bpm_control_port_index; uint32_t _patch_port_in_index; diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 9b6dbb8d06..c855e1ae02 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -191,6 +191,9 @@ public: void realtime_locate (bool); void monitoring_changed (); + /* use plugin for offline processing */ + virtual void set_non_realtime (bool) {} + virtual void add_slave (std::shared_ptr, bool realtime) {} virtual void remove_slave (std::shared_ptr) {} diff --git a/libs/ardour/ardour/vst3_plugin.h b/libs/ardour/ardour/vst3_plugin.h index 96269fd3e7..6f1de4792a 100644 --- a/libs/ardour/ardour/vst3_plugin.h +++ b/libs/ardour/ardour/vst3_plugin.h @@ -199,6 +199,7 @@ public: } void set_owner (ARDOUR::SessionObject* o); + void set_non_realtime (bool); void enable_io (std::vector const&, std::vector const&); @@ -297,6 +298,7 @@ private: bool _is_loading_state; bool _is_processing; int32_t _block_size; + bool _process_offline; /* ports */ struct Param { @@ -426,6 +428,7 @@ public: int set_block_size (pframes_t); void set_owner (ARDOUR::SessionObject* o); + void set_non_realtime (bool); void add_slave (std::shared_ptr, bool); void remove_slave (std::shared_ptr); diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 01aa41d36b..de50c3f8e9 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -453,6 +453,7 @@ LV2Plugin::LV2Plugin (AudioEngine& engine, , _worker(NULL) , _state_worker(NULL) , _insert_id("0") + , _non_realtime (false) , _bpm_control_port_index((uint32_t)-1) , _patch_port_in_index((uint32_t)-1) , _patch_port_out_index((uint32_t)-1) @@ -472,6 +473,7 @@ LV2Plugin::LV2Plugin (const LV2Plugin& other) , _worker(NULL) , _state_worker(NULL) , _insert_id(other._insert_id) + , _non_realtime (other._non_realtime) , _bpm_control_port_index((uint32_t)-1) , _patch_port_in_index((uint32_t)-1) , _patch_port_out_index((uint32_t)-1) @@ -1830,6 +1832,12 @@ LV2Plugin::remove_slave (std::shared_ptr p) } } +void +LV2Plugin::set_non_realtime (bool yn) +{ + _non_realtime = yn; +} + bool LV2Plugin::has_message_output() const { @@ -2790,7 +2798,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs, TempoMetric metric (tmap->metric_at (timepos_t (start0))); if (_freewheel_control_port) { - *_freewheel_control_port = _session.engine().freewheeling() ? 1.f : 0.f; + *_freewheel_control_port = _non_realtime || _session.engine().freewheeling() ? 1.f : 0.f; } if (_bpm_control_port) { @@ -3379,7 +3387,7 @@ LV2Plugin::run(pframes_t nframes, bool sync_work) if (_worker) { // Execute work synchronously if we're freewheeling (export) - _worker->set_synchronous(sync_work || session().engine().freewheeling()); + _worker->set_synchronous(sync_work || _non_realtime || session().engine().freewheeling()); } // Run the plugin for this cycle diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 86b0368842..d9f6227fa9 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -699,6 +699,12 @@ VST3Plugin::remove_slave (std::shared_ptr p) } } +void +VST3Plugin::set_non_realtime (bool yn) +{ + _plug->set_non_realtime (yn); +} + int VST3Plugin::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t end, double speed, @@ -1166,6 +1172,7 @@ VST3PI::VST3PI (std::shared_ptr m, std::string unique_ , _is_loading_state (false) , _is_processing (false) , _block_size (0) + , _process_offline (false) , _port_id_bypass (UINT32_MAX) , _owner (0) , _add_to_selection (false) @@ -1764,7 +1771,7 @@ VST3PI::update_processor () } Vst::ProcessSetup setup; - setup.processMode = AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; + setup.processMode = _process_offline || AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; setup.symbolicSampleSize = Vst::kSample32; setup.maxSamplesPerBlock = _block_size; setup.sampleRate = _context.sampleRate; @@ -1804,6 +1811,12 @@ VST3PI::set_owner (SessionObject* o) } } +void +VST3PI::set_non_realtime (bool yn) +{ + _process_offline = yn; +} + int32 VST3PI::count_channels (Vst::MediaType media, Vst::BusDirection dir, Vst::BusType type) { @@ -2315,7 +2328,7 @@ VST3PI::process (float** ins, float** outs, uint32_t n_samples) Vst::ProcessData data; data.numSamples = n_samples; - data.processMode = AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; + data.processMode = _process_offline || AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; data.symbolicSampleSize = Vst::kSample32; data.numInputs = _n_bus_in; data.numOutputs = _n_bus_out;