[SCM] calf/master: + LV2: unbreak, make live graphs work (using instance-access as for now)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:22 UTC 2013


The following commit has been merged in the master branch:
commit e4dc60114d132f8112a3f7e7d63522c2e97efba9
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Nov 5 23:36:54 2008 +0000

    + LV2: unbreak, make live graphs work (using instance-access as for now)

diff --git a/src/calf/giface.h b/src/calf/giface.h
index e405baf..25bf912 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -149,7 +149,18 @@ struct line_graph_iface
     /// @param context cairo context to adjust (for multicolour graphs etc.)
     /// @retval true graph data was returned; subindex+1 graph may or may not be available
     /// @retval false graph data was not returned; subindex+1 graph does not exist either
-    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) = 0;
+    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) { return false; }
+    
+    /// Obtain subindex'th static graph of parameter index (static graphs are only dependent on parameter value, not plugin state)
+    /// @param index parameter/graph number (usually tied to particular plugin control port)
+    /// @param subindex graph number (there may be multiple overlaid graphs for one parameter, eg. for monosynth 2x12dB filters)
+    /// @param value parameter value to pick the graph for
+    /// @param data buffer for normalized output values
+    /// @param points number of points to fill
+    /// @param context cairo context to adjust (for multicolour graphs etc.)
+    /// @retval true graph data was returned; subindex+1 graph may or may not be available
+    /// @retval false graph data was not returned; subindex+1 graph does not exist either
+    virtual bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context) { return false; }
     /// Standard destructor to make compiler happy
     virtual ~line_graph_iface() {}
 };
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index 10e58ec..3b3b910 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -34,7 +34,7 @@
 namespace calf_plugins {
 
 template<class Module>
-struct lv2_instance: public Module, public plugin_ctl_iface
+struct lv2_instance: public plugin_ctl_iface, public Module
 {
     bool set_srate;
     int srate_to_set;
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index ca7726c..9415d4b 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -139,7 +139,7 @@ public:
     /// Retrieve filter graph (which is 'live' so it cannot be generated by get_static_graph), or fall back to get_static_graph.
     bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
     /// Retrieve waveform graph (which does not need information about synth state)
-    static bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context);
+    bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context);
     /// @retval true if the filter 1 is to be used for the left channel and filter 2 for the right channel
     /// @retval false if filters are to be connected in series and sent (mono) to both channels    
     inline bool is_stereo_filter() const
@@ -188,7 +188,7 @@ public:
     }
 };
 
-struct organ_audio_module: public audio_module<organ_metadata>, public dsp::drawbar_organ
+struct organ_audio_module: public audio_module<organ_metadata>, public dsp::drawbar_organ, public line_graph_iface
 {
 public:
     using drawbar_organ::note_on;
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 70f7bd6..fe6613b 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -44,11 +44,15 @@ struct plugin_proxy: public plugin_ctl_iface, public plugin_metadata_proxy
     plugin_gui *gui;
     float *params;
     int param_count;
+    /// Instance pointer - usually NULL unless the host supports instance-access extension
+    plugin_ctl_iface *instance;
+    int source_id;
     
     plugin_proxy(plugin_metadata_iface *md)
     : plugin_metadata_proxy(md)
     {
         gui = NULL;
+        instance = NULL;
         send = true;
         param_count = get_param_count();
         params = new float[param_count];
@@ -83,6 +87,11 @@ struct plugin_proxy: public plugin_ctl_iface, public plugin_metadata_proxy
         return false;
     }
     
+    virtual line_graph_iface *get_line_graph_iface() {
+        printf("lgi=%p\n", instance->get_line_graph_iface());
+        return instance->get_line_graph_iface();
+    }
+    
     virtual float get_level(unsigned int port) { return 0.f; }
     virtual void execute(int command_no) { assert(0); }
     void send_configures(send_configure_iface *sci) { 
@@ -97,6 +106,13 @@ struct plugin_proxy: public plugin_ctl_iface, public plugin_metadata_proxy
     }
 };
 
+static gboolean plugin_on_idle(void *data)
+{
+    plugin_gui *self = (plugin_gui *)data;
+    self->on_idle();
+    return TRUE;
+}
+
 LV2UI_Handle gui_instantiate(const struct _LV2UI_Descriptor* descriptor,
                           const char*                     plugin_uri,
                           const char*                     bundle_path,
@@ -119,10 +135,23 @@ LV2UI_Handle gui_instantiate(const struct _LV2UI_Descriptor* descriptor,
     }
     if (!proxy)
         return NULL;
+    for (int i = 0; features[i]; i++)
+    {
+        if (!strcmp(features[i]->URI, "http://lv2plug.in/ns/ext/instance-access"))
+        {
+            proxy->instance = (plugin_ctl_iface *)features[i]->data;
+            printf("Instance %p\n", features[i]->data);
+        }
+        if (!strcmp(features[i]->URI, "http://lv2plug.in/ns/ext/data-access"))
+        {
+            printf("Data %p\n", features[i]->data);
+        }
+    }
     scope_assign<bool> _a_(proxy->send, false);
     proxy->setup(write_function, controller);
     // dummy window
     main_window *main = new main_window;
+    main->conditions.insert("directlink");
     main->conditions.insert("lv2gui");    
     plugin_gui_window *window = new plugin_gui_window(main);
     plugin_gui *gui = new plugin_gui(window);
@@ -132,12 +161,18 @@ LV2UI_Handle gui_instantiate(const struct _LV2UI_Descriptor* descriptor,
     else
         *(GtkWidget **)(widget) = gui->create(proxy);
     
+    if (*(GtkWidget **)(widget))
+        proxy->source_id = g_timeout_add_full(G_PRIORITY_LOW, 1000/30, plugin_on_idle, gui, NULL); // 30 fps should be enough for everybody    
+    
     return (LV2UI_Handle)gui;
 }
 
 void gui_cleanup(LV2UI_Handle handle)
 {
     plugin_gui *gui = (plugin_gui *)handle;
+    plugin_proxy *proxy = dynamic_cast<plugin_proxy *>(gui->plugin);
+    if (proxy->source_id)
+        g_source_remove(proxy->source_id);
     delete gui;
 }
 
@@ -163,7 +198,7 @@ const void *gui_extension(const char *uri)
     return NULL;
 }
 
-namespace synth {
+namespace calf_plugins {
 
 // 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)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list