[SCM] calf/master: + GUI, Fluidsynth: start implementing dynamic combo boxes, use for displaying preset lists in Fluidsynth (no selection yet)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:30 UTC 2013


The following commit has been merged in the master branch:
commit 1df89d2df28b02085f6b09a6272560b28c9c5f71
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Apr 22 21:18:03 2009 +0100

    + GUI, Fluidsynth: start implementing dynamic combo boxes, use for displaying preset lists in Fluidsynth (no selection yet)

diff --git a/gui/gui-fluidsynth.xml b/gui/gui-fluidsynth.xml
index 2f52e9a..670e493 100644
--- a/gui/gui-fluidsynth.xml
+++ b/gui/gui-fluidsynth.xml
@@ -6,7 +6,7 @@
     <align attach-x="0" attach-y="1"   align-x="1"><label param="soundfont"  /></align>
     <filechooser attach-x="1" attach-w="2" attach-y="1" key="soundfont" title="Select a soundfont" width_chars="30"/>
     <align attach-x="0" attach-y="2"   align-x="1"><label text="SF Name" /></align>
-    <value attach-x="1" attach-w="2" attach-y="2" key="preset_name" width="30"/>
+    <combo attach-x="1" attach-w="2" attach-y="2" key="preset_list" width="30"/>
     
     <align attach-x="0" attach-y="3"   align-x="1"><label param="interpolation" /></align>
     <align attach-x="1" attach-y="3" attach-w="2" ><combo param="interpolation" /></align>
diff --git a/src/calf/gui.h b/src/calf/gui.h
index e6c5ed8..b3c4811 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -220,11 +220,14 @@ struct button_param_control: public param_control
 };
 
 /// Combo list box
-struct combo_box_param_control: public param_control
+struct combo_box_param_control: public param_control, public send_updates_iface
 {
+    GtkListStore *lstore;
+    
     virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
     virtual void get();
     virtual void set();
+    virtual void send_status(const char *key, const char *value);
     static void combo_value_changed(GtkComboBox *widget, gpointer value);
 };
 
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index 530b8d4..8f3134e 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -59,6 +59,8 @@ protected:
     std::map<uint32_t, std::string> sf_preset_names;
     /// Last selected preset+128*bank
     uint32_t last_selected_preset;
+    /// Serial number of status data
+    int status_serial;
 
     /// Update last_selected_preset based on synth object state
     void update_preset_num();
diff --git a/src/fluidsynth.cpp b/src/fluidsynth.cpp
index 45eace3..26cb7da 100644
--- a/src/fluidsynth.cpp
+++ b/src/fluidsynth.cpp
@@ -39,6 +39,7 @@ fluidsynth_audio_module::fluidsynth_audio_module()
 {
     settings = NULL;
     synth = NULL;
+    status_serial = 1;
 }
 
 void fluidsynth_audio_module::post_instantiate()
@@ -129,6 +130,7 @@ void fluidsynth_audio_module::update_preset_num()
         last_selected_preset = p->get_num(p) + 128 * p->get_banknum(p);
     else
         last_selected_preset = 0;
+    status_serial++;
 }
 
 uint32_t fluidsynth_audio_module::process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
@@ -146,7 +148,10 @@ char *fluidsynth_audio_module::configure(const char *key, const char *value)
 {
     if (!strcmp(key, "soundfont"))
     {
-        printf("Loading %s\n", value);
+        if (*value)
+            printf("Loading %s\n", value);
+        else
+            printf("Creating a blank synth\n");
         soundfont = value;
         int newsfid = -1;
         fluid_synth_t *new_synth = create_synth(newsfid);
@@ -171,15 +176,18 @@ void fluidsynth_audio_module::send_configures(send_configure_iface *sci)
 
 int fluidsynth_audio_module::send_status_updates(send_updates_iface *sui, int last_serial)
 {
-    sui->send_status("sf_name", soundfont_name.c_str());
-    sui->send_status("preset_list", soundfont_preset_list.c_str());
+    if (status_serial != last_serial)
+    {
+        sui->send_status("sf_name", soundfont_name.c_str());
+        sui->send_status("preset_list", soundfont_preset_list.c_str());
 
-    map<uint32_t, string>::const_iterator i = sf_preset_names.find(last_selected_preset);
-    if (i == sf_preset_names.end())
-        sui->send_status("preset_name", "");
-    else
-        sui->send_status("preset_name", i->second.c_str());
-    return last_serial + 1;
+        map<uint32_t, string>::const_iterator i = sf_preset_names.find(last_selected_preset);
+        if (i == sf_preset_names.end())
+            sui->send_status("preset_name", "");
+        else
+            sui->send_status("preset_name", i->second.c_str());
+    }
+    return status_serial;
 }
 
 fluidsynth_audio_module::~fluidsynth_audio_module()
diff --git a/src/gui.cpp b/src/gui.cpp
index 45ba95e..126d28d 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -72,11 +72,16 @@ GtkWidget *combo_box_param_control::create(plugin_gui *_gui, int _param_no)
 {
     gui = _gui;
     param_no = _param_no;
+    lstore = gtk_list_store_new(1, G_TYPE_STRING);
     
     parameter_properties &props = get_props();
     widget  = gtk_combo_box_new_text ();
-    for (int j = (int)props.min; j <= (int)props.max; j++)
-        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), props.choices[j - (int)props.min]);
+    if (props.choices)
+    {
+        for (int j = (int)props.min; j <= (int)props.max; j++)
+            gtk_list_store_insert_with_values (lstore, NULL, j - (int)props.min, 0, props.choices[j - (int)props.min], -1);
+    }
+    gtk_combo_box_set_model (GTK_COMBO_BOX(widget), GTK_TREE_MODEL(lstore));
     gtk_signal_connect (GTK_OBJECT (widget), "changed", G_CALLBACK (combo_value_changed), (gpointer)this);
     
     return widget;
@@ -101,6 +106,25 @@ void combo_box_param_control::combo_value_changed(GtkComboBox *widget, gpointer
     jhp->get();
 }
 
+void combo_box_param_control::send_status(const char *key, const char *value)
+{
+    if (key == attribs["key"])
+    {
+        gtk_list_store_clear (lstore);
+        std::string v = value;
+        int i = 0;
+        size_t pos = 0;
+        while (pos < v.length()) {
+            size_t endpos = v.find("\n", pos);
+            if (endpos == string::npos)
+                break;
+            gtk_list_store_insert_with_values (lstore, NULL, i, 0, v.substr(pos, endpos - pos).c_str(), -1);
+            pos = endpos + 1;
+            i++;
+        }
+    }
+}
+
 // horizontal fader
 
 GtkWidget *hscale_param_control::create(plugin_gui *_gui, int _param_no)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list