summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:37:57 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-01-23 20:37:57 +0100
commit8cd3f1729a417d933744cf64e2adf78dc07e265c (patch)
tree8d677dced9b5efcb670dd3b04d7426a56e1ff96d
parent4a4d0a84bb1b80555052f59c1a4addc870ce5fda (diff)
Make plugin store its state. Connect state and GUI (and use GUI)
-rw-r--r--lv2/Makefile.am31
-rw-r--r--lv2/drumgizmo.ttl16
-rw-r--r--lv2/input_lv2.h5
-rw-r--r--lv2/lv2.cc114
-rw-r--r--lv2/lv2_gui.cc256
-rw-r--r--lv2/lv2_gui.h39
-rw-r--r--lv2/lv2_instance.h48
-rw-r--r--lv2/lv2_state.h354
-rw-r--r--lv2/lv2_ui.h372
-rw-r--r--lv2/lv2_uri_map.h86
-rw-r--r--lv2/output_lv2.cc18
-rw-r--r--lv2/output_lv2.h13
12 files changed, 1307 insertions, 45 deletions
diff --git a/lv2/Makefile.am b/lv2/Makefile.am
index a57fa97..b6d1263 100644
--- a/lv2/Makefile.am
+++ b/lv2/Makefile.am
@@ -1,7 +1,8 @@
if ENABLE_LV2
-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include $(SNDFILE_CXXFLAGS) \
- $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(LV2_CFLAGS)
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/plugingui \
+ -I$(top_srcdir)/include $(SNDFILE_CXXFLAGS) \
+ $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(LV2_CFLAGS) -DX11 -DSSE -msse -msse2 -msse3
plugindir = $(libdir)/lv2/drumgizmo.lv2
plugin_LTLIBRARIES = drumgizmo.la
@@ -14,29 +15,17 @@ EXTRA_DIST = \
lv2_event.h \
event-helpers.h
+include $(top_srcdir)/plugingui/Makefile.am.plugingui
+include $(top_srcdir)/src/Makefile.am.drumgizmo
drumgizmo_la_SOURCES = \
+ $(DRUMGIZMO_SOURCES) \
+ $(PLUGIN_GUI_SOURCES) \
lv2.cc \
+ lv2_gui.cc \
input_lv2.cc \
- output_lv2.cc \
- $(top_srcdir)/src/audiofile.cc \
- $(top_srcdir)/src/channel.cc \
- $(top_srcdir)/src/channelmixer.cc \
- $(top_srcdir)/src/configuration.cc \
- $(top_srcdir)/src/drumgizmo.cc \
- $(top_srcdir)/src/drumkit.cc \
- $(top_srcdir)/src/drumkitparser.cc \
- $(top_srcdir)/src/events.cc \
- $(top_srcdir)/src/instrument.cc \
- $(top_srcdir)/src/instrumentparser.cc \
- $(top_srcdir)/src/midimapparser.cc \
- $(top_srcdir)/src/midimapper.cc \
- $(top_srcdir)/src/mutex.cc \
- $(top_srcdir)/src/path.cc \
- $(top_srcdir)/src/sample.cc \
- $(top_srcdir)/src/saxparser.cc \
- $(top_srcdir)/src/velocity.cc
+ output_lv2.cc
drumgizmo_la_LDFLAGS = -module -avoid-version
-drumgizmo_la_LIBADD = $(SNDFILE_LIBS) $(EXPAT_LIBS) $(LV2_LIBS) -lX11
+drumgizmo_la_LIBADD = $(LV2_LIBS) $(PLUGIN_GUI_LIBS) $(DRUMGIZMO_LIBS)
endif
diff --git a/lv2/drumgizmo.ttl b/lv2/drumgizmo.ttl
index 97d3542..73af11e 100644
--- a/lv2/drumgizmo.ttl
+++ b/lv2/drumgizmo.ttl
@@ -17,13 +17,21 @@
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix lv2ev: <http://lv2plug.in/ns/ext/event#> .
+@prefix uiext: <http://lv2plug.in/ns/extensions/ui#> .
+@prefix state: <http://lv2plug.in/ns/ext/state#> .
+
+<http://drumgizmo.org/lv2-gui>
+ a uiext:external ;
+ uiext:binary <drumgizmo.so> .
<http://drumgizmo.org/lv2>
- a lv2:Plugin ;
+ a lv2:InstrumentPlugin ;
doap:name "DrumGizmo" ;
- doap:license <http://opensource.org/licenses/isc-license> ;
- lv2:requiredFeature <http://lv2plug.in/ns/ext/uri-map>;
- lv2:optionalFeature <http://lv2plug.in/ns/ext/event>;
+ uiext:ui <http://drumgizmo.org/lv2-gui> ;
+ doap:license <http://opensource.org/licenses/gpl-3.0> ;
+ lv2:optionalFeature <http://lv2plug.in/ns/ext/uri-map> ;
+ lv2:optionalFeature <http://lv2plug.in/ns/ext/event> ;
+ lv2:extensionData state:Interface ;
lv2:port [
a lv2:InputPort ,
lv2ev:EventPort ;
diff --git a/lv2/input_lv2.h b/lv2/input_lv2.h
index 73f242a..d6d4727 100644
--- a/lv2/input_lv2.h
+++ b/lv2/input_lv2.h
@@ -48,9 +48,14 @@ public:
event_t *run(size_t pos, size_t len, size_t *nevents);
void post();
+ void loadMidiMap(std::string file);
+
LV2_Event_Buffer *eventPort;
MidiMapper mmap;
+
+private:
+ Instruments *instruments;
};
#endif/*__DRUMGIZMO_INPUT_LV2_H__*/
diff --git a/lv2/lv2.cc b/lv2/lv2.cc
index 346b0dc..3fdd7e1 100644
--- a/lv2/lv2.cc
+++ b/lv2/lv2.cc
@@ -28,20 +28,82 @@
#include <stdlib.h>
-#include <drumgizmo.h>
+#include "lv2_gui.h"
+#include "lv2_state.h"
-#include "input_lv2.h"
-#include "output_lv2.h"
+#include "lv2_instance.h"
#define MIDI_EVENT_URI "http://lv2plug.in/ns/ext/midi#MidiEvent"
-typedef struct {
- InputLV2 *in;
- OutputLV2 *out;
- DrumGizmo *dg;
- sample_t *buffer;
- size_t buffer_size;
-} DGLV2;
+#define NS_ATOM "http://lv2plug.in/ns/ext/atom#"
+#define NS_DG "http://drumgizmo.org/lv2/atom#"
+
+/*
+ * Stuff to handle DrumGizmo* transmission from instance to GUI.
+ */
+static LV2_DrumGizmo_Descriptor dg_descriptor;
+
+static DrumGizmo *dg_get_pci(LV2_Handle instance)
+{
+ DGLV2 *dglv2 = (DGLV2 *)instance;
+ return dglv2->dg;
+}
+
+
+/*
+ * Stuff to save/restore plugin state.
+ */
+void dg_save(LV2_Handle instance,
+ LV2_State_Store_Function store,
+ void* callback_data,
+ uint32_t flags,
+ const LV2_Feature *const * features)
+{
+ DGLV2 *dglv2 = (DGLV2 *)instance;
+ printf("dg_save\n");
+
+ std::string config = dglv2->dg->configString();
+ printf("%s\n", config.c_str());
+
+ store(callback_data,
+ dglv2->urimap->uri_to_id(dglv2->urimap->callback_data,
+ NULL, NS_DG "config"),
+ config.data(), config.length(),
+ dglv2->urimap->uri_to_id(dglv2->urimap->callback_data,
+ NULL, NS_ATOM "String"),
+ LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
+}
+
+void dg_restore(LV2_Handle instance,
+ LV2_State_Retrieve_Function retrieve,
+ void* callback_data,
+ uint32_t flags,
+ const LV2_Feature *const * features)
+{
+ DGLV2 *dglv2 = (DGLV2 *)instance;
+ printf("dg_restore\n");
+
+ size_t size;
+ uint32_t type;
+ // uint32_t flags;
+
+ const char* data =
+ (const char*)retrieve(callback_data,
+ dglv2->urimap->uri_to_id(dglv2->urimap->callback_data,
+ NULL, NS_DG "config"),
+ &size, &type, &flags);
+ std::string config;
+ config.append(data, size);
+ dglv2->dg->setConfigString(config);
+
+ dglv2->in->loadMidiMap(dglv2->dg->midimapfile);
+}
+
+
+static LV2_State_Interface dg_persist = {
+ dg_save,
+ dg_restore
+};
/** A globally unique, case-sensitive identifier for this plugin type.
*
@@ -86,6 +148,16 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor,
{
DGLV2 *dglv2 = new DGLV2;
+ dglv2->urimap = NULL;
+ for (int i = 0 ; features[i] ; i++) {
+ printf("DG: feature: %s\n", features[i]->URI);
+ if (!strcmp(features[i]->URI, LV2_URI_MAP_URI)) {
+ dglv2->urimap = (LV2_URI_Map_Feature*)features[i]->data;
+ }
+ }
+
+ dg_descriptor.get_pci = dg_get_pci;
+
dglv2->in = new InputLV2();
dglv2->out = new OutputLV2();
@@ -93,8 +165,8 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor,
dglv2->buffer_size = 0;
dglv2->dg = new DrumGizmo(dglv2->out, dglv2->in);
- dglv2->dg->loadkit(getenv("DRUMGIZMO_DRUMKIT"));
- dglv2->dg->init(true);
+ // dglv2->dg->loadkit(getenv("DRUMGIZMO_DRUMKIT"));
+ // dglv2->dg->init(true);
return (LV2_Handle)dglv2;
}
@@ -143,8 +215,10 @@ void connect_port(LV2_Handle instance,
if(port == 0) {// MIDI in
dglv2->in->eventPort = (LV2_Event_Buffer*)data_location;
} else {// Audio Port
- if(port - 1 < NUM_OUTPUTS)
- dglv2->out->outputPort[port - 1] = (sample_t*)data_location;
+ if(port - 1 < NUM_OUTPUTS) {
+ dglv2->out->outputPorts[port - 1].samples = (sample_t*)data_location;
+ dglv2->out->outputPorts[port - 1].size = 0;
+ }
}
}
@@ -197,13 +271,17 @@ void run(LV2_Handle instance,
static size_t pos = 0;
DGLV2 *dglv2 = (DGLV2 *)instance;
+ // The buffer is not used anymore - declared NULL in 'instantiate'.
+ /*
if(dglv2->buffer_size != sample_count) {
if(dglv2->buffer) free(dglv2->buffer);
dglv2->buffer_size = sample_count;
dglv2->buffer = (sample_t*)malloc(sizeof(sample_t) * dglv2->buffer_size);
+ printf("(Re)allocate buffer: %d samples\n", dglv2->buffer_size);
}
+ */
- dglv2->dg->run(pos, dglv2->buffer, dglv2->buffer_size);
+ dglv2->dg->run(pos, dglv2->buffer, sample_count);
pos += sample_count;
}
@@ -272,6 +350,12 @@ void cleanup(LV2_Handle instance)
* for extensibility anyway). */
const void* extension_data(const char *uri)
{
+ printf("extension_data(%s)\n", uri);
+
+ if(!strcmp(uri, PLUGIN_INSTANCE_URI)) return &dg_descriptor;
+ if(!strcmp(uri, "http://lv2plug.in/ns/ext/state#Interface")) {
+ return &dg_persist;
+ }
return NULL;
}
diff --git a/lv2/lv2_gui.cc b/lv2/lv2_gui.cc
new file mode 100644
index 0000000..de5e566
--- /dev/null
+++ b/lv2/lv2_gui.cc
@@ -0,0 +1,256 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * lv2.cc
+ *
+ * Wed Jul 13 13:50:33 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include <lv2.h>
+
+#include "lv2_gui.h"
+#include "lv2_ui.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "lv2_instance.h"
+
+#include "lv2_instance-access.h"
+// From: http://codesearch.google.com/#50sg5qT6WNE/src/lv2_ui_dssi.c
+// git://repo.or.cz/nekobee.git/src/lv2_ui_dssi.c
+
+#define DRUMGIZMO_UI_URI "http://drumgizmo.org/lv2-gui"
+
+#include <plugingui.h>
+
+/**
+ * When LV2_EXTERNAL_UI_URI UI is instantiated, the returned
+ * LV2UI_Widget handle must be cast to pointer to struct lv2_external_ui.
+ * UI is created in invisible state.
+ */
+struct lv2_external_ui
+{
+ /**
+ * Host calls this function regulary. UI library implementing the
+ * callback may do IPC or redraw the UI.
+ *
+ * @param _this_ the UI context
+ */
+ void (* run)(struct lv2_external_ui * _this_);
+
+ /**
+ * Host calls this function to make the plugin UI visible.
+ *
+ * @param _this_ the UI context
+ */
+ void (* show)(struct lv2_external_ui * _this_);
+
+ /**
+ * Host calls this function to make the plugin UI invisible again.
+ *
+ * @param _this_ the UI context
+ */
+ void (* hide)(struct lv2_external_ui * _this_);
+};
+
+/** UI extension suitable for out-of-process UIs */
+#define LV2_EXTERNAL_UI_URI "http://lv2plug.in/ns/extensions/ui#external"
+
+/**
+ * On UI instantiation, host must supply LV2_EXTERNAL_UI_URI
+ * feature. LV2_Feature::data must be pointer to struct lv2_external_ui_host. */
+struct lv2_external_ui_host
+{
+ /**
+ * Callback that plugin UI will call
+ * when UI (GUI window) is closed by user.
+ * This callback wil; be called during execution of lv2_external_ui::run()
+ * (i.e. not from background thread).
+ *
+ * After this callback is called, UI is defunct. Host must call
+ * LV2UI_Descriptor::cleanup(). If host wants to make the UI visible
+ * again UI must be reinstantiated.
+ *
+ * @param controller Host context associated with plugin UI, as
+ * supplied to LV2UI_Descriptor::instantiate()
+ */
+ void (* ui_closed)(LV2UI_Controller controller);
+
+ /**
+ * Optional (may be NULL) "user friendly" identifier which the UI
+ * may display to allow a user to easily associate this particular
+ * UI instance with the correct plugin instance as it is represented
+ * by the host (e.g. "track 1" or "channel 4").
+ *
+ * If supplied by host, the string will be referenced only during
+ * LV2UI_Descriptor::instantiate()
+ */
+ const char * plugin_human_id;
+};
+
+struct DG_GUI {
+ struct lv2_external_ui virt;
+
+ LV2_Handle instance_handle;
+ LV2_Extension_Data_Feature *data_access;
+ DrumGizmo *instance;
+ LV2UI_Controller controller;
+
+ PluginGUI *gui;
+ struct lv2_external_ui_host *ui_host_ptr;
+};
+
+static void ui_run(struct lv2_external_ui * _this_)
+{
+ printf("run() called\n");
+ struct DG_GUI *dggui = (struct DG_GUI *)_this_;
+ dggui->gui->processEvents();
+}
+
+static void ui_show(struct lv2_external_ui * _this_)
+{
+ printf("show() called\n");
+ struct DG_GUI *dggui = (struct DG_GUI *)_this_;
+ dggui->gui->show();
+}
+
+static void ui_hide(struct lv2_external_ui * _this_)
+{
+ printf("hide() called\n");
+ struct DG_GUI *dggui = (struct DG_GUI *)_this_;
+ dggui->gui->hide();
+}
+
+static void closeHandler(void *ptr)
+{
+ printf("> closeHandler\n");
+ struct DG_GUI *gui = (struct DG_GUI *)ptr;
+ if(gui->ui_host_ptr && gui->ui_host_ptr->ui_closed)
+ gui->ui_host_ptr->ui_closed(gui->controller);
+ gui->gui->hide();
+ printf("< closeHandler\n");
+}
+
+static void midimapHandler(void *ptr, const char* file)
+{
+ printf("> midimapHandler %s\n", file);
+ struct DG_GUI *gui = (struct DG_GUI *)ptr;
+ gui->instance->midimapfile = file;
+
+ DGLV2 *dglv2 = (DGLV2 *)gui->instance_handle;
+ dglv2->in->loadMidiMap(file);
+
+ printf("< midimapHandler\n");
+}
+
+static LV2UI_Handle ui_instantiate(const struct _LV2UI_Descriptor * descriptor,
+ const char * plugin_uri,
+ const char * bundle_path,
+ LV2UI_Write_Function write_function,
+ LV2UI_Controller controller,
+ LV2UI_Widget * widget,
+ const LV2_Feature * const * features)
+{
+ printf("ui_instantiate\n");
+
+ struct DG_GUI* pt = new struct DG_GUI;
+
+ pt->ui_host_ptr = NULL;
+ pt->controller = controller;
+
+ while (*features != NULL) {
+ std::string uri = (*features)->URI;
+ void *data = (*features)->data;
+
+ printf("DGUI: feature: %s\n", uri.c_str());
+
+ if(uri == LV2_INSTANCE_ACCESS_URI) {
+ pt->instance_handle = data;
+ }
+
+ if(uri == LV2_DATA_ACCESS_URI) {
+ pt->data_access = (LV2_Extension_Data_Feature *)data;
+ }
+
+ if(uri == LV2_EXTERNAL_UI_URI) {
+ pt->ui_host_ptr = (struct lv2_external_ui_host *)data;
+ }
+ features++;
+ }
+
+ LV2_DrumGizmo_Descriptor *dgd =
+ (LV2_DrumGizmo_Descriptor *)(*pt->data_access->data_access)(PLUGIN_INSTANCE_URI);
+
+ pt->instance = dgd->get_pci(pt->instance_handle);
+ pt->virt.run = ui_run;
+ pt->virt.show = ui_show;
+ pt->virt.hide = ui_hide;
+ pt->gui = new PluginGUI(pt->instance);
+ pt->gui->setWindowClosedCallback(closeHandler, pt);
+ pt->gui->setChangeMidimapCallback(midimapHandler, pt);
+ // pt->gui->show();
+
+ *widget = (LV2UI_Widget)pt;
+
+ return pt;
+}
+
+static void ui_cleanup(LV2UI_Handle ui)
+{
+ printf("ui_cleanup\n");
+ struct DG_GUI* pt = (struct DG_GUI*)ui;
+ delete pt->gui;
+ delete pt;
+}
+
+static void ui_port_event(LV2UI_Handle ui,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void * buffer)
+{
+ printf("ui_cport_event\n");
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static LV2UI_Descriptor descriptor = {
+ DRUMGIZMO_UI_URI,
+ ui_instantiate,
+ ui_cleanup,
+ ui_port_event,
+ NULL
+};
+
+const LV2UI_Descriptor *lv2ui_descriptor(uint32_t index)
+{
+ printf("lv2ui_descriptor\n");
+
+ if(index == 0) return &descriptor;
+ return NULL;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lv2/lv2_gui.h b/lv2/lv2_gui.h
new file mode 100644
index 0000000..aef2127
--- /dev/null
+++ b/lv2/lv2_gui.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * lv2_gui.h
+ *
+ * Fri Oct 21 10:48:53 CEST 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __DRUMGIZMO_LV2_GUI_H__
+#define __DRUMGIZMO_LV2_GUI_H__
+
+#include "lv2_data_access.h"
+
+#define PLUGIN_INSTANCE_URI "http://drumgizmo.org/ns/drumgizmo-plugin-instance"
+
+class DrumGizmo;
+struct LV2_DrumGizmo_Descriptor {
+ DrumGizmo *(*get_pci)(LV2_Handle instance);
+};
+
+#endif/*__DRUMGIZMO_LV2_GUI_H__*/
diff --git a/lv2/lv2_instance.h b/lv2/lv2_instance.h
new file mode 100644
index 0000000..2619e5e
--- /dev/null
+++ b/lv2/lv2_instance.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * lv2_instance.h
+ *
+ * Sun Nov 20 15:27:41 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __DRUMGIZMO_LV2_INSTANCE_H__
+#define __DRUMGIZMO_LV2_INSTANCE_H__
+
+#include <lv2.h>
+
+#include "input_lv2.h"
+#include "output_lv2.h"
+
+#include <drumgizmo.h>
+
+#include "lv2_uri_map.h"
+
+typedef struct {
+ InputLV2 *in;
+ OutputLV2 *out;
+ DrumGizmo *dg;
+ sample_t *buffer;
+ size_t buffer_size;
+ LV2_URI_Map_Feature* urimap;
+} DGLV2;
+
+#endif/*__DRUMGIZMO_LV2_INSTANCE_H__*/
diff --git a/lv2/lv2_state.h b/lv2/lv2_state.h
new file mode 100644
index 0000000..3d39012
--- /dev/null
+++ b/lv2/lv2_state.h
@@ -0,0 +1,354 @@
+/*
+ Copyright 2010-2011 David Robillard <http://drobilla.net>
+ Copyright 2010 Leonard Ritter <paniq@paniq.org>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+/**
+ @file
+ C API for the LV2 State extension <http://lv2plug.in/ns/ext/state>.
+*/
+
+#ifndef LV2_STATE_H
+#define LV2_STATE_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LV2_STATE_URI "http://lv2plug.in/ns/ext/state"
+
+#define LV2_STATE_INTERFACE_URI LV2_STATE_URI "#Interface"
+#define LV2_STATE_PATH_URI LV2_STATE_URI "#Path"
+#define LV2_STATE_MAP_PATH_URI LV2_STATE_URI "#pathMap"
+#define LV2_STATE_MAKE_PATH_URI LV2_STATE_URI "#newPath"
+
+typedef void* LV2_State_Handle;
+typedef void* LV2_State_Map_Path_Handle;
+typedef void* LV2_State_Make_Path_Handle;
+
+/**
+ Flags describing value characteristics.
+
+ These flags are used along with the value's type URI to determine how to
+ (de-)serialise the value data, or whether it is even possible to do so.
+*/
+typedef enum {
+
+ /**
+ Plain Old Data.
+
+ Values with this flag contain no references to non-stateent or
+ non-global resources (e.g. pointers, handles, local paths, etc.). It is
+ safe to copy POD values with a simple memcpy and store them for use at
+ any time in the future on a machine with a compatible architecture
+ (e.g. the same endianness and alignment).
+
+ Implementations MUST NOT attempt to copy or serialise a non-POD value if
+ they do not understand its type (and thus know how to correctly do so).
+ */
+ LV2_STATE_IS_POD = 1,
+
+ /**
+ Portable (architecture independent) data.
+
+ Values with this flag are in a format that is usable on any
+ architecture, i.e. if the value is saved on one machine it can safely be
+ restored on another machine regardless of endianness, alignment, etc.
+ */
+ LV2_STATE_IS_PORTABLE = 1 << 1,
+
+ /**
+ Native data.
+
+ This flag is used by the host to indicate that the saved data is only
+ going to be used locally in the currently running process (e.g. for
+ instance duplication or snapshots), so the plugin should use the most
+ efficient representation possible and not worry about serialisation
+ and portability.
+ */
+ LV2_STATE_IS_NATIVE = 1 << 2
+
+} LV2_State_Flags;
+
+/**
+ A host-provided function to store a property.
+ @param handle Must be the handle passed to LV2_State_Interface.save().
+ @param key The key (predicate) to store @c value under (URI mapped integer).
+ @param value Pointer to the value (object) to be stored.
+ @param size The size of the data at @c value in bytes.
+ @param type The type of @c value (URI).
+ @param flags LV2_State_Flags for @c value.
+ @return 0 on success, otherwise a non-zero error code.
+
+ The host passes a callback of this type to LV2_State_Interface.save(). This callback
+ is called repeatedly by the plugin within LV2_State_Interface.save() to store all
+ the statements that describe its current state.
+
+ The host MAY fail to store a property if the type is not understood and is
+ not LV2_STATE_IS_POD and/or LV2_STATE_IS_PORTABLE. Implementations are
+ encouraged to use POD and portable values (e.g. string literals) wherever
+ possible, and use common types (e.g. types from
+ http://lv2plug.in/ns/ext/atom) regardless, since hosts are likely to already
+ contain the necessary implementation.
+
+ Note that @c size MUST be > 0, and @c value MUST point to a valid region of
+ memory @c size bytes long (this is required to make restore unambiguous).
+
+ The plugin MUST NOT attempt to use this function outside of the
+ LV2_State_Interface.restore() context.
+*/
+typedef int (*LV2_State_Store_Function)(LV2_State_Handle handle,
+ uint32_t key,
+ const void* value,
+ size_t size,
+ uint32_t type,
+ uint32_t flags);
+
+/**
+ A host-provided function to retrieve a property.
+ @param handle Must be the handle passed to
+ LV2_State_Interface.restore().
+ @param key The key (predicate) of the property to retrieve (URI).
+ @param size (Output) If non-NULL, set to the size of the restored value.
+ @param type (Output) If non-NULL, set to the type of the restored value.
+ @param flags (Output) If non-NULL, set to the LV2_State_Flags for
+ the returned value.
+ @return A pointer to the restored value (object), or NULL if no value
+ has been stored under @c key.
+
+ A callback of this type is passed by the host to
+ LV2_State_Interface.restore(). This callback is called repeatedly by the
+ plugin within LV2_State_Interface.restore() to retrieve any properties it
+ requires to restore its state.
+
+ The returned value MUST remain valid until LV2_State_Interface.restore()
+ returns.
+
+ The plugin MUST NOT attempt to use this function, or any value returned from
+ it, outside of the LV2_State_Interface.restore() context. Returned values
+ MAY be copied for later use if necessary, assuming the plugin knows how to
+ do so correctly (e.g. the value is POD, or the plugin understands the type).
+*/
+typedef const void* (*LV2_State_Retrieve_Function)(LV2_State_Handle handle,
+ uint32_t key,
+ size_t* size,
+ uint32_t* type,
+ uint32_t* flags);
+
+/**
+ State Extension Data.
+
+ When the plugin's extension_data is called with argument LV2_STATE_URI,
+ the plugin MUST return an LV2_State structure, which remains valid for the
+ lifetime of the plugin.
+
+ The host can use the contained function pointers to save and restore the
+ state of a plugin instance at any time (provided the threading restrictions
+ for the given function are met).
+
+ The typical use case is to save the plugin's state when a project is saved,
+ and to restore the state when a project has been loaded. Other uses are
+ possible (e.g. cloning plugin instances or taking a snapshot of plugin
+ state).
+
+ Stored data is only guaranteed to be compatible between instances of plugins
+ with the same URI (i.e. if a change to a plugin would cause a fatal error
+ when restoring state saved by a previous version of that plugin, the plugin
+ URI MUST change just as it must when ports change incompatibly). Plugin
+ authors should consider this possibility, and always store sensible data
+ with meaningful types to avoid such compatibility issues in the future.
+*/
+typedef struct _LV2_State_Interface {
+
+ /**
+ Save plugin state using a host-provided @c store callback.
+
+ @param instance The instance handle of the plugin.
+ @param store The host-provided store callback.
+ @param handle An opaque pointer to host data, e.g. the map or
+ file where the values are to be stored. If @c store is called, this MUST
+ be passed as its handle parameter.
+ @param flags Flags describing desires properties of this save. The
+ plugin SHOULD use these values to determine the most appropriate and/or
+ efficient serialisation, but is not required to do so.
+ @param features Extensible parameter for passing any additional
+ features to be used for this save.
+
+ The plugin is expected to store everything necessary to completely
+ restore its state later (possibly much later, in a different process, on
+ a completely different machine, etc.)
+
+ The @c handle pointer and @c store function MUST NOT be used
+ beyond the scope of save().
+
+ This function has its own special threading class: it may not be called
+ concurrently with any "Instantiation" function, but it may be called
+ concurrently with functions in any other class, unless the definition of
+ that class prohibits it (e.g. it may not be called concurrently with a
+ "Discovery" function, but it may be called concurrently with an "Audio"
+ function. The plugin is responsible for any locking or lock-free
+ techniques necessary to make this possible.
+
+ Note that in the simple case where state is only modified by restore(),
+ there are no synchronization issues since save() is never called
+ concurrently with restore() (though run() may read it during a save).
+
+ Plugins that dynamically modify state while running, however, must take
+ care to do so in such a way that a concurrent call to save() will save a
+ consistent representation of plugin state for a single instant in time.
+ */
+ void (*save)(LV2_Handle instance,
+ LV2_State_Store_Function store,
+ LV2_State_Handle handle,
+ uint32_t flags,
+ const LV2_Feature *const * features);
+
+
+ /**
+ Restore plugin state using a host-provided @c retrieve callback.
+
+ @param instance The instance handle of the plugin.
+ @param retrieve The host-provided retrieve callback.
+ @param handle An opaque pointer to host data, e.g. the map or
+ file from which the values are to be restored. If @c retrieve is
+ called, this MUST be passed as its handle parameter.
+ @param flags Currently unused.
+ @param features Extensible parameter for passing any additional
+ features to be used for this restore.
+
+ The plugin MAY assume a restored value was set by a previous call to
+ LV2_State_Interface.save() by a plugin with the same URI.
+
+ The plugin MUST gracefully fall back to a default value when a value can
+ not be retrieved. This allows the host to reset the plugin state with an
+ empty map.
+
+ The @c handle pointer and @c store function MUST NOT be used
+ beyond the scope of restore().
+
+ This function is in the "Instantiation" threading class as defined by
+ LV2. This means it MUST NOT be called concurrently with any other
+ function on the same plugin instance.
+ */
+ void (*restore)(LV2_Handle instance,
+ LV2_State_Retrieve_Function retrieve,
+ LV2_State_Handle handle,
+ uint32_t flags,
+ const LV2_Feature *const * features);
+
+} LV2_State_Interface;
+
+/**
+ Feature data for state:pathMap (LV2_STATE_MAP_PATH_URI).
+*/
+typedef struct {
+
+ /**
+ Opaque host data.
+ */
+ LV2_State_Map_Path_Handle handle;
+
+ /**
+ Map an absolute path to an abstract path for use in plugin state.
+ @param handle MUST be the @a handle member of this struct.
+ @param absolute_path The absolute path of a file.
+ @return An abstract path suitable for use in plugin state.
+
+ The plugin MUST use this function to map any paths that will be stored
+ in files in plugin state. The returned value is an abstract path which
+ MAY not be an actual file system path; @ref absolute_path MUST be used
+ to map it to an actual path in order to use the file.
+
+ Hosts MAY map paths in any way (e.g. by creating symbolic links within
+ the plugin's state directory or storing a list of referenced files
+ elsewhere). Plugins MUST NOT make any assumptions about abstract paths
+ except that they can be mapped back to an absolute path using @ref
+ absolute_path.
+
+ This function may only be called within the context of
+ LV2_State_Interface.save() or LV2_State_Interface.restore(). The caller
+ is responsible for freeing the returned value.
+ */
+ char* (*abstract_path)(LV2_State_Map_Path_Handle handle,
+ const char* absolute_path);
+
+ /**
+ Map an abstract path from plugin state to an absolute path.
+ @param handle MUST be the @a handle member of this struct.
+ @param abstract_path An abstract path (e.g. a path from plugin state).
+ @return An absolute file system path.
+
+ Since abstract paths are not necessarily actual file paths (or at least
+ not necessarily absolute paths), this function MUST be used in order to
+ actually open or otherwise use the file referred to by an abstract path.
+
+ This function may only be called within the context of
+ LV2_State_Interface.save() or LV2_State_Interface.restore(). The caller
+ is responsible for freeing the returned value.
+ */
+ char* (*absolute_path)(LV2_State_Map_Path_Handle handle,
+ const char* abstract_path);
+
+} LV2_State_Map_Path;
+
+/**
+ Feature data for state:makePath (@ref LV2_STATE_MAKE_PATH_URI).
+*/
+typedef struct {
+
+ /**
+ Opaque host data.
+ */
+ LV2_State_Make_Path_Handle handle;
+
+ /**
+ Return a path the plugin may use to create a new file.
+ @param handle MUST be the @a handle member of this struct.
+ @param path The path of the new file relative to a namespace unique
+ to this plugin instance.
+ @return The absolute path to use for the new file.
+
+ This function can be used by plugins to create files and directories,
+ either at state saving time (if this feature is passed to
+ LV2_State_Interface.save()) or any time (if this feature is passed to
+ LV2_Descriptor.instantiate()).
+
+ The host must do whatever is necessary for the plugin to be able to
+ create a file at the returned path (e.g. using fopen), including
+ creating any leading directories.
+
+ If this function is passed to LV2_Descriptor.instantiate(), it may be
+ called from any non-realtime context. If it is passed to
+ LV2_State_Interface.save(), it may only be called within the dynamic
+ scope of that function call.
+
+ The caller is responsible for freeing the returned value with free().
+ */
+ char* (*path)(LV2_State_Make_Path_Handle handle,
+ const char* path);
+
+} LV2_State_Make_Path;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* LV2_STATE_H */
diff --git a/lv2/lv2_ui.h b/lv2/lv2_ui.h
new file mode 100644
index 0000000..4be2c24
--- /dev/null
+++ b/lv2/lv2_ui.h
@@ -0,0 +1,372 @@
+/************************************************************************
+ *
+ * In-process UI extension for LV2
+ *
+ * Copyright (C) 2006-2008 Lars Luthman <lars.luthman@gmail.com>
+ *
+ * Based on lv2.h, which was
+ *
+ * Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
+ * Stefan Westerfeld
+ * Copyright (C) 2006 Steve Harris, Dave 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
+ This extension defines an interface that can be used in LV2 plugins and
+ hosts to create UIs for plugins. The UIs are plugins that reside in
+ shared object files in an LV2 bundle and are referenced in the RDF data
+ using the triples (Turtle shown)
+<pre>
+ @@prefix uiext: <http://lv2plug.in/ns/extensions/ui#> .
+ <http://my.plugin> uiext:ui <http://my.pluginui> .
+ <http://my.plugin> a uiext:GtkUI .
+ <http://my.pluginui> uiext:binary <myui.so> .
+</pre>
+ where <http://my.plugin> is the URI of the plugin, <http://my.pluginui> is
+ the URI of the plugin UI and <myui.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, in this case uiext: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).
+
+ (Note: the prefix above is used throughout this file for the same URI)
+
+ 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.
+
+ 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 does 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 this
+ header is all you can expect to work.
+
+ Since the LV2 specification itself allows for extensions that may add
+ new types of data and configuration parameters that plugin authors may
+ want to control with a UI, this extension allows for meta-extensions that
+ can extend the interface between the UI and the host. These extensions
+ mirror the extensions used for plugins - there are required and optional
+ "features" that you declare in the RDF data for the UI as
+<pre>
+ <http://my.pluginui> uiext:requiredFeature <http://my.feature> .
+ <http://my.pluginui> uiext:optionalFeature <http://my.feature> .
+</pre>
+ These predicates have the same semantics as lv2:requiredFeature and
+ lv2:optionalFeature - if a UI is declaring a feature as required, the
+ host is NOT allowed to load it unless it supports that feature, and if it
+ does support a feature (required or optional) it MUST pass that feature's
+ URI and any additional data (specified by the meta-extension that defines
+ the feature) in a LV2_Feature struct (as defined in lv2.h) to the UI's
+ instantiate() function.
+
+ These features may be used to specify how to pass data between the UI
+ and the plugin port buffers - see LV2UI_Write_Function for details.
+
+ There are four features defined in this extension that hosts may want to
+ implement:
+
+<pre>
+ uiext:makeResident
+</pre>
+ If this feature is required by a UI the host MUST NEVER unload the shared
+ library containing the UI implementation during the lifetime of the host
+ process (e.g. never calling dlclose() on Linux). This feature may be
+ needed by e.g. a Gtk UI that registers its own Glib types using
+ g_type_register_static() - if it gets unloaded and then loaded again the
+ type registration will break, since there is no way to unregister the
+ types when the library is unloaded. The data pointer in the LV2_Feature
+ for this feature should always be set to NULL.
+
+<pre>
+ uiext:makeSONameResident
+</pre>
+ This feature is ELF specific - it should only be used by UIs that
+ use the ELF file format for the UI shared object files (e.g. on Linux).
+ If it is required by an UI the UI should also list a number of SO names
+ (shared object names) for libraries that the UI shared object
+ depends on and that may not be unloaded during the lifetime of the host
+ process, using the predicate @c uiext:residentSONames, like this:
+<pre>
+ <http://my.pluginui> uiext:residentSONames "libgtkmm-2.4.so.1", "libfoo.so.0"
+</pre>
+ The host MUST then make sure that the shared libraries with the given ELF
+ SO names are not unloaded when the plugin UI is, but stay loaded during
+ the entire lifetime of the host process. On Linux this can be accomplished
+ by calling dlopen() on the shared library file with that SO name and never
+ calling a matching dlclose(). However, if a plugin UI requires the
+ @c uiext:makeSONameResident feature, it MUST ALWAYS be safe for the host to
+ just never unload the shared object containing the UI implementation, i.e.
+ act as if the UI required the @c uiext:makeResident feature instead. Thus
+ the host only needs to find the shared library files corresponding to the
+ given SO names if it wants to save RAM by unloading the UI shared object
+ file when it is no longer needed. The data pointer for the LV2_Feature for
+ this feature should always be set to NULL.
+
+<pre>
+ uiext:noUserResize
+</pre>
+ If an UI requires this feature it indicates that it does not make sense
+ to let the user resize the main widget, and the host should prevent that.
+ This feature may not make sense for all UI types. The data pointer for the
+ LV2_Feature for this feature should always be set to NULL.
+
+<pre>
+ uiext:fixedSize
+</pre>
+ If an UI requires this feature it indicates the same thing as
+ uiext:noUserResize, and additionally it means that the UI will not resize
+ the main widget on its own - it will always remain the same size (e.g. a
+ pixmap based GUI). This feature may not make sense for all UI types.
+ The data pointer for the LV2_Feature for this feature should always be set
+ to NULL.
+
+
+ UIs written to this specification do not need to be threadsafe - the
+ functions defined below may only be called in the same thread as the UI
+ main loop is running in.
+
+ Note that this UI extension is NOT a lv2:Feature. There is no way for a
+ plugin to know whether the host that loads it supports UIs or not, and
+ the plugin must ALWAYS work without the UI (although it may be rather
+ useless unless it has been configured using the UI in a previous session).
+
+ A UI does not have to be a graphical widget, it could just as well be a
+ server listening for OSC input or an interface to some sort of hardware
+ device, depending on the RDF class of the UI.
+*/
+
+#ifndef LV2_UI_H
+#define LV2_UI_H
+
+#include <lv2.h>
+
+#define LV2_UI_URI "http://lv2plug.in/ns/extensions/ui"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** A pointer to some widget or other type of UI handle.
+ The actual type is defined by the type URI of the UI.
+ 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* LV2UI_Widget;
+
+
+/** This handle indicates 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 plugin may use it to
+ reference internal instance data. */
+typedef void* LV2UI_Handle;
+
+
+/** This handle indicates a particular plugin instance, provided by the host.
+ It is valid to compare this to NULL (0 for C++) but otherwise the
+ UI plugin MUST not attempt to interpret it. The host may use it to
+ reference internal plugin instance data. */
+typedef void* LV2UI_Controller;
+
+
+/** This is the type of the host-provided function that the UI can use to
+ send data to a plugin's input ports. The @c buffer parameter must point
+ to a block of data, @c buffer_size bytes large. The contents of this buffer
+ and what the host should do with it depends on the value of the @c format
+ parameter.
+
+ The @c format parameter should either be 0 or a numeric ID for a "Transfer
+ mechanism". Transfer mechanisms are Features and may be defined in
+ meta-extensions. They specify how to translate the data buffers passed
+ to this function to input data for the plugin ports. If a UI wishes to
+ write data to an input port, it must list a transfer mechanism Feature
+ for that port's class as an optional or required feature (depending on
+ whether the UI will work without being able to write to that port or not).
+ The only exception is when the UI wants to write single float values to
+ input ports of the class lv2:ControlPort, in which case @c buffer_size
+ should always be 4, the buffer should always contain a single IEEE-754
+ float, and @c format should be 0.
+
+ The numeric IDs for the transfer mechanisms are provided by a
+ URI-to-integer mapping function provided by the host, using the URI Map
+ feature <http://lv2plug.in/ns/ext/uri-map> with the map URI
+ "http://lv2plug.in/ns/extensions/ui". Thus a UI that requires transfer
+ mechanism features also requires the URI Map feature, but this is
+ implicit - the UI does not have to list the URI map feature as a required
+ or optional feature in it's RDF data.
+
+ An UI MUST NOT pass a @c format parameter value (except 0) that has not
+ been returned by the host-provided URI mapping function for a
+ host-supported transfer mechanism feature URI.
+
+ The UI MUST NOT try to write to a port for which there is no specified
+ transfer mechanism, or to an output port. The UI is responsible for
+ allocating the buffer and deallocating it after the call.
+*/
+typedef void (*LV2UI_Write_Function)(LV2UI_Controller controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void* buffer);
+
+
+/** 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 _LV2UI_Descriptor {
+
+ /** The URI for this UI (not for the plugin it controls). */
+ const char* 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 that you want 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 file
+ that references this shared object file, including the
+ trailing '/'.
+ @param write_function A function provided by the host that the UI can
+ use to send data to the plugin's input ports.
+ @param controller A handle for the plugin instance that should be passed
+ as the first parameter of @c write_function.
+ @param widget A pointer to an LV2UI_Widget. The UI will write a
+ widget pointer to this location (what type of widget
+ depends on the RDF class of the UI) that will be the
+ main UI widget.
+ @param features An 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, they just share
+ the same data structure - this will probably not be the
+ same array as the one the plugin host passes to a
+ plugin.
+ */
+ LV2UI_Handle (*instantiate)(const struct _LV2UI_Descriptor* descriptor,
+ const char* plugin_uri,
+ const char* bundle_path,
+ LV2UI_Write_Function write_function,
+ LV2UI_Controller controller,
+ LV2UI_Widget* widget,
+ const LV2_Feature* const* features);
+
+
+ /** Destroy the UI object and the associated widget. The host must not try
+ to access the widget after calling this function.
+ */
+ void (*cleanup)(LV2UI_Handle ui);
+
+ /** Tell the UI that something interesting has happened at a plugin port.
+ What is interesting and how it is written to the buffer passed to this
+ function is defined by the @c format parameter, which has the same
+ meaning as in LV2UI_Write_Function. The only exception is ports of the
+ class lv2:ControlPort, for which this function should be called
+ when the port value changes (it does not have to be called for every
+ single change if the host's UI thread has problems keeping up with
+ the thread the plugin is running in), @c buffer_size should be 4 and the
+ buffer should contain a single IEEE-754 float. In this case the @c format
+ parameter should be 0.
+
+ By default, the host should only call this function for input ports of
+ the lv2:ControlPort class. However, the default setting can be modified
+ by using the following URIs in the UI's RDF data:
+ <pre>
+ uiext:portNotification
+ uiext:noPortNotification
+ uiext:plugin
+ uiext:portIndex
+ </pre>
+ For example, if you want the UI with uri
+ <code><http://my.pluginui></code> for the plugin with URI
+ <code><http://my.plugin></code> to get notified when the value of the
+ output control port with index 4 changes, you would use the following
+ in the RDF for your UI:
+ <pre>
+ <http://my.pluginui> uiext:portNotification [ uiext:plugin <http://my.plugin> ;
+ uiext:portIndex 4 ] .
+ </pre>
+ and similarly with <code>uiext:noPortNotification</code> if you wanted
+ to prevent notifications for a port for which it would be on by default
+ otherwise. The UI is not allowed to request notifications for ports of
+ types for which no transfer mechanism is specified, if it does it should
+ be considered broken and the host should not load it.
+
+ The @c 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.
+
+ This member may be set to NULL if the UI is not interested in any
+ port events.
+ */
+ void (*port_event)(LV2UI_Handle ui,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void* buffer);
+
+ /** Returns a data structure associated with an extension URI, for example
+ a struct containing additional function pointers. Avoid returning
+ function pointers directly since standard C++ has no valid way of
+ casting a void* to a function pointer. This member may be set to NULL
+ if the UI is not interested in supporting any extensions. This is similar
+ to the extension_data() member in LV2_Descriptor.
+ */
+ const void* (*extension_data)(const char* uri);
+
+} LV2UI_Descriptor;
+
+
+
+/** A plugin UI programmer must include a function called "lv2ui_descriptor"
+ with the following function prototype within the shared object
+ file. This function will have C-style linkage (if you are using
+ C++ this is taken care of by the 'extern "C"' clause at the top of
+ the file). This function will be accessed by the UI host using the
+ @c dlsym() function and called to get a LV2UI_UIDescriptor for the
+ wanted plugin.
+
+ Just like lv2_descriptor(), this function takes an index parameter. The
+ index should only be used for enumeration and not as any sort of ID number -
+ the host should just iterate from 0 and upwards until the function returns
+ NULL or a descriptor with an URI matching the one the host is looking for.
+*/
+const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index);
+
+
+/** This is the type of the lv2ui_descriptor() function. */
+typedef const LV2UI_Descriptor* (*LV2UI_DescriptorFunction)(uint32_t index);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/lv2/lv2_uri_map.h b/lv2/lv2_uri_map.h
new file mode 100644
index 0000000..93571d5
--- /dev/null
+++ b/lv2/lv2_uri_map.h
@@ -0,0 +1,86 @@
+/* lv2_uri_map.h - C header file for the LV2 URI Map extension.
+ *
+ * Copyright (C) 2008-2009 David Robillard <http://drobilla.net>
+ *
+ * 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 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 header; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA
+ */
+
+/** @file
+ * C header for the LV2 URI Map extension <http://lv2plug.in/ns/ext/uri-map>.
+ *
+ * This extension defines a simple mechanism for plugins to map URIs to
+ * integers, usually for performance reasons (e.g. processing events
+ * typed by URIs in real time). The expected use case is for plugins to
+ * map URIs to integers for things they 'understand' at instantiation time,
+ * and store those values for use in the audio thread without doing any string
+ * comparison. This allows the extensibility of RDF with the performance of
+ * integers (or centrally defined enumerations).
+ */
+
+#ifndef LV2_URI_MAP_H
+#define LV2_URI_MAP_H
+
+#define LV2_URI_MAP_URI "http://lv2plug.in/ns/ext/uri-map"
+
+#include <stdint.h>
+
+
+/** Opaque pointer to host data. */
+typedef void* LV2_URI_Map_Callback_Data;
+
+
+/** The data field of the LV2_Feature for this extension.
+ *
+ * To support this feature the host must pass an LV2_Feature struct to the
+ * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-map"
+ * and data pointed to an instance of this struct.
+ */
+typedef struct {
+
+ /** Opaque pointer to host data.
+ *
+ * The plugin MUST pass this to any call to functions in this struct.
+ * Otherwise, it must not be interpreted in any way.
+ */
+ LV2_URI_Map_Callback_Data callback_data;
+
+ /** Get the numeric ID of a URI from the host.
+ *
+ * @param callback_data Must be the callback_data member of this struct.
+ * @param map The 'context' of this URI. Certain extensions may define a
+ * URI that must be passed here with certain restrictions on the
+ * return value (e.g. limited range). This value may be NULL if
+ * the plugin needs an ID for a URI in general.
+ * @param uri The URI to be mapped to an integer ID.
+ *
+ * This function is referentially transparent - any number of calls with
+ * the same arguments is guaranteed to return the same value over the life
+ * of a plugin instance (though the same URI may return different values
+ * with a different map parameter). However, this function is not
+ * necessarily very fast: plugins should cache any IDs they might need in
+ * performance critical situations.
+ * The return value 0 is reserved and means an ID for that URI could not
+ * be created for whatever reason. Extensions may define more precisely
+ * what this means, but in general plugins should gracefully handle 0
+ * and consider whatever they wanted the URI for "unsupported".
+ */
+ uint32_t (*uri_to_id)(LV2_URI_Map_Callback_Data callback_data,
+ const char* map,
+ const char* uri);
+
+} LV2_URI_Map_Feature;
+
+
+#endif /* LV2_URI_MAP_H */
diff --git a/lv2/output_lv2.cc b/lv2/output_lv2.cc
index 226b92a..8187a5a 100644
--- a/lv2/output_lv2.cc
+++ b/lv2/output_lv2.cc
@@ -30,7 +30,10 @@
OutputLV2::OutputLV2()
{
- for(size_t i = 0; i < NUM_OUTPUTS; i++) outputPort[i] = NULL;
+ for(size_t i = 0; i < NUM_OUTPUTS; i++) {
+ outputPorts[i].size = 0;
+ outputPorts[i].samples = NULL;
+ }
}
OutputLV2::~OutputLV2()
@@ -59,11 +62,14 @@ void OutputLV2::pre(size_t nsamples)
{
}
+#include <stdio.h>
void OutputLV2::run(int ch, sample_t *samples, size_t nsamples)
{
if(ch < NUM_OUTPUTS) {
- if(outputPort[ch])
- memcpy(outputPort[ch], samples, nsamples * sizeof(sample_t));
+ // if(outputPorts[ch].size != nsamples) printf("port.%d nsamples.%d\n", outputPorts[ch].size, nsamples);
+ if(outputPorts[ch].samples) {
+ memcpy(outputPorts[ch].samples, samples, nsamples * sizeof(sample_t));
+ }
}
}
@@ -71,6 +77,12 @@ void OutputLV2::post(size_t nsamples)
{
}
+sample_t *OutputLV2::getBuffer(int ch)
+{
+ if(ch < NUM_OUTPUTS) return outputPorts[ch].samples;
+ return NULL;
+}
+
#ifdef TEST_OUTPUT_LV2
//Additional dependency files
//deps:
diff --git a/lv2/output_lv2.h b/lv2/output_lv2.h
index 9a313f4..1b4e8c9 100644
--- a/lv2/output_lv2.h
+++ b/lv2/output_lv2.h
@@ -29,7 +29,13 @@
#include <audiooutputengine.h>
-#define NUM_OUTPUTS 16
+#define NUM_OUTPUTS 64
+
+class OutputPort {
+public:
+ size_t size;
+ sample_t *samples;
+};
class OutputLV2 : public AudioOutputEngine {
public:
@@ -47,7 +53,10 @@ public:
void run(int ch, sample_t *samples, size_t nsamples);
void post(size_t nsamples);
- sample_t *outputPort[NUM_OUTPUTS];
+ sample_t *getBuffer(int c);
+
+ // sample_t *outputPort[NUM_OUTPUTS];
+ OutputPort outputPorts[NUM_OUTPUTS];
};
#endif/*__DRUMGIZMO_OUTPUT_LV2_H__*/