From d7e9c89138bbcad24dbdf858a04ef7c7229f133c Mon Sep 17 00:00:00 2001 From: Lars Luthman Date: Mon, 28 Mar 2011 14:20:20 +0000 Subject: Moved ui -> pui --- ext/pui.lv2/manifest.ttl | 8 ++ ext/pui.lv2/pui.h | 312 +++++++++++++++++++++++++++++++++++++++++++++++ ext/pui.lv2/pui.ttl | 187 ++++++++++++++++++++++++++++ 3 files changed, 507 insertions(+) create mode 100644 ext/pui.lv2/manifest.ttl create mode 100644 ext/pui.lv2/pui.h create mode 100644 ext/pui.lv2/pui.ttl (limited to 'ext/pui.lv2') diff --git a/ext/pui.lv2/manifest.ttl b/ext/pui.lv2/manifest.ttl new file mode 100644 index 0000000..1229118 --- /dev/null +++ b/ext/pui.lv2/manifest.ttl @@ -0,0 +1,8 @@ +@prefix lv2: . +@prefix rdfs: . + + + a lv2:Specification; + lv2:minorVersion 0; + lv2:microVersion 1; + rdfs:seeAlso . diff --git a/ext/pui.lv2/pui.h b/ext/pui.lv2/pui.h new file mode 100644 index 0000000..6af445b --- /dev/null +++ b/ext/pui.lv2/pui.h @@ -0,0 +1,312 @@ +/************************************************************************ + * + * Plugin UI extension for LV2 + * + * Copyright (C) 2006-2011 Lars Luthman + * + * Based on lv2.h, which was + * + * Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, + * Stefan Westerfeld + * Copyright (C) 2006 Steve Harris, David Robillard. + * + * This header is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, + * or (at your option) any later version. + * + * This header is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 + * USA. + * + ***********************************************************************/ + +/** + @file pui.h C API for the LV2 UI extension . + + This file specifies a C API for communication between an LV2 host and an + LV2 UI. The interface is similar to the one used for actual LV2 plugins. + + The entry point is the function lv2ui_descriptor(). +*/ + +#ifndef LV2_PUI_H +#define LV2_PUI_H + +#include + +/** The URI of this extension (note this is not the same as the prefix). */ +#define LV2_PUI_URI "http://lv2plug.in/ns/ext/pui" + +/** The numerical ID returned by LV2_PUI_Host_Descriptor::port_index() for + invalid port symbols. */ +#define LV2_PUI_INVALID_PORT_INDEX ((uint32_t)-1) + +/** The numerical ID returned by LV2_PUI_Host_Descriptor::port_protocol_id() for + invalid or unsupported PortProtocols. */ +#define LV2_PUI_INVALID_PORT_PROTOCOL_ID 0 + +/** The full URI for the pui:floatControl PortProtocol. */ +#define LV2_PUI_FLOAT_CONTROL_URI "http://lv2plug.in/ns/ext/pui#floatControl" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + A pointer to a widget or other type of UI. + The actual type is defined by the type of the UI defined in the RDF data. + All the functionality provided by this extension is toolkit independent, the + host only needs to pass the necessary callbacks and display the widget, if + possible. Plugins may have several UIs, in various toolkits. +*/ +typedef void* LV2_PUI_Widget; + +/** + Handle for a particular instance of a UI. + It is valid to compare this to NULL (0 for C++) but otherwise the host MUST + NOT attempt to interpret it. The UI may use it to reference internal + instance data. +*/ +typedef void* LV2_PUI_Handle; + +/** + Handle for host functions and data provided to a UI. + An object of this type is passed to the UI's instantiate() function, and the + UI must in turn pass it as the first parameter to the callbacks in + LV2_PUI_Host_Descriptor. The host may use it to reference internal data, such + as the plugin instance that the UI is associated with. The UI MUST NOT + interpret the value of an LV2_PUI_Host_Handle in any way. +*/ +typedef void* LV2_PUI_Host_Handle; + +/** + Host-provided functions that the UI can use to control the plugin instance. + + A pointer to an object of this type is passed to the lv2ui_descriptor() + function. + + The host MUST provide non-NULL values for all the function pointers. +*/ +typedef struct _LV2_PUI_Host_Descriptor { + + /** + Send data to one of the plugin's input ports. + + The @a buffer parameter MUST point to a block of data @a buffer_size + bytes large. The contents of this buffer and what the host should do + with it depends on the value of the @a port_protocol parameter. + + The @a port_protocol parameter MUST be a numeric ID for a + pui:PortProtocol. Numeric IDs for PortProtocols are retrieved using the + port_protocol_id() function. + + The @a buffer is only valid during the time of this function call, so if + the host wants to keep it for later use it has to copy the contents to an + internal buffer. + + @param host_handle The @a host_handle that was passed to the UI's + instantiate() function. + @param port_index The index of the port that the data should be written + to, as returned by port_index(). + @param buffer_size The size of the data pointed to by @a buffer, in + bytes. + @param port_protocol The numeric ID of the Port Protocol to use, + as returned by port_protocol_id(). + */ + void (*write_port)(LV2_PUI_Host_Handle host_handle, + uint32_t port_index, + uint32_t buffer_size, + uint32_t port_protocol, + void const* buffer); + + /** + Return the numerical index for a port. + This index is used when writing data to ports using write_port() and whe + receiving data using port_event(). If @a port_symbol is not a valid port + symbol for @a plugin the host it MUST return + LV2_PUI_INVALID_PORT_INDEX. For performance reasons it may be a good idea + to cache port indices in the UI at instantiation time. + + @param host_handle The LV2_PUI_Host_Handle that was passed to the UI's + instantiate() function. + @param port_symbol The port's symbol, as defined in the RDF data for + the plugin. + */ + uint32_t (*port_index)(LV2_PUI_Host_Handle host_handle, + char const* port_symbol); + + /** + This function is used by the UI, typically at instantiation, to get + the numeric IDs that are mapped to certain pui:PortProtocols (see + pui.ttl for details). If the host does not support the given + pui:PortProtocol it MUST return LV2_PUI_INVALID_PORT_PROTOCOL_ID, + but the UI SHOULD not rely on this to find out which protocols + are supported, it should check the @a features array passed to + instantiate() for this. + + @param host_handle The @a host_handle that was passed to the UI's + instantiate() function. + @param port_protocol_uri The URI of the pui:PortProtocol. + */ + uint32_t (*port_protocol_id)(LV2_PUI_Host_Handle host_handle, + char const* port_protocol_uri); + + /** + Subscribe to updates for a port. + This means that the host will call the UI's port_event() function when + the port value changes (as defined by the PortProtocol). + + Calling this function with the same @a port_index and @a port_protocol + as an already active subscription has no effect. + + @param host_handle The @a host_handle that was passed to the UI's + instantiate() function. + @param port_index The index of the port, as returned by port_index(). + @param port_protocol The numeric ID of the PortProtocol, as + returned by port_protocol_id(). + */ + void (*add_port_subscription)(LV2_PUI_Host_Handle host_handle, + uint32_t port_index, + uint32_t port_protocol); + + /** + Unsubscribe to updates for a port. + This means that the host will cease calling calling port_event() when + the port value changes. + + Calling this function with a @a port_index and @a port_protocol that + does not refer to an active port subscription has no effect. + + @param host_handle The @a host_handle that was passed to the UI's + instantiate() function. + @param port_index The index of the port, as returned by port_index(). + @param port_protocol The numeric ID of the PortProtocol, as + returned by port_protocol_id(). + */ + void (*remove_port_subscription)(LV2_PUI_Host_Handle host_handle, + uint32_t port_index, + uint32_t port_protocol); + +} LV2_PUI_Host_Descriptor; + +/** + This struct contains the implementation of an UI. A pointer to an + object of this type is returned by the lv2ui_descriptor() function. +*/ +typedef struct _LV2_PUI_Descriptor { + + /** + The URI for this UI (not for the plugin it controls). + */ + char const* URI; + + /** + Create a new UI object and return a handle to it. This function works + similarly to the instantiate() member in LV2_Descriptor. + + @param descriptor The descriptor for the UI to instantiate. + + @param plugin_uri The URI of the plugin that this UI will control. + + @param bundle_path The path to the bundle containing the RDF data that + references this shared object file, with trailing separator (e.g. '/'). + + @param host_descriptor A pointer to an object that contains function + pointers that the UI instance should use to control the plugin + instance. This pointer MUST be valid until cleanup() is called for this + UI instance. + + @param host_handle A handle that the host may use to reference internal + data. It MUST be passed as the first parameter to the function + pointers in @a host_descriptor, and MUST NOT be interpreted in any other + way by the UI. + + @param features A NULL-terminated array of LV2_Feature pointers. The + host must pass all feature URIs that it and the UI supports and any + additional data, just like in the LV2 plugin instantiate() + function. Note that UI features and plugin features are NOT necessarily + the same; @a features will probably not be the same array as the one the + plugin host passes to a plugin. + */ + LV2_PUI_Handle (*instantiate)(struct _LV2_PUI_Descriptor const* descriptor, + char const* plugin_uri, + char const* bundle_path, + LV2_PUI_Host_Descriptor const* host_descriptor, + LV2_PUI_Host_Handle host_handle, + LV2_Feature const* const* features); + + /** + Return the widget pointer for the UI object. + This MUST return the same value during the entire lifetime of the UI + object. + */ + LV2_PUI_Widget (*get_widget)(LV2_PUI_Handle ui); + + /** + Destroy the UI object and the associated widget. + The host must not try to access the widget after calling this function. + */ + void (*cleanup)(LV2_PUI_Handle ui); + + /** + Notify the UI that something has happened to a subscribed port. + + This is called by the host when something happens at a plugin port that + has been subscribed to using + LV2_PUI_Host_Descriptor::add_port_subscription(). + + The @a buffer is only valid during the time of this function call, so if + the UI wants to keep it for later use it has to copy the contents to an + internal buffer. + + @param ui A handle for the UI object. + @param port_index The index of the port that has changed, as returned by + LV2_PUI_Host_Descriptor::port_index(). + @param buffer_size The size of the data buffer in bytes. + @param port_protocol The format of the data buffer, as returned by + LV2_PUI_Host_Descriptor::port_protocol_id(). + @param buffer A pointer to the data buffer. + */ + void (*port_event)(LV2_PUI_Handle ui, + uint32_t port_index, + uint32_t buffer_size, + uint32_t port_protocol, + void const* buffer); + + /** + Return a data structure associated with an extension URI. + + This facility can be used by extensions to extend the LV2_PUI_Descriptor + API. This function adheres to the same rules as + LV2_Descriptor::extension_data, except it applies to UIs rather than + plugins. + */ + void const* (*extension_data)(char const* uri); + +} LV2_PUI_Descriptor; + +/** + Prototype for UI accessor function. + + This function follows the same rules as lv2_desciprotr(), except it applies + to UIs rather than plugins. +*/ +LV2_PUI_Descriptor const* lv2ui_descriptor(uint32_t index); + +/** + Type of the lv2ui_descriptor() function in a UI library. +*/ +typedef LV2_PUI_Descriptor const* (*LV2_PUI_DescriptorFunction)(uint32_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* LV2_PUI_H */ diff --git a/ext/pui.lv2/pui.ttl b/ext/pui.lv2/pui.ttl new file mode 100644 index 0000000..425047d --- /dev/null +++ b/ext/pui.lv2/pui.ttl @@ -0,0 +1,187 @@ +# LV2 Plugin UI Extension +# Copyright (C) 2010-2011 Lars Luthman +# +# Based on lv2.ttl, which is +# Copyright (C) 2006-2008 Steve Harris, David Robillard +# +# This extension should be considered a replacement for the earlier +# in-process UI extension with the URI . +# Hosts and plugins that used that extension should use this one instead. +# The earlier in-process UI extension is not compatible with LV2 revision 3 +# and later and may break in subtle ways. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +@prefix pui: . +@prefix lv2: . +@prefix rdf: . +@prefix rdfs: . +@prefix doap: . +@prefix foaf: . + + a lv2:Specification ; + doap:license ; + doap:name "LV2 UI" ; + doap:release [ + doap:revision "0.1" ; + doap:created "2011-03-26" + ]; + doap:maintainer [ + a foaf:Person; + foaf:name "Lars Luthman"; + foaf:mbox ; + ]; + lv2:documentation """ +

This extension defines an interface that can be used to create UIs for +plugins. The UIs are code that reside in shared object files in an LV2 +bundle and are referenced in the RDF data using the triples +

+  @prefix pui:     <http://lv2plug.in/ns/ext/pui#> .
+  @prefix pui-gtk: <http://lv2plug.in/ns/ext/pui-gtk#> .
+  <http://example.org/my-ui>  a             pui-gtk:GtkUI ;
+                              lv2:appliesTo <http://example.org/my-plugin> ;
+                              pui:binary     <my-ui.so> .
+
+where http://example.org/my-plugin is the URI of the plugin, +http://example.org/my-ui is the URI of the plugin UI and +my-ui.so is the relative URI to the shared object file. While it +is possible to have the plugin UI and the plugin in the same shared object file +it is probably a good idea to keep them separate so that hosts that don't want +UIs don't have to load the UI code.

+ +

A UI MUST specify its class in the RDF data and the class MUST be a proper +subclass of pui:UI, in this case pui-gtk:GtkUI. The class defines what type the +UI is, e.g. what graphics toolkit it uses. There are no UI classes defined in +this extension, those are specified separately (and anyone can define their +own).

+ +

It's entirely possible to have multiple UIs for the same plugin, or to have +the UI for a plugin in a different bundle from the actual plugin - this way +people other than the plugin author can write plugin UIs independently without +editing the original plugin bundle. It is also possible to have one UI that +works with several different plugins.

+ +

UIs should also be written in such a way that the host may load several +instances of an UI, or different UIs, and use them with the same plugin +instance.

+ +

Note that the process that loads the shared object file containing the UI +code and the process that loads the shared object file containing the actual +plugin implementation do not have to be the same. There are many valid reasons +for having the plugin and the UI in different processes, or even on different +machines. This means that you can not use singletons and global +variables and expect them to refer to the same objects in the UI and the actual +plugin. The function callback interface defined in the header pui.h is +all you can expect to work.

+""". + +############## +## UI Class ## +############## + +pui:UI a rdfs:Class; + rdfs:subClassOf lv2:Feature; + rdfs:label "UI"; + lv2:documentation """ +

The class which represents an LV2 plugin UI. +

+ +

To be used by a host a UI MUST have at least the following properties: +

+    rdf:type (with object a proper subclass of pui:UI)
+    doap:name (one without language tag)
+    lv2:binary (with a shared object file as object)
+    lv2:appliesTo (with a LV2 plugin as object)
+
+The rdf:type of an UI is used by the host to decide whether it supports the +UI and how to handle the LV2_PUI_Widget object that is returned by the UIs +get_widget() function. For example, a type of pui-gtk:GtkGUI might tell the host +that LV2_PUI_Widget is a pointer to an object of a type defined in the Gtk+ +library. No UI types are defined in this extension, that is intentionally +left for other extensions. +

+ +

The doap:name property should be at most a few words in length using title +capitalization, e.g. "Flashy Mixer GUI". Use lv2:documentation for more +detailed descriptions.

+ +

UIs may have optional or required features, specified using lv2:optionalFeature +or lv2:requiredFeature. The same rules apply here as for plugins; a host MUST +pass the LV2_Feature objects for all features it supports to the UI's +instantiate() function, a host SHOULD NOT try to instantiate an UI if it +doesn't support all of its required features, and an UI MUST fail to +instantiate if the host doesn't pass all required features to instantiate(). +

+ +

For details about the C API used to load UIs, see the file pui.h. +

+""" . + + +#################### +## Port Protocols ## +#################### + +pui:PortProtocol a rdfs:Class; + rdfs:subClassOf lv2:Feature; + rdfs:label "Port protocol"; + lv2:documentation """ +

A PortProtocol defines a certain way of communicating port data between UI +and plugin. PortProtocols can be specified in additional extensions, and +those extensions MUST specify: +

+ +

    +
  1. Which plugin port types the buffer type is valid for
  2. +
  3. When the host should call port_event() in LV2_PUI_Descriptor
  4. +
  5. The format of the data in the buffer passed to port_event()
  6. +
  7. The format of the data in the buffer passed to write_port()
  8. +
  9. What happens when the UI calls write_port() in LV2_PUI_Host_Descriptor
  10. +
  11. What data (if any) should be passed in the LV2_Feature data pointer.
  12. +

+ +

For an example, see pui:floatControl. +

+ +

PortProtocol is a subclass of lv2:Feature, so UIs use lv2:optionalFeature and +lv2:requiredFeature to specify which PortProtocols they want to use. +

+""". + +pui:floatControl a pui:PortProtocol; + rdfs:label "Floating point value"; + lv2:documentation """ +

The rules (see pui:PortProtocol) for this port protocol are:

+
    +
  1. This PortProtocol is valid for ports with the type lv2:ControlPort.
  2. +
  3. The host SHOULD call port_event() as soon as possible when the port value + has changed, but the plugin MUST NOT depend on a call for every change or + the timing of the calls. However, the host MUST do the calls in the same + order that the value changes occur in.
  4. +
  5. The format of the data in the buffer passed to port_event() is a single + float, and the buffer size is sizeof(float).
  6. +
  7. Same as 3.
  8. +
  9. The host SHOULD change the port value as soon as possible when write_port() + is called, but the UI MUST NOT depend on a change for every call or the + timing of the changes. However, the host MUST do the changes in the same + order that the function calls occur in.
  10. +
  11. The data pointer in the LV2_Feature object for this feature should be + NULL.
  12. +
+""". -- cgit v1.2.1