implement lv2:designation processing#enable (for bypass ports)
authorRobin Gareus <robin@gareus.org>
Tue, 5 Jul 2016 17:14:25 +0000 (19:14 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 5 Jul 2016 21:30:21 +0000 (23:30 +0200)
libs/ardour/ardour/lv2_extensions.h
libs/ardour/ardour/lv2_plugin.h
libs/ardour/lv2_plugin.cc

index e299b0864acb639f3fdf64e54f04ca0d415d77da..64fc3bc615cf13e69a934e419cc7b008715427b3 100644 (file)
@@ -139,4 +139,36 @@ typedef struct _LV2_License_Interface {
    @}
 */
 
+/**
+   @defgroup plugin provided bypass
+
+        A port with the designation "processing#enable" must
+        control a plugin's internal bypass mode.
+
+        If the port value is larger than zero the plugin processes
+        normally.
+
+        If the port value is zero, the plugin is expected to bypass
+        all signals unmodified.
+
+        The plugin is responsible for providing a click-free transition
+        between the states.
+
+        (values less than zero are reserved for future use:
+        e.g click-free insert/removal of latent plugins.
+        Generally values <= 0 are to be treated as bypassed.)
+
+   lv2:designation <http://ardour.org/lv2/processing#enable> ;
+
+   @{
+*/
+
+#define LV2_PROCESSING_URI "http://ardour.org/lv2/processing"
+#define LV2_PROCESSING_URI_PREFIX LV2_PROCESSING_URI "#"
+#define LV2_PROCESSING_URI__enable LV2_PROCESSING_URI_PREFIX "enable"
+
+/**
+   @}
+*/
+
 #endif
index 9d4e2d1f68719ad308b31fcd20971b7732604ec6..cbd7a7abc2b550d64d982ef219fc51ffc0d847b4 100644 (file)
@@ -126,6 +126,8 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        bool parameter_is_output (uint32_t) const;
        bool parameter_is_toggled (uint32_t) const;
 
+       uint32_t designated_bypass_port ();
+
        boost::shared_ptr<ScalePoints>
        get_scale_points(uint32_t port_index) const;
 
index f33c9db6ac4ec678680c305c7d66813f6cb187dc..228fd741173dfd075ce3d2c10eaa47b2dc4dd593 100644 (file)
@@ -2703,6 +2703,22 @@ LV2Plugin::parameter_is_input(uint32_t param) const
        return _port_flags[param] & PORT_INPUT;
 }
 
+uint32_t
+LV2Plugin::designated_bypass_port ()
+{
+#ifdef LV2_EXTENDED
+       const LilvPort* port = NULL;
+       LilvNode* designation = lilv_new_uri (_world.world, LV2_PROCESSING_URI__enable);
+       port = lilv_plugin_get_port_by_designation (
+                       _impl->plugin, _world.lv2_InputPort, designation);
+       lilv_node_free(designation);
+       if (port) {
+               return lilv_port_get_index (_impl->plugin, port);
+       }
+#endif
+       return UINT32_MAX;
+}
+
 void
 LV2Plugin::print_parameter(uint32_t param, char* buf, uint32_t len) const
 {