[SCM] calf/master: + Framework: prepare for adding string ports (hide extra ports in LADSPA/DSSI, generate RDF for string ports); variable-related fixed in GUI

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


The following commit has been merged in the master branch:
commit 67a4d65070a09b8bb9164839a4e0ebbfb2341cee
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Fri Nov 21 23:53:15 2008 +0000

    + Framework: prepare for adding string ports (hide extra ports in LADSPA/DSSI, generate RDF for string ports); variable-related fixed in GUI

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 39e4d6b..8f0883a 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -244,9 +244,6 @@ struct plugin_metadata_iface
     virtual const char **get_port_names() = 0;
     /// @return description structure for the plugin
     virtual const ladspa_plugin_info &get_plugin_info() = 0;
-    /// Get all configure vars that are supposed to be set to initialize a preset
-    /// @return key, value, key, value, ..., NULL
-    virtual const char **get_default_configure_vars() = 0;
     /// is a given parameter a control voltage?
     virtual bool is_cv(int param_no) = 0;
     /// is the given parameter non-interpolated?
@@ -352,7 +349,6 @@ public:
     plugin_command_info *get_commands() { return NULL; }
     parameter_properties *get_param_props(int param_no) { return &param_props[param_no]; }
     const char **get_port_names() { return port_names; }
-    const char **get_default_configure_vars() { return NULL; }
     bool is_cv(int param_no) { return true; }
     bool is_noisy(int param_no) { return false; }
     virtual const ladspa_plugin_info &get_plugin_info() { return plugin_info; }
@@ -383,7 +379,6 @@ public:
     plugin_command_info *get_commands() { return impl->get_commands(); }
     parameter_properties *get_param_props(int param_no) { return impl->get_param_props(param_no); }
     const char **get_port_names() { return impl->get_port_names(); }
-    const char **get_default_configure_vars() { return impl->get_default_configure_vars(); }
     bool is_cv(int param_no) { return impl->is_cv(param_no); }
     bool is_noisy(int param_no) { return impl->is_noisy(param_no); }
     virtual const ladspa_plugin_info &get_plugin_info() { return impl->get_plugin_info(); }
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 1b08d55..27955ba 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -194,9 +194,9 @@ public:
     jack_host()
     {
         for (int i = 0; i < Module::param_count; i++) {
-            param_values[i] = Module::param_props[i].def_value;
             Module::params[i] = &param_values[i];
         }
+        clear_preset();
         midi_meter = 0;
     }
     
diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index 603a198..ee7d3a6 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -31,18 +31,35 @@
 
 namespace calf_plugins {
 
+template<class Module>
+inline int calc_real_param_count()
+{
+    for (int i=0; i < Module::param_count; i++)
+    {
+        if ((Module::param_props[i].flags & PF_TYPEMASK) >= PF_STRING)
+            return i;
+    }
+    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;
+    static int real_param_count()
+    {
+        static int _real_param_count = calc_real_param_count<Module>();
+        return _real_param_count;
+    }
     ladspa_instance()
     {
         for (int i=0; i < Module::in_count; i++)
             Module::ins[i] = NULL;
         for (int i=0; i < Module::out_count; i++)
             Module::outs[i] = NULL;
-        for (int i=0; i < Module::param_count; i++)
+        int rpc = real_param_count();
+        for (int i=0; i < rpc; i++)
             Module::params[i] = NULL;
         activate_flag = true;
     }
@@ -60,7 +77,7 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     }
     virtual int get_param_count()
     {
-        return Module::param_count;
+        return real_param_count();
     }
     virtual int get_param_port_offset() 
     {
@@ -110,16 +127,6 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     virtual void send_configures(send_configure_iface *sci) { 
         Module::send_configures(sci);
     }
-    virtual void clear_preset() {
-        for (int i=0; i < Module::param_count; i++)
-            *Module::params[i] = Module::param_props[i].def_value;
-        const char **p = Module::get_default_configure_vars();
-        if (p)
-        {
-            for(; p[0]; p += 2)
-                configure(p[0], p[1]);
-        }
-    }
 };
 
 /// A wrapper class for plugin class object (there is only one ladspa_wrapper for many instances of the same plugin)
@@ -141,7 +148,7 @@ struct ladspa_wrapper
     {
         int ins = Module::in_count;
         int outs = Module::out_count;
-        int params = Module::param_count;
+        int params = ladspa_instance<Module>::real_param_count();
         ladspa_plugin_info &plugin_info = Module::plugin_info;
         descriptor.UniqueID = plugin_info.unique_id;
         descriptor.Label = plugin_info.label;
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index d8f4335..5d6e763 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -126,6 +126,7 @@ struct organ_enums
         par_eg3attack, par_eg3decay, par_eg3sustain, par_eg3release, par_eg3velscl, par_eg3ampctl, 
         par_lforate, par_lfoamt, par_lfowet, par_lfophase, par_lfomode,
         par_transpose, par_detune,
+        par_var_mapcurve,
         param_count
     };
     enum organ_waveform { 
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 998730d..c397597 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -83,6 +83,8 @@ struct organ_parameters {
     float global_transpose;
     float global_detune;
     
+    float dummy_mapcurve;
+    
     //////////////////////////////////////////////////////////////////////////
     // these parameters are calculated
     
diff --git a/src/giface.cpp b/src/giface.cpp
index 8079f3e..c966ee3 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -149,6 +149,8 @@ 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:
@@ -188,13 +190,14 @@ std::string parameter_properties::to_string(float value) const
 void calf_plugins::plugin_ctl_iface::clear_preset() {
     int param_count = get_param_count();
     for (int i=0; i < param_count; i++)
-        set_param_value(i, get_param_props(i)->def_value);
-    // This is never called in practice, at least for now
-    const char **p = get_default_configure_vars();
-    if (p)
     {
-        for(; p[0]; p += 2)
-            configure(p[0], p[1]);
+        parameter_properties &pp = *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);
     }
 }
 
diff --git a/src/gui.cpp b/src/gui.cpp
index 39a8c24..0c377a9 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -52,8 +52,10 @@ void param_control::update_label()
 
 void param_control::hook_params()
 {
-    if (param_no != -1)
+    if (param_no != -1) {
         gui->add_param_ctl(param_no, this);
+    }
+    gui->params.push_back(this);
 }
 
 param_control::~param_control()
@@ -407,7 +409,7 @@ struct curve_param_control_callback: public CalfCurve::EventAdapter
         ss << data.size() << endl;
         for (size_t i = 0; i < data.size(); i++)
             ss << data[i].first << " " << data[i].second << endl;
-        ctl->gui->send_configure(ctl->attribs["key"].c_str(), ss.str().c_str());
+        ctl->gui->plugin->configure(ctl->attribs["key"].c_str(), ss.str().c_str());
     }
     virtual void clip(CalfCurve *src, int pt, float &x, float &y, bool &hide)
     {
@@ -771,7 +773,6 @@ void plugin_gui::xml_element_start(const char *element, const char *attributes[]
             current_control->init_xml(element);
             current_control->set();
             current_control->hook_params();
-            params.push_back(current_control);
             return;
         }
     }
@@ -833,22 +834,26 @@ GtkWidget *plugin_gui::create_from_xml(plugin_ctl_iface *_plugin, const char *xm
 
 void plugin_gui::send_configure(const char *key, const char *value)
 {
-    plugin->configure(key, value);
+    // XXXKF this should really be replaced by a separate list of SCI-capable param controls
+    for (unsigned int i = 0; i < params.size(); i++)
+    {
+        assert(params[i] != NULL);
+        send_configure_iface *sci = dynamic_cast<send_configure_iface *>(params[i]);
+        if (sci)
+            sci->send_configure(key, value);
+    }
 }
 
 void plugin_gui::on_idle()
 {
     for (unsigned int i = 0; i < params.size(); i++)
     {
-        if (params[i] != NULL)
-        {
-            parameter_properties &props = *plugin->get_param_props(params[i]->param_no);
-            bool is_output = (props.flags & PF_PROP_OUTPUT) != 0;
-            if (is_output) {
-                params[i]->set();
-            }
-            params[i]->on_idle();
+        parameter_properties &props = *plugin->get_param_props(params[i]->param_no);
+        bool is_output = (props.flags & PF_PROP_OUTPUT) != 0;
+        if (is_output) {
+            params[i]->set();
         }
+        params[i]->on_idle();
     }    
     // XXXKF iterate over par2ctl, too...
 }
@@ -857,13 +862,10 @@ void plugin_gui::refresh()
 {
     for (unsigned int i = 0; i < params.size(); i++)
     {
-        if (params[i] != NULL)
-            params[i]->set();
+        params[i]->set();
         send_configure_iface *sci = dynamic_cast<send_configure_iface *>(params[i]);
         if (sci)
-        {
             plugin->send_configures(sci);
-        }
     }
 }
 
@@ -1107,6 +1109,7 @@ void plugin_gui_window::create(plugin_ctl_iface *_jh, const char *title, const c
 
     source_id = g_timeout_add_full(G_PRIORITY_LOW, 1000/30, on_idle, this, NULL); // 30 fps should be enough for everybody
     gtk_ui_manager_ensure_update(ui_mgr);
+    gui->plugin->send_configures(gui);
 }
 
 void plugin_gui_window::close()
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index 030dc6b..754af73 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -202,6 +202,8 @@ static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, plug
     stringstream ss;
     const char *ind = "        ";
 
+    parameter_flags type = (parameter_flags)(pp.flags & PF_TYPEMASK);
+    uint8_t unit = (pp.flags & PF_UNITMASK) >> 24;
     
     if (ports != "") ports += " , ";
     ss << "[\n";
@@ -209,7 +211,10 @@ static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, plug
         ss << ind << "a lv2:OutputPort ;\n";
     else
         ss << ind << "a lv2:InputPort ;\n";
-    ss << ind << "a lv2:ControlPort ;\n";
+    if (type == PF_STRING)
+        ss << ind << "a strport:StringPort ;\n";
+    else
+        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";
@@ -227,27 +232,33 @@ static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, plug
         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_TYPEMASK) == PF_BOOL)
+    if (type == PF_STRING)
+    {
+        ss << ind << "strport:default \"\"\"" << pp.choices[0] << "\"\"\" ;\n";
+    }
+    else if (type == PF_BOOL)
         ss << ind << "lv2:portProperty lv2:toggled ;\n";
-    else if ((pp.flags & PF_TYPEMASK) == PF_ENUM)
+    else if (type == PF_ENUM)
     {
         ss << ind << "lv2:portProperty lv2:integer ;\n";
         for (int i = (int)pp.min; i <= (int)pp.max; i++)
             ss << ind << "lv2:scalePoint [ rdfs:label \"" << pp.choices[i - (int)pp.min] << "\"; rdf:value " << i <<" ] ;\n";
     }
-    else if ((pp.flags & PF_TYPEMASK) > 0)
+    else if (type == PF_INT || type == PF_ENUM_MULTI)
         ss << ind << "lv2:portProperty lv2:integer ;\n";
     else if ((pp.flags & PF_SCALEMASK) == PF_SCALE_LOG)
         ss << ind << "lv2:portProperty epp:logarithmic ;\n";
     ss << showpoint;
-    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";
-    uint8_t unit = (pp.flags & PF_UNITMASK) >> 24;
-    if (unit > 0 && unit < (sizeof(units) / sizeof(char *)) && units[unit - 1] != NULL)
-        ss << ind << "ue:unit " << units[unit - 1] << " ;\n";
+    if (type != PF_STRING)
+    {
+        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
@@ -452,6 +463,7 @@ void make_ttl(string path_prefix)
         "@prefix lv2ev: <http://lv2plug.in/ns/ext/event#> .\n"
         "@prefix lv2midi: <http://lv2plug.in/ns/ext/midi#> .\n"
         "@prefix lv2ctx: <http://lv2plug.in/ns/dev/contexts#> .\n"
+        "@prefix strport: <http://lv2plug.in/ns/dev/string-port#> .\n"
         "@prefix pg: <http://ll-plugins.nongnu.org/lv2/ext/portgroups#> .\n"
         "@prefix ue: <http://lv2plug.in/ns/extensions/units#> .\n"
         "@prefix epp: <http://lv2plug.in/ns/dev/extportinfo#> .\n"
diff --git a/src/modules.cpp b/src/modules.cpp
index 4a419be..c2d3c11 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -289,6 +289,8 @@ const char *organ_ampctl_names[] = { "None", "Direct", "Flt 1", "Flt 2", "All"
 
 const char *organ_vibrato_mode_names[] = { "None", "Direct", "Flt 1", "Flt 2", "Voice", "Global"  };
 
+const char *organ_init_map_curve = "2\n0 1\n1 1\n";
+
 CALF_PORT_PROPS(organ) = {
     { 8,       0,  8, 80, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "l1", "16'" },
     { 8,       0,  8, 80, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_FADER, NULL, "l2", "5 1/3'" },
@@ -428,6 +430,8 @@ CALF_PORT_PROPS(organ) = {
 
     { -12,        -24, 24,   49, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "transpose", "Transpose" },
     { 0,       -100,  100,  201, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "detune", "Detune" },
+    
+    { 0,          0,    0,    0, PF_STRING, &organ_init_map_curve, "map_curve", "Key mapping curve" },
 };
 
 ////////////////////////////////////////////////////////////////////////////

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list