[SCM] calf/master: + LV2, Framework: initial implementation of message_run() API + bridge between message_run() and configure() (mostly untested)

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


The following commit has been merged in the master branch:
commit 6e5412a2a106f9733bdd7a9c0426882c2d3207bf
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Nov 23 22:51:30 2008 +0000

    + LV2, Framework: initial implementation of message_run() API + bridge between message_run() and configure() (mostly untested)

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 3c295f0..86e3800 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -253,6 +253,8 @@ struct plugin_metadata_iface
     virtual bool requires_message_context() = 0;
     /// does the plugin require string port extension? (or DSSI configure) may be slow
     virtual bool requires_string_ports() = 0;
+    /// add all message context parameter numbers to the ports vector
+    virtual void get_message_context_parameters(std::vector<int> &ports) = 0;
 
     /// Do-nothing destructor to silence compiler warning
     virtual ~plugin_metadata_iface() {}
@@ -320,11 +322,17 @@ public:
     /// Execute menu command with given number
     inline void execute(int cmd_no) {}
     /// DSSI configure call
-    inline char *configure(const char *key, const char *value) { return NULL; }
+    virtual char *configure(const char *key, const char *value) { return NULL; }
     /// Send all understood configure vars
     inline void send_configures(send_configure_iface *sci) {}
     /// Reset parameter values for epp:trigger type parameters (ones activated by oneshot push button instead of check box)
     inline void params_reset() {}
+    /// Handle 'message context' port message
+    /// @arg output_ports pointer to bit array of output port "changed" flags, note that 0 = first audio input, not first parameter (use input_count + output_count)
+    inline void message_run(uint32_t *output_ports) { 
+        fprintf(stderr, "ERROR: message run not implemented\n");
+        // configure(param_props[parameter].short_name, dynamic_cast<>()); 
+    }
 };
 
 extern bool check_for_message_context_ports(parameter_properties *parameters, int count);
@@ -362,6 +370,12 @@ public:
     const ladspa_plugin_info &get_plugin_info() { return plugin_info; }
     bool requires_message_context() { return check_for_message_context_ports(param_props, Metadata::param_count); }
     bool requires_string_ports() { return check_for_string_ports(param_props, Metadata::param_count); }
+    void get_message_context_parameters(std::vector<int> &ports) {
+        for (int i = 0; i < get_param_count(); ++i) {
+            if (get_param_props(i)->flags & PF_PROP_MSGCONTEXT)
+                ports.push_back(i);
+        }
+    }
 };
 
 /// A class for delegating metadata implementation to "remote" metadata class.
@@ -394,6 +408,7 @@ public:
     const ladspa_plugin_info &get_plugin_info() { return impl->get_plugin_info(); }
     bool requires_message_context() { return impl->requires_message_context(); }
     bool requires_string_ports() { return impl->requires_string_ports(); }
+    void get_message_context_parameters(std::vector<int> &ports) { impl->get_message_context_parameters(ports); }
 };
 
 #define CALF_PORT_NAMES(name) template<> const char *::plugin_metadata<name##_metadata>::port_names[]
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index 7789ca1..7b794a5 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -24,6 +24,7 @@
 #if USE_LV2
 
 #include <string>
+#include <vector>
 #include <lv2.h>
 #include <calf/giface.h>
 #include <calf/lv2-midiport.h>
@@ -44,6 +45,7 @@ struct lv2_instance: public plugin_ctl_iface, public Module
     LV2_URI_Map_Feature *uri_map;
     LV2_Event_Feature *event_feature;
     uint32_t midi_event_type;
+    std::vector<int> message_params;
     lv2_instance()
     {
         for (int i=0; i < Module::in_count; i++)
@@ -58,6 +60,8 @@ struct lv2_instance: public plugin_ctl_iface, public Module
         midi_event_type = 0xFFFFFFFF;
         set_srate = true;
         srate_to_set = 44100;
+        get_message_context_parameters(message_params);
+        printf("message params %d\n", (int)message_params.size());
     }
     virtual parameter_properties *get_param_props(int param_no)
     {
@@ -111,6 +115,24 @@ struct lv2_instance: public plugin_ctl_iface, public Module
     void send_configures(send_configure_iface *sci) { 
         Module::send_configures(sci);
     }
+    void impl_message_run(uint32_t *output_ports) {
+        for (unsigned int i = 0; i < message_params.size(); i++)
+        {
+            int pn = message_params[i];
+            parameter_properties &pp = *get_param_props(pn);
+            if ((pp.flags & PF_TYPEMASK) == PF_STRING) {
+                printf("Calling configure on %s\n", pp.short_name);
+                configure(pp.short_name, ((LV2_String_Data *)Module::params[pn])->data);
+            }
+        }
+        Module::message_run(output_ports);
+    }
+    char *configure(const char *key, const char *value) { 
+        // disambiguation - the plugin_ctl_iface version is just a stub, so don't use it
+        return Module::configure(key, value);
+    }
+#if 0
+    // the default implementation should be fine
     virtual void clear_preset() {
         // This is never called in practice, at least for now
         // However, it will change when presets are implemented
@@ -125,6 +147,7 @@ struct lv2_instance: public plugin_ctl_iface, public Module
         }
         */
     }
+#endif
 };
 
 struct LV2_Calf_Descriptor {
@@ -137,6 +160,7 @@ struct lv2_wrapper
     typedef lv2_instance<Module> instance;
     static LV2_Descriptor descriptor;
     static LV2_Calf_Descriptor calf_descriptor;
+    static LV2MessageContext message_context;
     std::string uri;
     
     lv2_wrapper()
@@ -152,6 +176,8 @@ struct lv2_wrapper
         descriptor.cleanup = cb_cleanup;
         descriptor.extension_data = cb_ext_data;
         calf_descriptor.get_pci = cb_get_pci;
+        message_context.message_connect_port = cb_connect;
+        message_context.message_run = cb_message_run;
     }
 
     static void cb_connect(LV2_Handle Instance, uint32_t port, void *DataLocation) {
@@ -230,6 +256,11 @@ struct lv2_wrapper
         }
     }
 
+    static bool cb_message_run(LV2_Handle Instance, uint32_t *outputs_written) {
+        instance *mod = (instance *)Instance;
+        mod->impl_message_run(outputs_written);
+        return true;
+    }
     static void cb_run(LV2_Handle Instance, uint32_t SampleCount) {
         instance *const mod = (instance *)Instance;
         if (mod->set_srate) {
@@ -281,8 +312,11 @@ struct lv2_wrapper
         delete mod;
     }
     static const void *cb_ext_data(const char *URI) {
+        fprintf(stderr, "%s\n", URI);
         if (!strcmp(URI, "http://foltman.com/ns/calf-plugin-instance"))
             return &calf_descriptor;
+        if (!strcmp(URI, LV2_CONTEXT_MESSAGE))
+            return &message_context;
         return NULL;
     }
     static lv2_wrapper &get() { 
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index 243f901..f36c7cc 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -25,6 +25,7 @@
 #include <calf/plugininfo.h>
 #include <calf/utils.h>
 #if USE_LV2
+#include <calf/lv2_contexts.h>
 #include <calf/lv2_event.h>
 #include <calf/lv2_uri_map.h>
 #endif
@@ -566,6 +567,7 @@ void make_ttl(string path_prefix)
         if (pi->requires_message_context())
         {
             ttl += "    lv2:requiredFeature <http://lv2plug.in/ns/dev/contexts> ;\n";
+            ttl += "    lv2:requiredFeature <" LV2_CONTEXT_MESSAGE "> ;\n";
             ttl += "    lv2ctx:requiredContext lv2ctx:MessageContext ;\n";
         }
         if (pi->requires_string_ports())
diff --git a/src/modules.cpp b/src/modules.cpp
index f243392..bdd6057 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -99,7 +99,7 @@ CALF_PORT_PROPS(filter) = {
     { 2000,      10,20000,    0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq", "Frequency" },
     { 0.707,  0.707,   32,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "res", "Resonance" },
     { 0,          0,    5,    1, PF_ENUM | PF_CTL_COMBO, filter_choices, "mode", "Mode" },
-    { 20,         5,  100,    20, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "inertia", "Inertia"},
+    { 20,         5,  100,    20, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC | PF_PROP_MSGCONTEXT, NULL, "inertia", "Inertia"},
 };
 
 CALF_PLUGIN_INFO(filter) = { 0x847f, "Filter", "Calf Filter", "Krzysztof Foltman", calf_plugins::calf_copyright_info, "FilterPlugin" };
diff --git a/src/organ.cpp b/src/organ.cpp
index da58108..7d244b6 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -772,7 +772,7 @@ char *organ_audio_module::configure(const char *key, const char *value)
         }
         return NULL;
     }
-    cout << "Set configure value " << key << " to " << value;
+    cout << "Set unknown configure value " << key << " to " << value;
     return NULL;
 }
 
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 1b1489e..380cc9b 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -30,6 +30,7 @@ using namespace calf_plugins;
 // instantiate descriptor templates
 template<class Module> LV2_Descriptor calf_plugins::lv2_wrapper<Module>::descriptor;
 template<class Module> LV2_Calf_Descriptor calf_plugins::lv2_wrapper<Module>::calf_descriptor;
+template<class Module> LV2MessageContext calf_plugins::lv2_wrapper<Module>::message_context;
 
 extern "C" {
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list