[SCM] calf/master: Replace string port/message context using persist extension.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:24 UTC 2013


The following commit has been merged in the master branch:
commit b8e69ceb2ff7aca549efd939d04447e2f08ad5a8
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Tue Sep 21 00:07:46 2010 +0100

    Replace string port/message context using persist extension.

diff --git a/gui/gui-fluidsynth.xml b/gui/gui-fluidsynth.xml
index 34a5755..bdb9ace 100644
--- a/gui/gui-fluidsynth.xml
+++ b/gui/gui-fluidsynth.xml
@@ -13,7 +13,7 @@
     </vbox>
     <frame attach-x="2" attach-y="0" label="Source">
       <table rows="3" cols="2" pad-x="10" fill-y="0">
-          <align attach-x="0" attach-y="0"   align-x="1"><label param="soundfont"  /></align>
+          <align attach-x="0" attach-y="0"   align-x="1"><label text="Soundfont"  /></align>
           <filechooser attach-x="1" attach-y="0" key="soundfont" title="Select a soundfont" width_chars="30" pad-x="5" pad-y="6" />
           <align attach-x="0" attach-y="1"   align-x="1"><label text="Current preset" /></align>
           <combo attach-x="1" attach-y="1" key="preset_list" current-key="preset_key" setter-key="preset_key_set" pad-x="5" pad-y="6" />
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 7525197..d4eb287 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -28,8 +28,6 @@
 #include <string>
 #include <vector>
 
-// #define USE_PERSIST_EXTENSION 1
-
 namespace osctl {
     struct osc_client;
 }
@@ -49,7 +47,6 @@ enum parameter_flags
   PF_BOOL = 0x0002,  ///< bool value (usually >=0.5f is treated as TRUE, which is inconsistent with LV2 etc. which treats anything >0 as TRUE)
   PF_ENUM = 0x0003,  ///< enum value (min, min+1, ..., max, only guaranteed to work when min = 0)
   PF_ENUM_MULTI = 0x0004, ///< SET / multiple-choice
-  PF_STRING = 0x0005, ///< see: http://lv2plug.in/docs/index.php?title=String_port
   
   PF_SCALEMASK = 0xF0, ///< bit mask for scale
   PF_SCALE_DEFAULT = 0x00, ///< no scale given
@@ -84,7 +81,6 @@ enum parameter_flags
   PF_PROP_OUTPUT    = 0x080000, ///< output port
   PF_PROP_OPTIONAL  = 0x100000, ///< connection optional
   PF_PROP_GRAPH     = 0x200000, ///< add graph
-  PF_PROP_MSGCONTEXT= 0x400000, ///< message context
   
   PF_UNITMASK     = 0xFF000000,  ///< bit mask for units   \todo reduce to use only 5 bits
   PF_UNIT_DB      = 0x01000000,  ///< decibels
@@ -301,8 +297,6 @@ struct plugin_metadata_iface
     virtual const char *get_label() const = 0;
     /// @return total number of parameters
     virtual int get_param_count() const = 0;
-    /// @return total number of parameters that aren't configure variables
-    virtual int get_nonstring_param_count() const = 0;
     /// Return custom XML
     virtual const char *get_gui_xml() const = 0;
     /// @return number of audio inputs
@@ -335,12 +329,10 @@ struct plugin_metadata_iface
     virtual bool is_cv(int param_no) const = 0;
     /// is the given parameter non-interpolated?
     virtual bool is_noisy(int param_no) const = 0;
-    /// does the plugin require message context? (or DSSI configure) may be slow
-    virtual bool requires_message_context() const = 0;
     /// does the plugin require string port extension? (or DSSI configure) may be slow
-    virtual bool requires_string_ports() const = 0;
-    /// add all message context parameter numbers to the ports vector
-    virtual void get_message_context_parameters(std::vector<int> &ports) const = 0;
+    virtual bool requires_configure() const = 0;
+    /// obtain array of names of configure variables (or NULL is none needed)
+    virtual const char *const *get_configure_vars() const { return NULL; }
 
     /// Do-nothing destructor to silence compiler warning
     virtual ~plugin_metadata_iface() {}
@@ -431,7 +423,7 @@ struct audio_module_iface
     virtual void set_sample_rate(uint32_t sr) = 0;
     /// Execute menu command with given number
     virtual void execute(int cmd_no) = 0;
-    /// DSSI configure call
+    /// DSSI configure call, value = NULL = reset to default
     virtual char *configure(const char *key, const char *value) = 0;
     /// Send all understood configure vars (none by default)
     virtual void send_configures(send_configure_iface *sci) = 0;
@@ -556,9 +548,6 @@ public:
     virtual const line_graph_iface *get_line_graph_iface() const { return dynamic_cast<const line_graph_iface *>(this); }
 };
 
-extern bool check_for_message_context_ports(const parameter_properties *parameters, int count);
-extern bool check_for_string_ports(const parameter_properties *parameters, int count);
-
 #if USE_EXEC_GUI || USE_DSSI
 
 enum line_graph_item
@@ -629,20 +618,7 @@ public:
     bool is_cv(int param_no) const { return true; }
     bool is_noisy(int param_no) const { return false; }
     const ladspa_plugin_info &get_plugin_info() const { return plugin_info; }
-    bool requires_message_context() const { return check_for_message_context_ports(param_props, Metadata::param_count); }
-    bool requires_string_ports() const { return check_for_string_ports(param_props, Metadata::param_count); }
-    void get_message_context_parameters(std::vector<int> &ports) const {
-        for (int i = 0; i < get_param_count(); ++i) {
-            if (get_param_props(i)->flags & PF_PROP_MSGCONTEXT)
-                ports.push_back(i);
-        }
-    }
-    int get_nonstring_param_count() const {
-        int i = Metadata::param_count;
-        while(i > 0 && (param_props[i - 1].flags & PF_TYPEMASK) == PF_STRING)
-            i--;
-        return i;
-    }
+    bool requires_configure() const { return false; }
 };
 
 #define CALF_PORT_NAMES(name) template<> const char *::plugin_metadata<name##_metadata>::port_names[]
diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index 68009b8..d94ebce 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -88,7 +88,7 @@ struct ladspa_plugin_metadata_set
     std::vector<DSSI_Program_Descriptor> *preset_descs;
 #endif
     
-    int input_count, output_count, param_count, real_param_count;
+    int input_count, output_count, param_count;
     const plugin_metadata_iface *metadata;
     
     ladspa_plugin_metadata_set();
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index 2c130be..8fda6d9 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -28,11 +28,9 @@
 #include <lv2.h>
 #include <calf/giface.h>
 #include <calf/lv2-midiport.h>
-#include <calf/lv2_contexts.h>
 #include <calf/lv2_event.h>
 #include <calf/lv2_persist.h>
 #include <calf/lv2_progress.h>
-#include <calf/lv2_string_port.h>
 #include <calf/lv2_uri_map.h>
 #include <string.h>
 
@@ -49,7 +47,6 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
     LV2_URI_Map_Feature *uri_map;
     LV2_Event_Feature *event_feature;
     uint32_t midi_event_type;
-    std::vector<int> message_params;
     LV2_Progress *progress_report_feature;
     float **ins, **outs, **params;
     int out_count;
@@ -59,13 +56,8 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
         module = _module;
         module->get_port_arrays(ins, outs, params);
         metadata = module->get_metadata_iface();
-        metadata->get_message_context_parameters(message_params);
         out_count = metadata->get_output_count();
-#if USE_PERSIST_EXTENSION
-        real_param_count = metadata->get_nonstring_param_count();
-#else
         real_param_count = metadata->get_param_count();
-#endif
         
         uri_map = NULL;
         midi_data = NULL;
@@ -75,7 +67,6 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
 
         srate_to_set = 44100;
         set_srate = true;
-        // printf("message params %d\n", (int)message_params.size());
     }
     /// This, and not Module::post_instantiate, is actually called by lv2_wrapper class
     void post_instantiate()
@@ -98,43 +89,24 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
     void send_configures(send_configure_iface *sci) { 
         module->send_configures(sci);
     }
-    uint32_t impl_message_run(const void *valid_inputs, void *output_ports) {
-        uint8_t *vi = (uint8_t *)valid_inputs;
-        int ofs = metadata->get_param_port_offset();
-        for (unsigned int i = 0; i < message_params.size(); i++)
-        {
-            int pn = message_params[i];
-            const parameter_properties &pp = *metadata->get_param_props(pn);
-            int ppn = pn + ofs;
-            if ((pp.flags & PF_TYPEMASK) == PF_STRING && (vi[ppn >> 3] & (1 << (ppn & 7)))
-                && (((LV2_String_Data *)params[pn])->flags & LV2_STRING_DATA_CHANGED_FLAG)) {
-                // printf("Calling configure on %s\n", pp.short_name);
-                configure(pp.short_name, ((LV2_String_Data *)params[pn])->data);
-            }
-        }
-        return module->message_run(valid_inputs, output_ports);
-    }
-#if USE_PERSIST_EXTENSION
     void impl_restore(LV2_Persist_Retrieve_Function retrieve, void *callback_data)
     {
-        for (unsigned int i = 0; i < message_params.size(); i++)
+        const char *const *vars = module->get_metadata_iface()->get_configure_vars();
+        if (!vars)
+            return;
+        for (unsigned int i = 0; vars[i]; i++)
         {
-            int pn = message_params[i];
-            const parameter_properties &pp = *metadata->get_param_props(pn);
-            if ((pp.flags & PF_TYPEMASK) == PF_STRING) {
-                size_t len = 0;
-                const void *ptr = (*retrieve)(callback_data, pp.short_name, &len);
-                if (ptr)
-                {
-                    printf("Calling configure on %s\n", pp.short_name);
-                    configure(pp.short_name, std::string((const char *)ptr, len).c_str());
-                }
-                else
-                    configure(pp.short_name, pp.choices[0]);
+            size_t len = 0;
+            const void *ptr = (*retrieve)(callback_data, vars[i], &len);
+            if (ptr)
+            {
+                printf("Calling configure on %s\n", vars[i]);
+                configure(vars[i], std::string((const char *)ptr, len).c_str());
             }
+            else
+                configure(vars[i], NULL);
         }
     }
-#endif
     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);
@@ -204,7 +176,6 @@ struct lv2_wrapper
     typedef lv2_instance instance;
     static LV2_Descriptor descriptor;
     static LV2_Calf_Descriptor calf_descriptor;
-    static LV2MessageContext message_context;
     static LV2_Persist persist;
     std::string uri;
     
@@ -220,13 +191,9 @@ struct lv2_wrapper
         descriptor.deactivate = cb_deactivate;
         descriptor.cleanup = cb_cleanup;
         descriptor.extension_data = cb_ext_data;
-#if USE_PERSIST_EXTENSION
         persist.save = cb_persist_save;
         persist.restore = cb_persist_restore;
-#endif
         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)
@@ -235,11 +202,7 @@ struct lv2_wrapper
         const plugin_metadata_iface *md = mod->metadata;
         unsigned long ins = md->get_input_count();
         unsigned long outs = md->get_output_count();
-#if USE_PERSIST_EXTENSION
-        unsigned long params = md->get_nonstring_param_count();
-#else
         unsigned long params = md->get_param_count();
-#endif
         if (port < ins)
             mod->ins[port] = (float *)DataLocation;
         else if (port < ins + outs)
@@ -299,11 +262,6 @@ struct lv2_wrapper
         return static_cast<plugin_ctl_iface *>(Instance);
     }
 
-    static uint32_t cb_message_run(LV2_Handle Instance, const void *valid_inputs, void *outputs_written)
-    {
-        instance *mod = (instance *)Instance;
-        return mod->impl_message_run(valid_inputs, outputs_written);
-    }
     static void cb_run(LV2_Handle Instance, uint32_t SampleCount)
     {
         instance *const inst = (instance *)Instance;
@@ -330,15 +288,10 @@ struct lv2_wrapper
     {
         if (!strcmp(URI, "http://foltman.com/ns/calf-plugin-instance"))
             return &calf_descriptor;
-        if (!strcmp(URI, LV2_CONTEXT_MESSAGE))
-            return &message_context;
-#if USE_PERSIST_EXTENSION
         if (!strcmp(URI, LV2_PERSIST_URI))
             return &persist;
-#endif
         return NULL;
     }
-#if USE_PERSIST_EXTENSION
     static void cb_persist_save(LV2_Handle Instance, LV2_Persist_Store_Function store, void *callback_data)
     {
         instance *const inst = (instance *)Instance;
@@ -362,7 +315,6 @@ struct lv2_wrapper
         instance *const inst = (instance *)Instance;
         inst->impl_restore(retrieve, callback_data);
     }
-#endif
     
     static lv2_wrapper &get() { 
         static lv2_wrapper *instance = new lv2_wrapper;
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 7f6f324..2941df5 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -403,7 +403,10 @@ struct organ_metadata: public organ_enums, public plugin_metadata<organ_metadata
 {
     enum { in_count = 0, out_count = 2, ins_optional = 0, outs_optional = 0, support_midi = true, require_midi = true, rt_capable = true };
     PLUGIN_NAME_ID_LABEL("organ", "organ", "Organ")
+    
+public:
     plugin_command_info *get_commands();
+    const char *const *get_configure_vars() const;
 };
 
 /// FluidSynth - metadata
@@ -412,6 +415,9 @@ struct fluidsynth_metadata: public plugin_metadata<fluidsynth_metadata>
     enum { par_master, par_interpolation, par_reverb, par_chorus, par_soundfont, par_preset_key_set, param_count };
     enum { in_count = 0, out_count = 2, ins_optional = 0, outs_optional = 0, support_midi = true, require_midi = true, rt_capable = false };
     PLUGIN_NAME_ID_LABEL("fluidsynth", "fluidsynth", "Fluidsynth")
+
+public:
+    const char *const *get_configure_vars() const;
 };
     
 /// Wavetable - metadata
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index 96af86a..c316bc1 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -128,11 +128,6 @@ struct plugin_proxy: public plugin_ctl_iface, public line_graph_iface
     virtual void set_param_value(int param_no, float value) {
         if (param_no < 0 || param_no >= param_count)
             return;
-        if((metadata->get_param_props(param_no)->flags & PF_TYPEMASK) == PF_STRING)
-        {
-            g_warning("Attempting to set a float value on a string port");
-            return;
-        }
         update_graphs = true;
         params[param_no] = value;
         if (send_osc)
diff --git a/src/giface.cpp b/src/giface.cpp
index b8705b6..3c22cb3 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -150,8 +150,6 @@ std::string parameter_properties::to_string(float value) const
     }
     switch(flags & PF_TYPEMASK)
     {
-    case PF_STRING:
-        return "N/A";
     case PF_INT:
     case PF_BOOL:
     case PF_ENUM:
@@ -190,16 +188,14 @@ std::string parameter_properties::to_string(float value) const
 
 void calf_plugins::plugin_ctl_iface::clear_preset() {
     int param_count = get_metadata_iface()->get_param_count();
-    for (int i=0; i < param_count; i++)
+    for (int i = 0; i < param_count; i++)
     {
         const parameter_properties &pp = *get_metadata_iface()->get_param_props(i);
-        if ((pp.flags & PF_TYPEMASK) == PF_STRING)
-        {
-            configure(pp.short_name, pp.choices ? pp.choices[0] : "");
-        }
-        else
-            set_param_value(i, pp.def_value);
+        set_param_value(i, pp.def_value);
     }
+    const char *const *vars = get_metadata_iface()->get_configure_vars();
+    for (int i = 0; vars[i]; i++)
+        configure(vars[i], NULL);
 }
 
 const char *calf_plugins::load_gui_xml(const std::string &plugin_id)
@@ -213,28 +209,6 @@ const char *calf_plugins::load_gui_xml(const std::string &plugin_id)
     }
 }
 
-bool calf_plugins::check_for_message_context_ports(const parameter_properties *parameters, int count)
-{
-    for (int i = count - 1; i >= 0; i--)
-    {
-        if (parameters[i].flags & PF_PROP_MSGCONTEXT)
-            return true;
-    }
-    return false;
-}
-
-bool calf_plugins::check_for_string_ports(const parameter_properties *parameters, int count)
-{
-    for (int i = count - 1; i >= 0; i--)
-    {
-        if ((parameters[i].flags & PF_TYPEMASK) == PF_STRING)
-            return true;
-        if ((parameters[i].flags & PF_TYPEMASK) < PF_STRING)
-            return false;
-    }
-    return false;
-}
-
 bool calf_plugins::get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context, bool use_frequencies)
 {
     if (subindex < 0 )
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 7f70faa..afeab5c 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -67,8 +67,6 @@ struct plugin_proxy_base
     plugin_ctl_iface *instance;
     /// If true, a given parameter (not port) may be sent to host - it is blocked when the parameter is written to by the host
     vector<bool> sends;
-    /// If true, a given parameter (not port) is a string port
-    vector<bool> is_string_param;
     /// Map of parameter name to parameter index (used for mapping configure values to string ports)
     map<string, int> params_by_name;
     /// Values of parameters (float control ports)
@@ -120,18 +118,12 @@ plugin_proxy_base::plugin_proxy_base(const plugin_metadata_iface *metadata, LV2U
     
     /// Block all updates until GUI is ready
     sends.resize(param_count, false);
-    is_string_param.resize(param_count, false);
     params.resize(param_count);
     for (int i = 0; i < param_count; i++)
     {
         const parameter_properties *pp = metadata->get_param_props(i);
         params_by_name[pp->short_name] = i;
-        unsigned int port_type = pp->flags & PF_TYPEMASK;
-        if (port_type < PF_STRING)
-            params[i] = pp->def_value;
-        else
-        if (port_type == PF_STRING)
-            is_string_param[i] = true;
+        params[i] = pp->def_value;
     }
     for (int i = 0; features[i]; i++)
     {
@@ -193,40 +185,10 @@ const line_graph_iface *plugin_proxy_base::get_line_graph_iface() const
 
 char *plugin_proxy_base::configure(const char *key, const char *value)
 {
-#if USE_PERSIST_EXTENSION
     if (instance)
         return instance->configure(key, value);
     else
-        return "Configuration not available because of lack of instance-access/data-access";
-#else
-    map<string, int>::iterator i = params_by_name.find(key);
-    if (i == params_by_name.end())
-    {
-        g_error("configure called for unknown key %s\n", key);
-        g_assert(FALSE);
-        return NULL;
-    }
-    int idx = i->second;
-    if (!sends[idx])
-        return NULL;
-    LV2_String_Data data;
-    data.data = (char *)value;
-    data.len = strlen(value);
-    data.storage = -1; // host doesn't need that
-    data.flags = 0;
-    data.pad = 0;
-    
-    if (string_port_uri)
-    {
-        write_function(controller, idx + param_offset, sizeof(LV2_String_Data), string_port_uri, &data);
-    }
-    else
-    {
-        g_warning("String port not supported - cannot write configure variable %s", key);
-    }
-    
-    return NULL;
-#endif
+        return strdup("Configuration not available because of lack of instance-access/data-access");
 }
 
 void plugin_proxy_base::enable_all_sends()
@@ -267,11 +229,6 @@ struct lv2_plugin_proxy: public plugin_ctl_iface, public plugin_proxy_base, publ
     virtual void set_param_value(int param_no, float value) {
         if (param_no < 0 || param_no >= param_count)
             return;
-        if (is_string_param[param_no])
-        {
-            g_warning("Attempt to write a float value to a string port %d", param_no + param_offset);;
-            return;
-        }
         send_float_to_host(param_no, value);
     }
     
@@ -347,12 +304,6 @@ void gui_port_event(LV2UI_Handle handle, uint32_t port, uint32_t buffer_size, ui
     int param = port - proxy->plugin_metadata->get_param_port_offset();
     if (param >= proxy->plugin_metadata->get_param_count())
         return;
-    if (proxy->is_string_param[param])
-    {
-        TempSendSetter _a_(proxy->sends[param], false);
-        gui->plugin->configure(proxy->plugin_metadata->get_param_props(param)->short_name, ((LV2_String_Data *)buffer)->data);
-        return;
-    }
     if (fabs(gui->plugin->get_param_value(param) - v) < 0.00001)
         return;
     {
@@ -446,14 +397,6 @@ void ext_plugin_gui::port_event_impl(uint32_t port, uint32_t buffer_size, uint32
     {
         int param = port - param_offset;
         TempSendSetter _a_(sends[param], false);
-        if (is_string_param[param])
-        {
-            osc_inline_typed_strstream data;
-            data << plugin_metadata->get_param_props(param)->short_name;
-            data << ((LV2_String_Data *)buffer)->data;
-            cli.send("/configure", data);
-        }
-        else
         if (format == 0)
         {
             osc_inline_typed_strstream data;
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index 9b755c1..bd43bfb 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -212,10 +212,6 @@ static bool add_ctl_port(string &ports, const parameter_properties &pp, int pidx
     const char *ind = "        ";
 
     parameter_flags type = (parameter_flags)(pp.flags & PF_TYPEMASK);
-#if USE_PERSIST_EXTENSION
-    if (type == PF_STRING)
-        return false;
-#endif
     uint8_t unit = (pp.flags & PF_UNITMASK) >> 24;
     
     if (ports != "") ports += " , ";
@@ -224,10 +220,7 @@ static bool add_ctl_port(string &ports, const parameter_properties &pp, int pidx
         ss << ind << "a lv2:OutputPort ;\n";
     else
         ss << ind << "a lv2:InputPort ;\n";
-    if (type == PF_STRING)
-        ss << ind << "a strport:StringPort ;\n";
-    else
-        ss << ind << "a lv2:ControlPort ;\n";
+    ss << ind << "a lv2:ControlPort ;\n";
     ss << ind << "lv2:index " << pidx << " ;\n";
     ss << ind << "lv2:symbol \"" << pp.short_name << "\" ;\n";
     ss << ind << "lv2:name \"" << pp.name << "\" ;\n";
@@ -245,13 +238,7 @@ static bool add_ctl_port(string &ports, const parameter_properties &pp, int pidx
         ss << ind << "lv2:portProperty epp:notAutomatic ;\n";
     if (pp.flags & PF_PROP_OUTPUT_GAIN)
         ss << ind << "lv2:portProperty epp:outputGain ;\n";
-    if (pp.flags & PF_PROP_MSGCONTEXT)
-        ss << ind << "lv2ctx:context lv2ctx:MessageContext ;\n";
-    if (type == PF_STRING)
-    {
-        ss << ind << "strport:default \"\"\"" << pp.choices[0] << "\"\"\" ;\n";
-    }
-    else if (type == PF_BOOL)
+    if (type == PF_BOOL)
         ss << ind << "lv2:portProperty lv2:toggled ;\n";
     else if (type == PF_ENUM)
     {
@@ -264,17 +251,14 @@ static bool add_ctl_port(string &ports, const parameter_properties &pp, int pidx
     else if ((pp.flags & PF_SCALEMASK) == PF_SCALE_LOG)
         ss << ind << "lv2:portProperty epp:logarithmic ;\n";
     ss << showpoint;
-    if (type != PF_STRING)
-    {
-        if (!(pp.flags & PF_PROP_OUTPUT))
-            ss << ind << "lv2:default " << pp.def_value << " ;\n";
-        ss << ind << "lv2:minimum " << pp.min << " ;\n";
-        ss << ind << "lv2:maximum " << pp.max << " ;\n";
-        if (pp.step > 1)
-            ss << ind << "epp:rangeSteps " << pp.step << " ;\n";
-        if (unit > 0 && unit < (sizeof(units) / sizeof(char *)) && units[unit - 1] != NULL)
-            ss << ind << "ue:unit " << units[unit - 1] << " ;\n";
-    }
+    if (!(pp.flags & PF_PROP_OUTPUT))
+        ss << ind << "lv2:default " << pp.def_value << " ;\n";
+    ss << ind << "lv2:minimum " << pp.min << " ;\n";
+    ss << ind << "lv2:maximum " << pp.max << " ;\n";
+    if (pp.step > 1)
+        ss << ind << "epp:rangeSteps " << pp.step << " ;\n";
+    if (unit > 0 && unit < (sizeof(units) / sizeof(char *)) && units[unit - 1] != NULL)
+        ss << ind << "ue:unit " << units[unit - 1] << " ;\n";
     
     // for now I assume that the only tempo passed is the tempo the plugin should operate with
     // this may change as more complex plugins are added
@@ -416,19 +400,9 @@ void make_ttl(string path_prefix)
             }
         }
         
-        if (pi->requires_message_context())
+        if (pi->get_configure_vars())
         {
-            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())
-        {
-#if USE_PERSIST_EXTENSION
-            ttl += "    lv2:requiredFeature <" LV2_PERSIST_URI "> ;\n";
-#else
-            ttl += "    lv2:requiredFeature <http://lv2plug.in/ns/dev/string-port#StringTransfer> ;\n";
-#endif
+            ttl += "    lv2:optionalFeature <" LV2_PERSIST_URI "> ;\n";
         }
         
         string ports = "";
@@ -597,10 +571,6 @@ void make_gui(string path_prefix)
             {
                 ctl = "    <combo " + attach_x + attach_y + param + expand_x + pad_x + " />\n";
             }
-            else if ((props.flags & PF_TYPEMASK) == PF_STRING)
-            {
-                ctl = "    <entry " + attach_x + attach_y + "key=\"" + props.short_name + "\" " + expand_x + pad_x + " />\n";
-            }
             else if ((props.flags & PF_TYPEMASK) == PF_BOOL && 
                      (props.flags & PF_CTLMASK) == PF_CTL_TOGGLE)
             {
diff --git a/src/metadata.cpp b/src/metadata.cpp
index d655a48..9feccb7 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -950,10 +950,14 @@ CALF_PORT_PROPS(organ) = {
     { 1,        0.1, 10,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "bass_gain", "Bass Gain" },
     { 12000,     20, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "treble_freq", "Treble Freq" },
     { 1,        0.1, 10,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "treble_gain", "Treble Gain" },
-
-    { 0,          0,    0,    0, PF_STRING | PF_PROP_MSGCONTEXT, &organ_init_map_curve, "map_curve", "Key mapping curve" },
 };
 
+const char *const *organ_metadata::get_configure_vars() const
+{
+    static const char *names[] = {"map_curve", NULL};
+    return names;
+}
+
 ////////////////////////////////////////////////////////////////////////////
 
 const char *fluidsynth_init_soundfont = "";
@@ -972,10 +976,14 @@ CALF_PORT_PROPS(fluidsynth) = {
     { 2,          0,    3,    0, PF_ENUM | PF_CTL_COMBO, fluidsynth_interpolation_names, "interpolation", "Interpolation" },
     { 1,          0,    1,    0, PF_BOOL | PF_CTL_TOGGLE, NULL, "reverb", "Reverb" },
     { 1,          0,    1,    0, PF_BOOL | PF_CTL_TOGGLE, NULL, "chorus", "Chorus" },
-    { 0,          0,    0,    0, PF_STRING | PF_PROP_MSGCONTEXT, &fluidsynth_init_soundfont, "soundfont", "Soundfont" },
-    { 0,          0,    0,    0, PF_STRING | PF_PROP_MSGCONTEXT, &fluidsynth_init_presetkeyset, "preset_key_set", "Set Preset" },
 };
 
+const char *const *fluidsynth_metadata::get_configure_vars() const
+{
+    static const char *names[] = {"soundfont", "preset_key_set", NULL};
+    return names;
+}
+
 ////////////////////////////////////////////////////////////////////////////
 
 const char *wavetable_names[] = { 
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 6588f67..cd466c4 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -58,7 +58,7 @@ ladspa_instance::ladspa_instance(audio_module_iface *_module, ladspa_plugin_meta
 float ladspa_instance::get_param_value(int param_no)
 {
     // XXXKF hack
-    if (param_no >= ladspa->real_param_count)
+    if (param_no >= ladspa->param_count)
         return 0;
     return *params[param_no];
 }
@@ -66,7 +66,7 @@ float ladspa_instance::get_param_value(int param_no)
 void ladspa_instance::set_param_value(int param_no, float value)
 {
     // XXXKF hack
-    if (param_no >= ladspa->real_param_count)
+    if (param_no >= ladspa->param_count)
         return;
     *params[param_no] = value;
 }
@@ -231,7 +231,7 @@ static void cb_connect(LADSPA_Handle Instance, unsigned long port, LADSPA_Data *
     
     int first_out = mod->ladspa->input_count;
     int first_param = first_out + mod->ladspa->output_count;
-    int ladspa_port_count = first_param + mod->ladspa->real_param_count;
+    int ladspa_port_count = first_param + mod->ladspa->param_count;
     
     if ((int)port < first_out)
         mod->ins[port] = DataLocation;
@@ -292,7 +292,7 @@ static void cb_select_program(LADSPA_Handle Instance, unsigned long Bank, unsign
     unsigned int no = (Bank << 7) + Program - 1;
     // printf("no = %d presets = %p:%d\n", no, presets, presets->size());
     if (no == -1U) {
-        int rpc = ladspa->real_param_count;
+        int rpc = ladspa->param_count;
         for (int i =0 ; i < rpc; i++)
             *mod->params[i] = mod->metadata->get_param_props(i)->def_value;
         return;
@@ -328,9 +328,6 @@ void ladspa_plugin_metadata_set::prepare(const plugin_metadata_iface *md, LADSPA
     input_count = md->get_input_count();
     output_count = md->get_output_count();
     param_count = md->get_param_count(); // XXXKF ladspa_instance<Module>::real_param_count();
-    real_param_count = 0;
-    while(real_param_count < md->get_param_count() && (metadata->get_param_props(real_param_count)->flags & PF_TYPEMASK) < PF_STRING)
-        real_param_count++;
     
     const ladspa_plugin_info &plugin_info = md->get_plugin_info();
     descriptor.UniqueID = plugin_info.unique_id;
@@ -339,7 +336,7 @@ void ladspa_plugin_metadata_set::prepare(const plugin_metadata_iface *md, LADSPA
     descriptor.Maker = plugin_info.maker;
     descriptor.Copyright = plugin_info.copyright;
     descriptor.Properties = md->is_rt_capable() ? LADSPA_PROPERTY_HARD_RT_CAPABLE : 0;
-    descriptor.PortCount = input_count + output_count + real_param_count;
+    descriptor.PortCount = input_count + output_count + param_count;
     descriptor.PortNames = new char *[descriptor.PortCount];
     descriptor.PortDescriptors = new LADSPA_PortDescriptor[descriptor.PortCount];
     descriptor.PortRangeHints = new LADSPA_PortRangeHint[descriptor.PortCount];
@@ -352,7 +349,7 @@ void ladspa_plugin_metadata_set::prepare(const plugin_metadata_iface *md, LADSPA
         prh.HintDescriptor = 0;
         ((const char **)descriptor.PortNames)[i] = md->get_port_names()[i];
     }
-    for (; i < input_count + output_count + real_param_count; i++)
+    for (; i < input_count + output_count + param_count; i++)
     {
         LADSPA_PortRangeHint &prh = ((LADSPA_PortRangeHint *)descriptor.PortRangeHints)[i];
         const parameter_properties &pp = *md->get_param_props(i - input_count - output_count);
@@ -484,10 +481,7 @@ ladspa_plugin_metadata_set::~ladspa_plugin_metadata_set()
 // 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;
-#if USE_PERSIST_EXTENSION
 template<class Module> LV2_Persist calf_plugins::lv2_wrapper<Module>::persist;
-#endif
 
 extern "C" {
 
diff --git a/src/preset.cpp b/src/preset.cpp
index e1798c0..23df7ef 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -107,8 +107,6 @@ void plugin_preset::get_from(plugin_ctl_iface *plugin)
     const plugin_metadata_iface *metadata = plugin->get_metadata_iface();
     int count = metadata->get_param_count();
     for (int i = 0; i < count; i++) {
-        if ((metadata->get_param_props(i)->flags & PF_TYPEMASK) >= PF_STRING)
-            continue;
         param_names.push_back(metadata->get_param_props(i)->short_name);
         values.push_back(plugin->get_param_value(i));
     }

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list