From 8175db5b0118db15c3ed9bfbd664f37eecca99bc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 25 Jan 2021 02:07:34 +0100 Subject: [PATCH] Prepare variable I/O --- libs/ardour/ardour/vst3_plugin.h | 14 +++++- libs/ardour/plugin_insert.cc | 5 +++ libs/ardour/vst3_plugin.cc | 73 +++++++++++++++++++++++++++----- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/libs/ardour/ardour/vst3_plugin.h b/libs/ardour/ardour/vst3_plugin.h index 5798ecb8c7..68a6f83b2f 100644 --- a/libs/ardour/ardour/vst3_plugin.h +++ b/libs/ardour/ardour/vst3_plugin.h @@ -132,8 +132,12 @@ public: ARDOUR::Plugin::IOPortDescription describe_io_port (ARDOUR::DataType dt, bool input, uint32_t id) const; - uint32_t n_audio_inputs () const; - uint32_t n_audio_outputs () const; + uint32_t n_audio_inputs (bool with_aux = true) const; + uint32_t n_audio_outputs (bool with_aux = true) const; + + uint32_t n_audio_aux_in () const { return _n_aux_inputs; } + uint32_t n_audio_aux_out () const { return _n_aux_outputs; } + /* MIDI/Event interface */ void cycle_start (); @@ -199,6 +203,7 @@ private: bool disconnect_components (); bool update_processor (); + void update_channelcount (); int32 count_channels (Vst::MediaType, Vst::BusDirection, Vst::BusType); bool evoral_to_vst3 (Vst::Event&, Evoral::Event const&, int32_t); @@ -330,6 +335,8 @@ public: bool parameter_is_input (uint32_t) const; bool parameter_is_output (uint32_t) const; + bool reconfigure_io (ChanCount, ChanCount, ChanCount); + uint32_t designated_bypass_port (); std::set automatable () const; @@ -400,6 +407,9 @@ private: std::vector _connected_inputs; std::vector _connected_outputs; + + ChanCount _configured_in; + ChanCount _configured_out; }; /* ****************************************************************************/ diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index ebb777da2d..b01466da95 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -2001,6 +2001,11 @@ PluginInsert::configure_io (ChanCount in, ChanCount out) } } break; + + case Replicate: + assert (get_count () > 1); + break; + default: if (_plugins.front()->reconfigure_io (in, aux_in, out) == false) { PluginIoReConfigure (); /* EMIT SIGNAL */ diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 8813d56f1f..9b6f067870 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -137,6 +137,46 @@ VST3Plugin::parameter_change_handler (VST3PI::ParameterChange t, uint32_t param, } } +/* ***************************************************************************/ + +bool +VST3Plugin::reconfigure_io (ChanCount in, ChanCount aux_in, ChanCount out) +{ + std::cerr << "VST3Plugin::reconfigure_io: in: " << in << " aux_in: " << aux_in << " out: " << out << "\n"; + _configured_in = in + aux_in; + _configured_out = out; + +#if 0 + _info->n_inputs = in; + _info->n_outputs = out; +#endif + + /* apply new portlayout */ + _connected_inputs.clear (); + _connected_outputs.clear (); + /* assume all I/O is connected by default */ + for (uint32_t i = 0; i < _configured_in.n_audio (); ++i) { + _connected_inputs.push_back (true); + } + for (uint32_t i = 0; i < _configured_out.n_audio (); ++i) { + _connected_outputs.push_back (true); + } + +#if 1 + while (_connected_inputs.size () < _plug->n_audio_inputs ()) { + _connected_inputs.push_back (false); + } + while (_connected_outputs.size () < _plug->n_audio_outputs ()) { + _connected_outputs.push_back (false); + } +#endif + + /* pre-configure from GUI thread */ + _plug->enable_io (_connected_inputs, _connected_outputs); + + return true; +} + /* **************************************************************************** * Parameter API */ @@ -1080,13 +1120,7 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu _busbuf_in.reserve (_n_bus_in); _busbuf_out.reserve (_n_bus_out); - /* do not re-order, _io_name is build in sequence */ - _n_inputs = count_channels (Vst::kAudio, Vst::kInput, Vst::kMain); - _n_aux_inputs = count_channels (Vst::kAudio, Vst::kInput, Vst::kAux); - _n_outputs = count_channels (Vst::kAudio, Vst::kOutput, Vst::kMain); - _n_aux_outputs = count_channels (Vst::kAudio, Vst::kOutput, Vst::kAux); - _n_midi_inputs = count_channels (Vst::kEvent, Vst::kInput, Vst::kMain); - _n_midi_outputs = count_channels (Vst::kEvent, Vst::kOutput, Vst::kMain); + update_channelcount (); if (!connect_components ()) { //_controller->terminate(); // XXX ? @@ -1575,6 +1609,23 @@ VST3PI::count_channels (Vst::MediaType media, Vst::BusDirection dir, Vst::BusTyp return n_channels; } +void +VST3PI::update_channelcount () +{ + _io_name[Vst::kAudio][0].clear(); + _io_name[Vst::kAudio][1].clear(); + _io_name[Vst::kEvent][0].clear(); + _io_name[Vst::kEvent][1].clear(); + + /* do not re-order, _io_name is build in sequence */ + _n_inputs = count_channels (Vst::kAudio, Vst::kInput, Vst::kMain); + _n_aux_inputs = count_channels (Vst::kAudio, Vst::kInput, Vst::kAux); + _n_outputs = count_channels (Vst::kAudio, Vst::kOutput, Vst::kMain); + _n_aux_outputs = count_channels (Vst::kAudio, Vst::kOutput, Vst::kAux); + _n_midi_inputs = count_channels (Vst::kEvent, Vst::kInput, Vst::kMain); + _n_midi_outputs = count_channels (Vst::kEvent, Vst::kOutput, Vst::kMain); +} + Vst::ParamID VST3PI::index_to_id (uint32_t p) const { @@ -1645,15 +1696,15 @@ VST3PI::print_parameter (Vst::ParamID id, Vst::ParamValue value) const } uint32_t -VST3PI::n_audio_inputs () const +VST3PI::n_audio_inputs (bool with_aux) const { - return _n_inputs + _n_aux_inputs; + return _n_inputs + (with_aux ? _n_aux_inputs : 0); } uint32_t -VST3PI::n_audio_outputs () const +VST3PI::n_audio_outputs (bool with_aux) const { - return _n_outputs + _n_aux_outputs; + return _n_outputs +(with_aux ? _n_aux_outputs : 0); } uint32_t