summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2019-08-19 13:19:38 -0500
committerRobin Gareus <robin@gareus.org>2019-08-19 23:28:04 +0200
commit031847f88ef8c266df97f38fccf094fb0c78356e (patch)
treef5e1cde2693a1730ae6f1f46354ab3c6f67e8f69
parent8775087ea6280d4c553be5579e94e8b84e9b3bad (diff)
LV2 extension to override strict-i/o per plugin
This allows mono to stereo plugins to override the default routing and forces both outputs to be connected.
-rw-r--r--libs/ardour/ardour/lv2_extensions.h23
-rw-r--r--libs/ardour/ardour/lv2_plugin.h2
-rw-r--r--libs/ardour/ardour/plugin.h2
-rw-r--r--libs/ardour/lv2_plugin.cc14
-rw-r--r--libs/ardour/plugin_insert.cc6
5 files changed, 47 insertions, 0 deletions
diff --git a/libs/ardour/ardour/lv2_extensions.h b/libs/ardour/ardour/lv2_extensions.h
index 027eb0391b..13ceac4cbd 100644
--- a/libs/ardour/ardour/lv2_extensions.h
+++ b/libs/ardour/ardour/lv2_extensions.h
@@ -180,6 +180,29 @@ typedef struct _LV2_License_Interface {
@}
*/
+
+/**
+ @defgroup plugin port/routing control
+
+ This is a "feature" to simplify per port meta-data of
+ http://lv2plug.in/ns/ext/port-groups/port-groups.html#source
+
+ Plugins using this feature provide a strong hint that the host
+ should always connect all audio output-ports.
+
+ This allows mono->stereo plugins to override strict_io rules.
+
+ @{
+*/
+
+#define LV2_ROUTING_URI "http://harrisonconsoles.com/lv2/routing"
+#define LV2_ROUTING_PREFIX LV2_ROUTING_URI "#"
+#define LV2_ROUTING__connectAllOutputs LV2_ROUTING_PREFIX "connectAllOutputs"
+
+/**
+ @}
+*/
+
/**
@defgroup midnam MIDI Naming
diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h
index be1e2af85e..734a8d7e21 100644
--- a/libs/ardour/ardour/lv2_plugin.h
+++ b/libs/ardour/ardour/lv2_plugin.h
@@ -113,6 +113,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
int set_block_size (pframes_t);
bool requires_fixed_sized_buffers () const;
+ bool connect_all_audio_outputs () const;
int connect_and_run (BufferSet& bufs,
samplepos_t start, samplepos_t end, double speed,
@@ -201,6 +202,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
uint32_t _patch_port_out_index;
URIMap& _uri_map;
bool _no_sample_accurate_ctrl;
+ bool _connect_all_audio_outputs;
bool _can_write_automation;
samplecnt_t _max_latency;
samplecnt_t _current_latency;
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index 59f2ed86f5..04879eb95c 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -113,8 +113,10 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public HasLatency
virtual void flush () { deactivate(); activate(); }
virtual int set_block_size (pframes_t nframes) = 0;
+
virtual bool requires_fixed_sized_buffers() const { return false; }
virtual bool inplace_broken() const { return false; }
+ virtual bool connect_all_audio_outputs () const { return false; }
virtual int connect_and_run (BufferSet& bufs,
samplepos_t start, samplepos_t end, double speed,
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index 09c352c39b..6c23472b68 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -202,6 +202,7 @@ public:
#endif
#ifdef LV2_EXTENDED
LilvNode* lv2_noSampleAccurateCtrl;
+ LilvNode* routing_connectAllOutputs; // lv2:optionalFeature
LilvNode* auto_can_write_automatation; // lv2:optionalFeature
LilvNode* auto_automation_control; // atom:supports
LilvNode* auto_automation_controlled; // lv2:portProperty
@@ -369,6 +370,7 @@ LV2Plugin::LV2Plugin (AudioEngine& engine,
, _patch_port_out_index((uint32_t)-1)
, _uri_map(URIMap::instance())
, _no_sample_accurate_ctrl (false)
+ , _connect_all_audio_outputs (false)
{
init(c_plugin, rate);
latency_compute_run();
@@ -387,6 +389,7 @@ LV2Plugin::LV2Plugin (const LV2Plugin& other)
, _patch_port_out_index((uint32_t)-1)
, _uri_map(URIMap::instance())
, _no_sample_accurate_ctrl (false)
+ , _connect_all_audio_outputs (false)
{
init(other._impl->plugin, other._sample_rate);
@@ -628,6 +631,9 @@ LV2Plugin::init(const void* c_plugin, samplecnt_t rate)
/* deprecated 2016-Sep-18 in favor of bufz_coarseBlockLength */
_no_sample_accurate_ctrl = true;
}
+ if (lilv_nodes_contains (optional_features, _world.routing_connectAllOutputs)) {
+ _connect_all_audio_outputs = true;
+ }
if (lilv_nodes_contains (optional_features, _world.auto_can_write_automatation)) {
_can_write_automation = true;
}
@@ -908,6 +914,12 @@ LV2Plugin::requires_fixed_sized_buffers () const
return _no_sample_accurate_ctrl;
}
+bool
+LV2Plugin::connect_all_audio_outputs () const
+{
+ return _connect_all_audio_outputs;
+}
+
LV2Plugin::~LV2Plugin ()
{
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 destroy\n", name()));
@@ -3252,6 +3264,7 @@ LV2World::LV2World()
opts_requiredOptions = lilv_new_uri(world, LV2_OPTIONS__requiredOption);
#ifdef LV2_EXTENDED
lv2_noSampleAccurateCtrl = lilv_new_uri(world, "http://ardour.org/lv2/ext#noSampleAccurateControls"); // deprecated 2016-09-18
+ routing_connectAllOutputs = lilv_new_uri(world, LV2_ROUTING__connectAllOutputs);
auto_can_write_automatation = lilv_new_uri(world, LV2_AUTOMATE_URI__can_write);
auto_automation_control = lilv_new_uri(world, LV2_AUTOMATE_URI__control);
auto_automation_controlled = lilv_new_uri(world, LV2_AUTOMATE_URI__controlled);
@@ -3275,6 +3288,7 @@ LV2World::~LV2World()
lilv_node_free(bufz_powerOf2BlockLength);
#ifdef LV2_EXTENDED
lilv_node_free(lv2_noSampleAccurateCtrl);
+ lilv_node_free(routing_connectAllOutputs);
lilv_node_free(auto_can_write_automatation);
lilv_node_free(auto_automation_control);
lilv_node_free(auto_automation_controlled);
diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc
index bbd5b0baad..c63066154a 100644
--- a/libs/ardour/plugin_insert.cc
+++ b/libs/ardour/plugin_insert.cc
@@ -112,8 +112,14 @@ PluginInsert::~PluginInsert ()
void
PluginInsert::set_strict_io (bool b)
{
+ if (_plugins.front()->connect_all_audio_outputs ()) {
+ /* Ignore route setting, allow plugin to add/remove ports */
+ b = false;
+ }
+
bool changed = _strict_io != b;
_strict_io = b;
+
if (changed) {
PluginConfigChanged (); /* EMIT SIGNAL */
}