[SCM] calf/master: + Framework: store configure variables in presets (not implemented for LV2, not tested for DSSI) + Framework: allow transfer of configured values to controls (curve only for now) + Framework: use plain EventAdapter for keyboard + Curve: don't flick a pencil if a mouse button is released at maximum point limit + Organ: storage and retrieval of configured map_curve

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:27 UTC 2013


The following commit has been merged in the master branch:
commit a27418a18f66c377f98d7ae3b69c46aae673fc9d
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sat Aug 2 17:24:17 2008 +0000

    + Framework: store configure variables in presets (not implemented for LV2, not tested for DSSI)
    + Framework: allow transfer of configured values to controls (curve only for now)
    + Framework: use plain EventAdapter for keyboard
    + Curve: don't flick a pencil if a mouse button is released at maximum point limit
    + Organ: storage and retrieval of configured map_curve
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@250 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/giface.h b/src/calf/giface.h
index a6c22ae..04f4546 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -195,7 +195,7 @@ struct plugin_ctl_iface
     /// Set a configure variable on a plugin
     virtual char *configure(const char *key, const char *value) { return NULL; }
     /// Send all configure variables set within a plugin to given destination (which may be limited to only those that plugin understands)
-    virtual void send_configures(send_configure_iface *) {}
+    virtual void send_configures(send_configure_iface *)=0;
     /// Do-nothing destructor to silence compiler warning
     virtual ~plugin_ctl_iface() {}
 };
@@ -308,6 +308,9 @@ struct ladspa_instance: public Module, public plugin_ctl_iface
     virtual void execute(int cmd_no) {
         Module::execute(cmd_no);
     }
+    void send_configures(send_configure_iface *sci) { 
+        Module::send_configures(sci);
+    }
 };
 
 template<class Module>
diff --git a/src/calf/gui.h b/src/calf/gui.h
index faedde2..80c03e5 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -227,13 +227,14 @@ struct keyboard_param_control: public param_control
     virtual void set() {}
 };
 
-struct curve_param_control: public param_control
+struct curve_param_control: public param_control, public send_configure_iface
 {
     CalfCurve *curve;
     
     virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
     virtual void get() {}
     virtual void set() {}
+    virtual void send_configure(const char *key, const char *value);
 };
 
 class plugin_gui_window;
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 922171e..4cabc72 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -417,6 +417,9 @@ public:
     virtual char *configure(const char *key, const char *value) { 
         return module.configure(key, value);
     }
+    virtual void send_configures(send_configure_iface *sci) {
+        module.send_configures(sci);
+    }
 };
 
 extern jack_host_base *create_jack_host(const char *name);
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index be16461..b54dacc 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -83,6 +83,9 @@ struct lv2_instance: public Module, public plugin_ctl_iface
     virtual void execute(int cmd_no) {
         Module::execute(cmd_no);
     }
+    void send_configures(send_configure_iface *sci) { 
+        Module::send_configures(sci);
+    }
 };
 
 template<class Module>
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 044ec3f..3be2c47 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -56,6 +56,7 @@ public:
     static bool is_noisy(int param_no) { return false; }
     inline void execute(int cmd_no) {}
     inline char *configure(const char *key, const char *value) { return NULL; }
+    inline void send_configures(send_configure_iface *sci) {}
 };
 
 class amp_audio_module: public null_audio_module
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index 7c04af8..1a82670 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -226,6 +226,8 @@ public:
     organ_parameters par_values;
     uint32_t srate;
     bool panic_flag;
+    /// Value for configure variable map_curve
+    std::string var_map_curve;
 
     organ_audio_module()
     : drawbar_organ(&par_values)
@@ -274,6 +276,7 @@ public:
     static const char *get_label() { return "Organ"; }    
     static plugin_command_info *get_commands();
     virtual char *configure(const char *key, const char *value);
+    virtual void send_configures(send_configure_iface *);
 };
 
 };
diff --git a/src/calf/preset.h b/src/calf/preset.h
index 8855cfd..5a5ae3e 100644
--- a/src/calf/preset.h
+++ b/src/calf/preset.h
@@ -40,7 +40,7 @@ struct plugin_preset
     std::string plugin;
     std::vector<std::string> param_names;
     std::vector<float> values;
-    std::string blob;
+    std::map<std::string, std::string> variables;
 
     plugin_preset() : bank(0), program(0) {}
     std::string to_xml();    
@@ -78,11 +78,13 @@ struct preset_list
         LIST,
         PRESET,
         VALUE,
+        VAR,
     } state;
 
     preset_vector presets;
     plugin_preset parser_preset;
     std::map<std::string, int> last_preset_ids;
+    std::string current_key;
 
     static std::string get_preset_filename();
     bool load_defaults(bool builtin);
@@ -95,6 +97,7 @@ struct preset_list
 protected:
     static void xml_start_element_handler(void *user_data, const char *name, const char *attrs[]);
     static void xml_end_element_handler(void *user_data, const char *name);
+    static void xml_character_data_handler(void *user_data, const char *data, int len);
 };
 
 extern preset_list &get_builtin_presets();
diff --git a/src/ctl_curve.cpp b/src/ctl_curve.cpp
index 6a4ebdc..99f36c1 100644
--- a/src/ctl_curve.cpp
+++ b/src/ctl_curve.cpp
@@ -194,7 +194,7 @@ calf_curve_button_release (GtkWidget *widget, GdkEventButton *event)
     if (self->sink)
         self->sink->curve_changed(self, *self->points);
     gtk_widget_queue_draw(widget);
-    gdk_window_set_cursor(widget->window, self->pencil_cursor);
+    gdk_window_set_cursor(widget->window, self->points->size() >= self->point_limit ? self->arrow_cursor : self->pencil_cursor);
     return FALSE;
 }
 
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index 7d8bb46..17a42af 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -75,6 +75,7 @@ struct plugin_proxy_base: public plugin_ctl_iface
     osc_client *client;
     bool send_osc;
     plugin_gui *gui;
+    map<string, string> cfg_vars;
     
     plugin_proxy_base()
     {
@@ -169,6 +170,10 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
             client->send("/configure", str);
         }
     }
+    void send_configures(send_configure_iface *sci) { 
+        for (map<string, string>::iterator i = cfg_vars.begin(); i != cfg_vars.end(); i++)
+            sci->send_configure(i->first.c_str(), i->second.c_str());
+    }
 };
 
 plugin_proxy_base *create_plugin_proxy(const char *effect_name)
@@ -274,6 +279,15 @@ struct dssi_osc_server: public osc_server, public osc_message_sink<osc_strstream
             g_main_loop_quit(mainloop);
             return;
         }
+        if (address == prefix + "/configure"&& args == "ss")
+        {
+            string key, value;
+            buffer >> key >> value;
+            plugin->cfg_vars[key] = value;
+            // XXXKF perhaps this should be queued !
+            window->gui->refresh();
+            return;
+        }
         if (address == prefix + "/program"&& args == "ii")
         {
             uint32_t bank, program;
diff --git a/src/gui.cpp b/src/gui.cpp
index 5f5dfe1..4d60717 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -348,7 +348,7 @@ GtkWidget *keyboard_param_control::create(plugin_gui *_gui, int _param_no)
     widget = calf_keyboard_new();
     kb = CALF_KEYBOARD(widget);
     kb->nkeys = get_int("octaves", 4) * 7 + 1;
-    kb->sink = new CalfKeyboard::EventTester;
+    kb->sink = new CalfKeyboard::EventAdapter;
     return widget;
 }
 
@@ -389,6 +389,29 @@ GtkWidget *curve_param_control::create(plugin_gui *_gui, int _param_no)
     return widget;
 }
 
+void curve_param_control::send_configure(const char *key, const char *value)
+{
+    cout << "send conf " << key << endl;
+    if (attribs["key"] == key)
+    {
+        stringstream ss(value);
+        CalfCurve::point_vector pts;
+        if (*value)
+        {
+            unsigned int npoints = 0;
+            ss >> npoints;
+            unsigned int i;
+            float x = 0, y = 0;
+            for (i = 0; i < npoints && i < curve->point_limit; i++)
+            {
+                ss >> x >> y;
+                pts.push_back(CalfCurve::point(x, y));
+            }
+            calf_curve_set_points(widget, pts);
+        }
+    }
+}
+
 // line graph
 
 void line_graph_param_control::on_idle()
@@ -856,6 +879,11 @@ void plugin_gui::refresh()
     {
         if (params[i] != NULL)
             params[i]->set();
+        send_configure_iface *sci = dynamic_cast<send_configure_iface *>(params[i]);
+        if (sci)
+        {
+            plugin->send_configures(sci);
+        }
     }
 }
 
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index c40b261..e7eb853 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -130,6 +130,9 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
     virtual plugin_command_info *get_commands() {
         return Module::get_commands();
     }
+    void send_configures(send_configure_iface *sci) { 
+        fprintf(stderr, "TODO: send_configures (non-control port configuration dump) not implemented in LV2 GUIs\n");
+    }
 };
 
 plugin_proxy_base *create_plugin_proxy(const char *effect_name)
diff --git a/src/organ.cpp b/src/organ.cpp
index 0addd57..62cdc68 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -1230,20 +1230,24 @@ char *organ_audio_module::configure(const char *key, const char *value)
 {
     if (!strcmp(key, "map_curve"))
     {
+        var_map_curve = value;
         stringstream ss(value);
-        int points;
-        ss >> points;
-        int i;
-        float x = 0, y = 0;
-        for (i = 0; i < points; i++)
+        int i = 0;
+        float x = 0, y = 1;
+        if (*value)
         {
-            static const int whites[] = { 0, 2, 4, 5, 7, 9, 11 };
-            ss >> x >> y;
-            int wkey = (int)(x * 71);
-            x = whites[wkey % 7] + 12 * (wkey / 7);
-            parameters->percussion_keytrack[i][0] = x;
-            parameters->percussion_keytrack[i][1] = y;
-            // cout << "(" << x << ", " << y << ")" << endl;
+            int points;
+            ss >> points;
+            for (i = 0; i < points; i++)
+            {
+                static const int whites[] = { 0, 2, 4, 5, 7, 9, 11 };
+                ss >> x >> y;
+                int wkey = (int)(x * 71);
+                x = whites[wkey % 7] + 12 * (wkey / 7);
+                parameters->percussion_keytrack[i][0] = x;
+                parameters->percussion_keytrack[i][1] = y;
+                // cout << "(" << x << ", " << y << ")" << endl;
+            }
         }
         // pad with constant Y
         for (; i < ORGAN_KEYTRACK_POINTS; i++) {
@@ -1255,6 +1259,11 @@ char *organ_audio_module::configure(const char *key, const char *value)
     cout << "Set configure value " << key << " to " << value;
     return NULL;
 }
+
+void organ_audio_module::send_configures(send_configure_iface *sci)
+{
+    sci->send_configure("map_curve", var_map_curve.c_str());
+}
     
 plugin_command_info *organ_audio_module::get_commands()
 {
diff --git a/src/preset.cpp b/src/preset.cpp
index fd7b674..7acdb09 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -55,7 +55,10 @@ std::string plugin_preset::to_xml()
         else
             ss << "  <param value=\"" << values[i] << "\" />\n";
     }
-    // XXXKF I'm not writing blob here, because I don't use blobs yet anyway
+    for (map<string, string>::iterator i = variables.begin(); i != variables.end(); i++)
+    {
+        ss << "  <var name=\"" << xml_escape(i->first) << "\">" << xml_escape(i->second) << "</var>\n";
+    }
     ss << "</preset>\n";
     return ss.str();
 }
@@ -80,6 +83,11 @@ void plugin_preset::activate(plugin_ctl_iface *plugin)
         }
         plugin->set_param_value(pos->second, values[i]);
     }
+    for (map<string, string>::iterator i = variables.begin(); i != variables.end(); i++)
+    {
+        printf("configure %s: %s\n", i->first.c_str(), i->second.c_str());
+        plugin->configure(i->first.c_str(), i->second.c_str());
+    }
 }
 
 void plugin_preset::get_from(plugin_ctl_iface *plugin)
@@ -89,6 +97,17 @@ void plugin_preset::get_from(plugin_ctl_iface *plugin)
         param_names.push_back(plugin->get_param_props(i)->short_name);
         values.push_back(plugin->get_param_value(i));
     }
+    struct store_obj: public send_configure_iface
+    {
+        map<string, string> *data;
+        void send_configure(const char *key, const char *value)
+        {
+            (*data)[key] = value;
+        }
+    } tmp;
+    variables.clear();
+    tmp.data = &variables;
+    plugin->send_configures(&tmp);
 }
     
 string synth::preset_list::get_preset_filename()
@@ -116,9 +135,9 @@ void preset_list::xml_start_element_handler(void *user_data, const char *name, c
             parser_preset.bank = parser_preset.program = 0;
             parser_preset.name = "";
             parser_preset.plugin = "";
-            parser_preset.blob = "";
             parser_preset.param_names.clear();
             parser_preset.values.clear();
+            parser_preset.variables.clear();
             for(; *attrs; attrs += 2) {
                 if (!strcmp(attrs[0], "name")) self.parser_preset.name = attrs[1];
                 else
@@ -151,8 +170,23 @@ void preset_list::xml_start_element_handler(void *user_data, const char *name, c
             state = VALUE;
             return;
         }
+        if (!strcmp(name, "var")) {
+            self.current_key = "";
+            for(; *attrs; attrs += 2) {
+                if (!strcmp(attrs[0], "name")) self.current_key = attrs[1];
+            }
+            if (self.current_key.empty())
+                throw preset_exception("No name specified for preset variable", "", 0);
+            self.parser_preset.variables[self.current_key].clear();
+            state = VAR;
+            return;
+        }
         break;
     case VALUE:
+        // no nested elements allowed inside <param>
+        break;
+    case VAR:
+        // no nested elements allowed inside <var>
         break;
     }
     // g_warning("Invalid XML element: %s", name);
@@ -187,10 +221,27 @@ void preset_list::xml_end_element_handler(void *user_data, const char *name)
             return;
         }
         break;
+    case VAR:
+        if (!strcmp(name, "var")) {
+            state = PRESET;
+            return;
+        }
+        break;
     }
     throw preset_exception("Invalid XML element close: %s", name, 0);
 }
 
+void preset_list::xml_character_data_handler(void *user_data, const XML_Char *data, int len)
+{
+    preset_list &self = *(preset_list *)user_data;
+    parser_state &state = self.state;
+    if (state == VAR)
+    {
+        self.parser_preset.variables[self.current_key] += string(data, len);
+        return;
+    }
+}
+
 bool preset_list::load_defaults(bool builtin)
 {
     try {
@@ -224,6 +275,7 @@ void preset_list::parse(const std::string &data)
     XML_Parser parser = XML_ParserCreate("UTF-8");
     XML_SetUserData(parser, this);
     XML_SetElementHandler(parser, xml_start_element_handler, xml_end_element_handler);
+    XML_SetCharacterDataHandler(parser, xml_character_data_handler);
     XML_Status status = XML_Parse(parser, data.c_str(), data.length(), 1);
     if (status == XML_STATUS_ERROR) {
         string err = string("Parse error: ") + XML_ErrorString(XML_GetErrorCode(parser))+ " in ";
@@ -242,6 +294,7 @@ void preset_list::load(const char *filename)
     if (fd < 0) 
         throw preset_exception("Could not load the presets from ", filename, errno);
     XML_SetElementHandler(parser, xml_start_element_handler, xml_end_element_handler);
+    XML_SetCharacterDataHandler(parser, xml_character_data_handler);
     char buf[4096];
     do
     {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list