[SCM] calf/master: + DSSI: first (successful) attempt at sending OSC messages from the plugin to the GUI

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


The following commit has been merged in the master branch:
commit d175d0f608a42414f2b0b815f6d3a56272a00076
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Jan 21 00:24:44 2009 +0000

    + DSSI: first (successful) attempt at sending OSC messages from the plugin to the GUI

diff --git a/src/calf/giface.h b/src/calf/giface.h
index dfc0440..e82bc5d 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -23,11 +23,16 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <pthread.h>
 #include <exception>
 #include <string>
 #include "primitives.h"
 #include "preset.h"
 
+namespace osctl {
+    struct osc_client;
+}
+
 namespace calf_plugins {
 
 enum {
@@ -351,6 +356,20 @@ public:
 
 extern bool check_for_message_context_ports(parameter_properties *parameters, int count);
 extern bool check_for_string_ports(parameter_properties *parameters, int count);
+extern void send_graph_via_osc(osctl::osc_client &client, const std::string &address, line_graph_iface *graph);
+
+#if USE_DSSI
+/// A class to send status updates via OSC
+struct dssi_feedback_sender
+{
+    osctl::osc_client *client;
+    pthread_t bg_thread;
+    bool quit;
+    
+    dssi_feedback_sender(const char *URI);
+    ~dssi_feedback_sender();
+};
+#endif
 
 /// Metadata base class template, to provide default versions of interface functions
 template<class Metadata>
diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index fdd3332..b341146 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -41,12 +41,16 @@ inline int calc_real_param_count()
     }
     return Module::param_count;
 }
-    
+
 /// A template implementing plugin_ctl_iface for a given plugin
 template<class Module>
 struct ladspa_instance: public Module, public plugin_ctl_iface
 {
     bool activate_flag;
+#if USE_DSSI
+    dssi_feedback_sender *feedback_sender;
+#endif
+    
     static int real_param_count()
     {
         static int _real_param_count = calc_real_param_count<Module>();
@@ -62,6 +66,9 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
         for (int i=0; i < rpc; i++)
             Module::params[i] = NULL;
         activate_flag = true;
+#if USE_DSSI
+        feedback_sender = NULL;
+#endif
     }
     virtual parameter_properties *get_param_props(int param_no)
     {
@@ -113,6 +120,29 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     }
     virtual char *configure(const char *key, const char *value)
     {
+        printf("%s = %s\n", key, value);
+#if USE_DSSI
+        if (!strcmp(key, "OSC:FEEDBACK_URI"))
+        {
+            if (*value)
+            {
+                if (feedback_sender) {
+                    delete feedback_sender;
+                    feedback_sender = NULL;
+                }
+                feedback_sender = new dssi_feedback_sender(value);
+            }
+            else
+            {
+                if (feedback_sender) {
+                    delete feedback_sender;
+                    feedback_sender = NULL;
+                }
+            }
+            return NULL;
+        }
+        else 
+#endif
         if (!strcmp(key, "ExecCommand"))
         {
             if (*value)
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index dfc6c4f..40de558 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -216,6 +216,14 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
         presets.insert(presets.end(), tmp_presets.begin(), tmp_presets.end());
     }
     
+    void set_osc_update(bool enabled)
+    {
+        osc_inline_typed_strstream data;
+        data << "OSC:FEEDBACK_URI";
+        data << (enabled ? get_uri() : "");
+        cli.send("/configure", data);
+    }
+    
     virtual void receive_osc_message(std::string address, std::string args, osc_strstream &buffer)
     {
         if (osc_debug)
@@ -227,13 +235,14 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
             debug_printf("UPDATE: %s\n", str.c_str());
             return;
         }
-        if (address == prefix + "/quit")
+        else if (address == prefix + "/quit")
         {
+            set_osc_update(false);
             debug_printf("QUIT\n");
             g_main_loop_quit(mainloop);
             return;
         }
-        if (address == prefix + "/configure"&& args == "ss")
+        else if (address == prefix + "/configure"&& args == "ss")
         {
             string key, value;
             buffer >> key >> value;
@@ -242,7 +251,7 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
             window->gui->refresh();
             return;
         }
-        if (address == prefix + "/program"&& args == "ii")
+        else if (address == prefix + "/program"&& args == "ii")
         {
             uint32_t bank, program;
             
@@ -274,7 +283,7 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
             // cli.send("/update", data);
             return;
         }
-        if (address == prefix + "/control" && args == "if")
+        else if (address == prefix + "/control" && args == "if")
         {
             uint32_t port;
             float val;
@@ -289,16 +298,22 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
             plugin->send_osc = sosc;
             return;
         }
-        if (address == prefix + "/show")
+        else if (address == prefix + "/show")
         {
+            set_osc_update(true);
+
             gtk_widget_show_all(GTK_WIDGET(window->toplevel));
             return;
         }
-        if (address == prefix + "/hide")
+        else if (address == prefix + "/hide")
         {
+            set_osc_update(false);
+
             gtk_widget_hide(GTK_WIDGET(window->toplevel));
             return;
         }
+        else
+            printf("Unknown OSC address: %s\n", address.c_str());
     }
 };
 
@@ -369,6 +384,8 @@ int main(int argc, char *argv[])
     }
     
     g_main_loop_run(mainloop);
+
+    srv.set_osc_update(false);
     debug_printf("exited\n");
     
     return 0;
diff --git a/src/giface.cpp b/src/giface.cpp
index 03209b7..756090d 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -22,6 +22,7 @@
 #include <assert.h>
 #include <memory.h>
 #include <calf/giface.h>
+#include <calf/osctlnet.h>
 
 using namespace std;
 using namespace calf_utils;
@@ -233,3 +234,26 @@ bool calf_plugins::check_for_string_ports(parameter_properties *parameters, int
     }
     return false;
 }
+
+void calf_plugins::send_graph_via_osc(osctl::osc_client &client, const std::string &address, line_graph_iface *graph)
+{
+    osctl::osc_inline_typed_strstream os;
+    os << (uint32_t)10;
+    client.send(address, os);
+}
+
+calf_plugins::dssi_feedback_sender::dssi_feedback_sender(const char *URI)
+{
+    client = new osctl::osc_client;
+    client->bind("0.0.0.0", 0);
+    client->set_url(URI);
+    client->send("/iAmHere");
+}
+
+calf_plugins::dssi_feedback_sender::~dssi_feedback_sender()
+{
+    // this would not be received by GUI's main loop because it's already been terminated
+    // client->send("/iQuit");
+    delete client;
+}
+

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list