[SCM] calf/master: + LV2: added preliminary support for larsl's LV2 GUI + LV2: compatibility fixes + LV2: Fix (hopefully) a wrong #if (copy-paste bug) - thanks to Frank Neumann for spotting it + autostuff: fix DSSI GUI build with PHAT - thanks to Nedko Arnaudov for testing/reporting
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:57 UTC 2013
The following commit has been merged in the master branch:
commit 32f7c9de5b9aedab0b3c90570ef9219d750301c9
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Sun Jan 13 16:41:20 2008 +0000
+ LV2: added preliminary support for larsl's LV2 GUI
+ LV2: compatibility fixes
+ LV2: Fix (hopefully) a wrong #if (copy-paste bug) - thanks to Frank Neumann for spotting it
+ autostuff: fix DSSI GUI build with PHAT - thanks to Nedko Arnaudov for testing/reporting
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@93 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/configure.in b/configure.in
index 4f86d34..5e8e56a 100644
--- a/configure.in
+++ b/configure.in
@@ -79,6 +79,12 @@ else
DSSI_GUI_ENABLED="no"
fi
+if test "$GUI_ENABLED" = "yes" -a "$LV2_ENABLED" = "yes"; then
+ LV2_GUI_ENABLED="yes"
+else
+ LV2_GUI_ENABLED="no"
+fi
+
if test "$JACK_ENABLED" = "yes"; then
PKG_CHECK_MODULES(PHAT_DEPS, phat >= 0.4.1,
[
@@ -106,6 +112,7 @@ AM_CONDITIONAL(USE_JACK, test "$JACK_ENABLED" = "yes")
AM_CONDITIONAL(USE_LV2, test "$LV2_ENABLED" = "yes")
AM_CONDITIONAL(USE_GUI, test "$GUI_ENABLED" = "yes")
AM_CONDITIONAL(USE_DSSI_GUI, test "$DSSI_GUI_ENABLED" = "yes")
+AM_CONDITIONAL(USE_LV2_GUI, test "$LV2_GUI_ENABLED" = "yes")
AM_CONDITIONAL(USE_PHAT, test "$PHAT_ENABLED" = "yes")
AM_CONDITIONAL(USE_LASH, test "$LASH_ENABLED" = "yes")
AM_CONDITIONAL(ENABLE_EXPERIMENTAL, test "$set_enable_experimental" = "yes")
@@ -170,8 +177,9 @@ AC_MSG_RESULT([
LADSPA enabled: $LADSPA_FOUND
DSSI enabled: $DSSI_FOUND
DSSI GUI enabled: $DSSI_GUI_ENABLED
- JACK host enabled: $JACK_ENABLED
LV2 enabled: $LV2_ENABLED
+ LV2 GUI enabled: $LV2_GUI_ENABLED
+ JACK host enabled: $JACK_ENABLED
LASH enabled: $LASH_ENABLED
Old-style JACK MIDI: $OLD_JACK
PHAT GUI enabled: $PHAT_ENABLED
diff --git a/src/Makefile.am b/src/Makefile.am
index 24ce815..94bf061 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES = -I$(top_srcdir) -I$(srcdir)
SUBDIRS = calf
ladspadir = $(with_ladspa_dir)
+lv2dir = $(with_lv2_dir)
bin_PROGRAMS =
@@ -13,6 +14,9 @@ noinst_LTLIBRARIES = calf.la libcalfstatic.la
if USE_DSSI_GUI
noinst_PROGRAMS += calfdssigui
endif
+if USE_LV2_GUI
+noinst_LTLIBRARIES += calflv2gui.la
+endif
AM_CXXFLAGS = -ffast-math -finline-limit=80 -DPKGLIBDIR=\"$(pkglibdir)\"
@@ -53,6 +57,9 @@ endif
if USE_LV2
AM_CXXFLAGS += -DUSE_LV2=1
endif
+if USE_LV2_GUI
+AM_CXXFLAGS += -DUSE_LV2_GUI=1
+endif
if USE_LASH
AM_CXXFLAGS += -DUSE_LASH=1 $(LASH_DEPS_CFLAGS)
endif
@@ -63,10 +70,21 @@ calfbenchmark_LDADD = -lglib-2.0
if USE_DSSI_GUI
calfdssigui_SOURCES = dssigui.cpp
calfdssigui_LDADD = -lglib-2.0 libcalfstatic.la libcalfgui.la $(GUI_DEPS_LIBS)
+if USE_PHAT
+calfdssigui_LDADD += $(PHAT_DEPS_LIBS)
+endif
endif
calf_la_SOURCES = modules.cpp giface.cpp monosynth.cpp organ.cpp preset.cpp synth.cpp
-calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat
+calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -export-symbols-regex "(ladspa_|lv2_|dssi_)descriptor"
+
+if USE_LV2_GUI
+calflv2gui_la_SOURCES = gui.cpp custom_ctl.cpp modules.cpp giface.cpp monosynth.cpp organ.cpp preset.cpp synth.cpp lv2gui.cpp
+calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -export-symbols-regex "lv2_gui_descriptor"
+if USE_PHAT
+calflv2gui_la_LIBADD = $(PHAT_DEPS_LIBS)
+endif
+endif
libcalfstatic_la_SOURCES = modules.cpp giface.cpp monosynth.cpp organ.cpp preset.cpp synth.cpp
libcalfstatic_la_LDFLAGS = -static -lexpat
@@ -103,6 +121,9 @@ endif
if USE_LV2
install -d -m 755 $(DESTDIR)$(with_lv2_dir)/calf.lv2
install -c -m 755 $(top_builddir)/src/.libs/calf.so $(DESTDIR)$(with_lv2_dir)/calf.lv2/calf.so
+if USE_LV2_GUI
+ install -c -m 755 $(top_builddir)/src/.libs/calflv2gui.so $(DESTDIR)$(with_lv2_dir)/calf.lv2/calflv2gui.so
+endif
$(top_builddir)/src/calfmakerdf -m ttl >$(DESTDIR)$(with_lv2_dir)/calf.lv2/calf.ttl
$(top_builddir)/src/calfmakerdf -m manifest >$(DESTDIR)$(with_lv2_dir)/calf.lv2/manifest.ttl
endif
@@ -110,6 +131,9 @@ endif
#remove calf.so, calf.rdf and - if empty - ladspa dir in usr/share
uninstall-hook:
if USE_LV2
+if USE_LV2_GUI
+ rm -f $(DESTDIR)$(with_lv2_dir)/calf.lv2/calflv2gui.so
+endif
rm -f $(DESTDIR)$(with_lv2_dir)/calf.lv2/calf.so
rm -f $(DESTDIR)$(with_lv2_dir)/calf.lv2/calf.ttl $(DESTDIR)$(with_lv2_dir)/calf.lv2/manifest.ttl
rmdir -p $(DESTDIR)$(with_lv2_dir)/calf.lv2 || true
diff --git a/src/calf/lv2-gui.h b/src/calf/lv2-gui.h
new file mode 100644
index 0000000..fe20570
--- /dev/null
+++ b/src/calf/lv2-gui.h
@@ -0,0 +1,291 @@
+/************************************************************************
+ *
+ * In-process UI extension for LV2
+ *
+ * Copyright (C) 2006-2007 Lars Luthman <lars.luthman at 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 GUIs for plugins. The GUIs 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 guiext: <http://ll-plugins.nongnu.org/lv2/ext/gui#> .
+ <http://my.plugin> guiext:gui <http://my.plugingui> .
+ <http://my.plugingui> a guiext:GtkGUI .
+ <http://my.plugingui> guiext:binary <mygui.so> .
+</pre>
+ where <http://my.plugin> is the URI of the plugin, <http://my.plugingui> is
+ the URI of the plugin GUI and <mygui.so> is the relative URI to the shared
+ object file. While it is possible to have the plugin GUI 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 GUIs don't have to load the GUI code.
+ A GUI MUST specify its class in the RDF data. In this case the class is
+ guiext:GtkGUI, which is the only class defined by this extension.
+
+ (Note: the prefix above is used throughout this file for the same URI)
+
+ It's entirely possible to have multiple GUIs for the same plugin, or to have
+ the GUI for a plugin in a different bundle from the actual plugin - this
+ way people other than the plugin author can write plugin GUIs independently
+ without editing the original plugin bundle.
+
+ Note that the process that loads the shared object file containing the GUI
+ 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 GUI 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
+ GUI 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 GUI, this extension allows for meta-extensions that
+ can extend the interface between the GUI 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 GUI as
+<pre>
+ <http://my.plugingui> guiext:requiredFeature <http://my.feature> .
+ <http://my.plugingui> guiext:optionalFeature <http://my.feature> .
+</pre>
+ These predicates have the same semantics as lv2:requiredFeature and
+ lv2:optionalFeature - if a GUI 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) to the GUI's instantiate() function.
+
+ These features may be used to specify how to pass data between the GUI
+ and the plugin port buffers - see LV2UI_Write_Function for details.
+
+ GUIs 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 GUI extension is NOT a lv2:Feature. There is no way for a
+ plugin to know whether the host that loads it supports GUIs or not, and
+ the plugin must ALWAYS work without the GUI (although it may be rather
+ useless unless it has been configured using the GUI in a previous session).
+
+*/
+
+#ifndef LV2_IPGUI_H
+#define LV2_IPGUI_H
+
+#include "lv2.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** A pointer to some widget.
+ The actual type of the widget is defined by the type URI of the GUI.
+ e.g. if "<http://example.org/somegui> a guiext:GtkGUI", this is a pointer
+ to a GtkWidget compatible with GTK+ 2.0 and the GUI can expect the GTK+
+ main loop to be running during the entire lifetime of all instances of that
+ GUI. 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 GUIs, in various
+ toolkits, but guiext:GtkGUI is the only type that is defined in this
+ extension. */
+typedef void* LV2UI_Widget;
+
+
+/** This handle indicates a particular instance of a GUI.
+ It is valid to compare this to NULL (0 for C++) but otherwise the
+ host MUST not attempt to interpret it. The GUI 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
+ GUI 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 GUI 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
+ will depend on the class of the port it's being sent to, and the transfer
+ mechanism specified for that port class.
+
+ 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 GUI 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 GUI
+ will work without being able to write to that port or not). The only
+ exception is ports of the class lv2:ControlPort, for which @c buffer_size
+ should always be 4 and the buffer should always contain a single IEEE-754
+ float.
+
+ The GUI MUST NOT try to write to a port for which there is no specified
+ transfer mechanism, or to a port for which the GUI has listed an optional
+ transfer mechanism that the host does not support, or to an output port.
+ The GUI is responsible for allocating the buffer and deallocating it after
+ the call. A function pointer of this type will be provided to the GUI by
+ the host in the instantiate() function. */
+typedef void (*LV2UI_Write_Function)(LV2UI_Controller controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ const void* buffer);
+
+
+/** */
+typedef struct _LV2UI_Descriptor {
+
+ /** The URI for this GUI (not for the plugin it controls). */
+ const char* URI;
+
+ /** Create a new GUI object and return a handle to it. This function works
+ similarly to the instantiate() member in LV2_Descriptor.
+
+ @param descriptor The descriptor for the GUI that you want to instantiate.
+ @param plugin_uri The URI of the plugin that this GUI 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 GUI 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 GUI will write a
+ widget pointer to this location (what type of widget
+ depends on the RDF class of the GUI) that will be the
+ main GUI widget.
+ @param features An array of LV2_Feature pointers. The host must pass
+ all feature URIs that it and the plugin supports and any
+ additional data, just like in the LV2 plugin
+ instantiate() function.
+ */
+ 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 GUI object and the associated widget. The host must not try
+ to access the widget after calling this function.
+ */
+ void (*cleanup)(LV2UI_Handle gui);
+
+ /** Tell the GUI 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 specified transfer mechanism for that port
+ class (see 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 must not be called for every single
+ change if the host's GUI 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.
+
+ 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 GUI's RDF data:
+ <pre>
+ guiext:portNotification
+ guiext:noPortNotification
+ guiext:plugin
+ guiext:portIndex
+ </pre>
+ For example, if you want the GUI with uri
+ <code><http://my.plugingui></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 GUI:
+ <pre>
+ <http://my.plugingui> guiext:portNotification [ guiext:plugin <http://my.plugin> ;
+ guiext:portIndex 4 ] .
+ </pre>
+ and similarly with <code>guiext:noPortNotification</code> if you wanted
+ to prevent notifications for a port for which it would be on by default
+ otherwise. The GUI is not allowed to request notifications for ports
+ for which no transfer mechanism is specified, if it does it should be
+ considered broken and the host should not load it. Also, a GUI should
+ not expect to receive notifications for a port for which it has listed
+ an optional transfer mechanism that the host does not support.
+
+ The @c buffer is only valid during the time of this function call, so if
+ the GUI 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 GUI is not interested in any
+ port events.
+ */
+ void (*port_event)(LV2UI_Handle gui,
+ uint32_t port,
+ uint32_t buffer_size,
+ 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 GUI 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 GUI 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 GUI 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
+ is returned.
+*/
+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/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index b4ce3c6..f89bf9a 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -9,6 +9,8 @@ namespace synth {
template<class Module>
struct lv2_instance: public Module, public plugin_ctl_iface
{
+ bool set_srate;
+ int srate_to_set;
lv2_instance()
{
for (int i=0; i < Module::in_count; i++)
@@ -17,6 +19,8 @@ struct lv2_instance: public Module, public plugin_ctl_iface
Module::outs[i] = NULL;
for (int i=0; i < Module::param_count; i++)
Module::params[i] = NULL;
+ set_srate = true;
+ srate_to_set = 44100;
}
virtual parameter_properties *get_param_props(int param_no)
{
@@ -86,9 +90,7 @@ struct lv2_wrapper
}
static void cb_activate(LV2_Handle Instance) {
- instance *const mod = (instance *)Instance;
- mod->set_sample_rate(mod->srate);
- mod->activate();
+ // LV2 activate is practically useless because parameters aren't present
}
static void cb_deactivate(LADSPA_Handle Instance) {
@@ -100,7 +102,8 @@ struct lv2_wrapper
{
instance *mod = new instance();
// XXXKF some people use fractional sample rates; we respect them ;-)
- mod->srate = (uint32_t)sample_rate;
+ mod->srate_to_set = (uint32_t)sample_rate;
+ mod->set_srate = true;
return mod;
}
static inline void zero_by_mask(Module *module, uint32_t mask, uint32_t offset, uint32_t nsamples)
@@ -124,6 +127,11 @@ struct lv2_wrapper
static void cb_run(LV2_Handle Instance, uint32_t SampleCount) {
instance *const mod = (instance *)Instance;
+ if (mod->set_srate) {
+ mod->set_sample_rate(mod->srate_to_set);
+ mod->activate();
+ mod->set_srate = false;
+ }
mod->params_changed();
process_slice(mod, 0, SampleCount);
}
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 4979fec..79f5f27 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -178,6 +178,7 @@ public:
: inertia_cutoff(exponential_ramp(128), 20)
, timer(128)
{
+ order = 0;
}
void calculate_filter()
@@ -218,7 +219,7 @@ public:
calculate_filter();
}
void activate() {
- calculate_filter();
+ params_changed();
for (int i=0; i < order; i++) {
left[i].reset();
right[i].reset();
@@ -230,7 +231,6 @@ public:
}
void set_sample_rate(uint32_t sr) {
srate = sr;
- params_changed();
}
inline int process_channel(dsp::biquad<float> *filter, float *in, float *out, uint32_t numsamples, int inmask) {
if (inmask) {
@@ -279,6 +279,7 @@ public:
return filter[order - 1].empty_d1() ? 0 : inmask;
}
uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+// printf("sr=%d cutoff=%f res=%f mode=%f\n", srate, *params[par_cutoff], *params[par_resonance], *params[par_mode]);
uint32_t ostate = 0;
numsamples += offset;
while(offset < numsamples) {
diff --git a/src/gui.cpp b/src/gui.cpp
index 47ed532..74adcbf 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -116,6 +116,7 @@ void hscale_param_control::set()
{
_GUARD_CHANGE_
parameter_properties &props = get_props();
+ printf("param value %d = %f\n", param_no, gui->plugin->get_param_value(param_no));
gtk_range_set_value (GTK_RANGE (widget), props.to_01 (gui->plugin->get_param_value(param_no)));
// hscale_value_changed (GTK_HSCALE (widget), (gpointer)this);
}
@@ -423,6 +424,7 @@ GtkWidget *plugin_gui::create(plugin_ctl_iface *_plugin)
widget = params[i]->create(this, i);
gtk_table_attach (GTK_TABLE (container), widget, 1, 3, trow, trow + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_SHRINK, 0, 0);
}
+ params[i]->hook_params();
params[i]->set();
}
return container;
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
new file mode 100644
index 0000000..9463418
--- /dev/null
+++ b/src/lv2gui.cpp
@@ -0,0 +1,195 @@
+/* Calf DSP Library utility application.
+ * DSSI GUI application.
+ * Copyright (C) 2007 Krzysztof Foltman
+ *
+ * This program 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 program 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 program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <getopt.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <config.h>
+#include <calf/giface.h>
+#include <calf/gui.h>
+#include <calf/modules.h>
+#include <calf/modules_dev.h>
+#include <calf/benchmark.h>
+#include <calf/lv2-gui.h>
+#include <calf/preset_gui.h>
+
+using namespace std;
+using namespace dsp;
+using namespace synth;
+
+struct plugin_proxy_base: public plugin_ctl_iface
+{
+ LV2UI_Write_Function write_function;
+ LV2UI_Controller controller;
+
+ bool send;
+ plugin_gui *gui;
+
+ plugin_proxy_base()
+ {
+ send = false;
+ gui = NULL;
+ }
+
+ void setup(LV2UI_Write_Function wfn, LV2UI_Controller ctl)
+ {
+ write_function = wfn;
+ controller = ctl;
+ }
+
+};
+
+template<class Module>
+struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
+{
+ float params[Module::param_count];
+ plugin_proxy()
+ {
+ send = true;
+ for (int i = 0; i < Module::param_count; i++)
+ params[i] = Module::param_props[i].def_value;
+ }
+
+ virtual parameter_properties *get_param_props(int param_no) {
+ return Module::param_props + param_no;
+ }
+ virtual float get_param_value(int param_no) {
+ if (param_no < 0 || param_no >= Module::param_count)
+ return 0;
+ return params[param_no];
+ }
+ virtual void set_param_value(int param_no, float value) {
+ if (param_no < 0 || param_no >= Module::param_count)
+ return;
+ params[param_no] = value;
+ if (send) {
+ send = false;
+ write_function(controller, param_no + Module::in_count + Module::out_count, sizeof(float), ¶ms[param_no]);
+ send = true;
+ }
+ }
+ virtual int get_param_count() {
+ return Module::param_count;
+ }
+ virtual int get_param_port_offset() {
+ return Module::in_count + Module::out_count;
+ }
+ virtual const char *get_gui_xml() {
+ return Module::get_gui_xml();
+ }
+ virtual line_graph_iface *get_line_graph_iface() {
+ return this;
+ }
+ virtual bool activate_preset(int bank, int program) {
+ return false;
+ }
+ virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) {
+ return Module::get_static_graph(index, subindex, params[index], data, points, context);
+ }
+};
+
+plugin_proxy_base *create_plugin_proxy(const char *effect_name)
+{
+ if (!strcmp(effect_name, "Reverb"))
+ return new plugin_proxy<reverb_audio_module>();
+ else if (!strcmp(effect_name, "Flanger"))
+ return new plugin_proxy<flanger_audio_module>();
+ else if (!strcmp(effect_name, "Filter"))
+ return new plugin_proxy<filter_audio_module>();
+ else if (!strcmp(effect_name, "Monosynth"))
+ return new plugin_proxy<monosynth_audio_module>();
+ else if (!strcmp(effect_name, "VintageDelay"))
+ return new plugin_proxy<vintage_delay_audio_module>();
+#ifdef ENABLE_EXPERIMENTAL
+ else if (!strcmp(effect_name, "Organ"))
+ return new plugin_proxy<organ_audio_module>();
+ else if (!strcmp(effect_name, "RotarySpeaker"))
+ return new plugin_proxy<rotary_speaker_audio_module>();
+#endif
+ else
+ return NULL;
+}
+
+LV2UI_Descriptor gui;
+
+LV2UI_Handle gui_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)
+{
+ plugin_proxy_base *proxy = create_plugin_proxy(plugin_uri + sizeof("http://calf.sourceforge.net/plugins/") - 1);
+ proxy->setup(write_function, controller);
+ // dummy window
+ plugin_gui_window *window = new plugin_gui_window;
+ window->conditions.insert("lv2gui");
+ plugin_gui *gui = new plugin_gui(window);
+ *(GtkWidget **)(widget) = gui->create(proxy);
+
+ return (LV2UI_Handle)gui;
+}
+
+void gui_cleanup(LV2UI_Handle handle)
+{
+ plugin_gui *gui = (plugin_gui *)handle;
+ delete gui;
+}
+
+void gui_port_event(LV2UI_Handle handle, uint32_t port, uint32_t buffer_size, const void *buffer)
+{
+ plugin_gui *gui = (plugin_gui *)handle;
+ float v = *(float *)buffer;
+ printf("spv %d %f\n", port, v);
+ port -= gui->plugin->get_param_port_offset();
+ if (port >= (uint32_t)gui->plugin->get_param_count())
+ return;
+ gui->set_param_value(port, v);
+}
+
+const void *gui_extension(const char *uri)
+{
+ return NULL;
+}
+
+namespace synth {
+
+// this function is normally implemented in preset_gui.cpp, but we're not using that file
+void activate_preset(GtkAction *action, activate_preset_params *params)
+{
+}
+
+};
+
+const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index)
+{
+ gui.URI = "http://calf.sourceforge.net/plugins/gui/gtk2-gui";
+ gui.instantiate = gui_instantiate;
+ gui.cleanup = gui_cleanup;
+ gui.port_event = gui_port_event;
+ gui.extension_data = gui_extension;
+ switch(index) {
+ case 0:
+ return &gui;
+ default:
+ return NULL;
+ }
+}
+
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index e9fafff..a202a44 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -110,7 +110,10 @@ void make_ttl()
ttl =
"@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n"
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
- "@prefix doap: <http://usefulinc.com/ns/doap#> .\n\n";
+ "@prefix doap: <http://usefulinc.com/ns/doap#> .\n"
+ "@prefix guiext: <http://ll-plugins.nongnu.org/lv2/ext/gui#> .\n"
+ "\n"
+ ;
vector<synth::giface_plugin_info> plugins;
synth::get_all_plugins(plugins);
@@ -131,6 +134,10 @@ void make_ttl()
classes[name] = "lv2:" + name;
}
+#if USE_LV2_GUI
+ ttl += "<http://calf.sourceforge.net/plugins/gui/gtk2-gui>\n a guiext:GtkGUI ;\n guiext:binary <calflv2gui.so> .\n\n";
+#endif
+
for (unsigned int i = 0; i < plugins.size(); i++) {
synth::giface_plugin_info &pi = plugins[i];
ttl += string("<http://calf.sourceforge.net/plugins/")
@@ -142,6 +149,11 @@ void make_ttl()
ttl += " doap:name \""+string(pi.info->name)+"\" ;\n";
+
+#if USE_LV2_GUI
+ ttl += " guiext:gui <http://calf.sourceforge.net/plugins/gui/gtk2-gui> ;\n";
+#endif
+
#if USE_PHAT
ttl += " doap:license <http://usefulinc.com/doap/licenses/gpl> ;\n";
#else
@@ -196,7 +208,7 @@ int main(int argc, char *argv[])
switch(c) {
case 'h':
case '?':
- printf("LADSPA RDF generator for Calf plugin pack\nSyntax: %s [--help] [--version] [--mode rdf|ttl|manifest]\n", argv[0]);
+ printf("LADSPA RDF / LV2 TTL generator for Calf plugin pack\nSyntax: %s [--help] [--version] [--mode rdf|ttl|manifest]\n", argv[0]);
return 0;
case 'v':
printf("%s\n", PACKAGE_STRING);
diff --git a/src/modules.cpp b/src/modules.cpp
index a7517f7..af419e5 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -153,7 +153,7 @@ ALL_WRAPPERS(monosynth)
////////////////////////////////////////////////////////////////////////////
-#if USE_LADSPA
+#if USE_LV2
extern "C" {
const LV2_Descriptor *lv2_descriptor(uint32_t index)
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list