[SCM] calf/master: Get Fluidsynth to sort-of run in some LV2 hosts, fix a few wrapper/API bugs in the process. DSSI still not handled.

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


The following commit has been merged in the master branch:
commit 3b70c2d1742a5f36771938400ead7f9801a5f072
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun May 16 20:43:18 2010 +0100

    Get Fluidsynth to sort-of run in some LV2 hosts, fix a few wrapper/API bugs in the process. DSSI still not handled.

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 1340a0d..08954c6 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -356,7 +356,7 @@ struct plugin_ctl_iface
     /// Execute menu command with given number
     virtual void execute(int cmd_no)=0;
     /// Set a configure variable on a plugin
-    virtual char *configure(const char *key, const char *value) { return NULL; }
+    virtual char *configure(const char *key, const char *value) = 0;
     /// 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 *)=0;
     /// Restore all state (parameters and configure vars) to default values - implemented in giface.cpp
@@ -366,7 +366,7 @@ struct plugin_ctl_iface
     virtual bool blobcall(const char *command, const std::string &request, std::string &result) { result = "Call not supported"; return false; }
     /// Update status variables changed since last_serial
     /// @return new last_serial
-    virtual int send_status_updates(send_updates_iface *sui, int last_serial) { return last_serial; }
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial) = 0;
     /// Return metadata object
     virtual const plugin_metadata_iface *get_metadata_iface() const = 0;
     /// @return line_graph_iface if any
diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index 069a6ca..68009b8 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -59,6 +59,7 @@ struct ladspa_instance: public plugin_ctl_iface
     virtual void send_configures(send_configure_iface *sci) { 
         module->send_configures(sci);
     }
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial) { return module->send_status_updates(sui, last_serial); }
     void run(unsigned long SampleCount);
 #if USE_DSSI
     /// Utility function: handle MIDI event (only handles a subset in this version)
diff --git a/src/calf/lv2wrap.h b/src/calf/lv2wrap.h
index 15b5cb8..6a9bc40 100644
--- a/src/calf/lv2wrap.h
+++ b/src/calf/lv2wrap.h
@@ -92,11 +92,14 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
         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);
-            if ((pp.flags & PF_TYPEMASK) == PF_STRING
+            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);
@@ -160,6 +163,7 @@ struct lv2_instance: public plugin_ctl_iface, public progress_report_iface
     }
     virtual const plugin_metadata_iface *get_metadata_iface() const { return metadata; }
     virtual const line_graph_iface *get_line_graph_iface() const { return module->get_line_graph_iface(); }
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial) { return module->send_status_updates(sui, last_serial); }
 };
 
 struct LV2_Calf_Descriptor {
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 5cb0107..27b675c 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -383,16 +383,14 @@ 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")
     plugin_command_info *get_commands();
-    const char **get_default_configure_vars();
 };
 
 /// FluidSynth - metadata
 struct fluidsynth_metadata: public plugin_metadata<fluidsynth_metadata>
 {
-    enum { par_master, par_soundfont, par_interpolation, par_reverb, par_chorus, param_count };
+    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")
-    const char **get_default_configure_vars();
 };
     
 /// Wavetable - metadata
diff --git a/src/calf/utils.h b/src/calf/utils.h
index 9177c92..3dd83de 100644
--- a/src/calf/utils.h
+++ b/src/calf/utils.h
@@ -93,10 +93,10 @@ public:
 };
 
 /// Exception-safe temporary assignment
-template<class T, class Tref>
+template<class T, class Tref = T&>
 class scope_assign
 {
-    Tref &data;
+    Tref data;
     T old_value;
 public:
     scope_assign(Tref _data, T new_value)
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index 650c17e..5a417b2 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -102,9 +102,12 @@ struct plugin_proxy: public plugin_ctl_iface, public line_graph_iface
     map<int, param_line_graphs> graphs;
     bool update_graphs;
     const plugin_metadata_iface *metadata;
+    vector<string> new_status;
+    uint32_t new_status_serial;
 
     plugin_proxy(const plugin_metadata_iface *md)
     {
+        new_status_serial = 0;
         metadata = md;
         client = NULL;
         send_osc = false;
@@ -123,6 +126,11 @@ 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)
@@ -169,6 +177,21 @@ struct plugin_proxy: public plugin_ctl_iface, public line_graph_iface
         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());
     }
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial)
+    {
+        if ((int)new_status_serial != last_serial)
+        {
+            for (size_t i = 0; i < (new_status.size() & ~1); i += 2)
+            {
+                sui->send_status(new_status[i].c_str(), new_status[i + 1].c_str());
+            }
+            return new_status_serial;
+        }
+        osc_inline_typed_strstream str;
+        str << (uint32_t)last_serial;
+        client->send("/send_status", str);
+        return last_serial;
+    }
     virtual const line_graph_iface *get_line_graph_iface() const { return this; }
     virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context) const;
     virtual bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context) const;
@@ -531,6 +554,24 @@ void dssi_osc_server::receive_osc_message(std::string address, std::string args,
         }
         return;
     }
+    else if (address == prefix + "/status_data" && (args.length() & 1) && args[args.length() - 1] == 'i')
+    {
+        int len = (int)args.length();
+        plugin->new_status.clear();
+        
+        for (int pos = 0; pos < len - 2; pos += 2)
+        {
+            if (args[pos] == 's' && args[pos+1] == 's')
+            {
+                string key, value;
+                buffer >> key >> value;
+                plugin->new_status.push_back(key);
+                plugin->new_status.push_back(value);
+            }
+        }
+        buffer >> plugin->new_status_serial;
+        return;
+    }
     else
         printf("Unknown OSC address: %s\n", address.c_str());
 }
diff --git a/src/fluidsynth.cpp b/src/fluidsynth.cpp
index 8b10896..451387c 100644
--- a/src/fluidsynth.cpp
+++ b/src/fluidsynth.cpp
@@ -172,6 +172,7 @@ char *fluidsynth_audio_module::configure(const char *key, const char *value)
         soundfont = value;
         int newsfid = -1;
         fluid_synth_t *new_synth = create_synth(newsfid);
+        status_serial++;
         
         if (new_synth)
         {
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 0faca26..6144cb1 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -362,7 +362,7 @@ const void *gui_extension(const char *uri)
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
-class ext_plugin_gui: public lv2_external_ui, public plugin_proxy_base, public osc_message_sink<osc_strstream>
+class ext_plugin_gui: public lv2_external_ui, public plugin_proxy_base, public osc_message_sink<osc_strstream>, public send_updates_iface
 {
 public:
     GPid child_pid;
@@ -372,6 +372,7 @@ public:
     string prefix;
     dssi_feedback_sender *feedback_sender;
     bool enable_graph_updates;
+    osc_inline_typed_strstream status_data;
 
     ext_plugin_gui(const plugin_metadata_iface *metadata, LV2UI_Write_Function wf, LV2UI_Controller c, const LV2_Feature* const* f);
 
@@ -382,6 +383,7 @@ public:
     void run_impl();
     void port_event_impl(uint32_t port, uint32_t buffer_size, uint32_t format, const void *buffer);
 
+    virtual void send_status(const char *key, const char *value);
     virtual void receive_osc_message(std::string address, std::string args, osc_strstream &buffer);
     virtual ~ext_plugin_gui();
         
@@ -423,6 +425,11 @@ void ext_plugin_gui::hide_impl()
     cli.send("/hide");
 }
 
+void ext_plugin_gui::send_status(const char *key, const char *value)
+{
+    status_data << key << value;
+}
+
 void ext_plugin_gui::port_event_impl(uint32_t port, uint32_t buffer_size, uint32_t format, const void *buffer)
 {
     assert(confirmed);
@@ -504,7 +511,20 @@ void ext_plugin_gui::receive_osc_message(std::string address, std::string args,
     {
         string key, value;
         buffer >> key >> value;
-        configure(key.c_str(), value.c_str());
+        plugin_proxy_base::configure(key.c_str(), value.c_str());
+    }
+    else
+    if (address == "/bridge/send_status" && args == "i")
+    {
+        if (instance)
+        {
+            int serial;
+            buffer >> serial;
+
+            status_data.clear();
+            status_data << (uint32_t)instance->send_status_updates(this, serial);
+            cli.send("/status_data", status_data);
+        }
     }
     else
         srv.dump.receive_osc_message(address, args, buffer);
diff --git a/src/metadata.cpp b/src/metadata.cpp
index f08fa48..5dff436 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -684,12 +684,6 @@ CALF_PORT_PROPS(monosynth) = {
 
 CALF_PLUGIN_INFO(organ) = { 0x8481, "Organ", "Calf Organ", "Krzysztof Foltman", calf_plugins::calf_copyright_info, "SynthesizerPlugin" };
 
-const char **organ_metadata::get_default_configure_vars()
-{
-    static const char *data[] = { "map_curve", "2\n0 1\n1 1\n", NULL };
-    return data;
-}
-
 plugin_command_info *organ_metadata::get_commands()
 {
     static plugin_command_info cmds[] = {
@@ -885,6 +879,7 @@ CALF_PORT_PROPS(organ) = {
 ////////////////////////////////////////////////////////////////////////////
 
 const char *fluidsynth_init_soundfont = "";
+const char *fluidsynth_init_presetkeyset = "";
 
 const char *fluidsynth_interpolation_names[] = { "None (zero-hold)", "Linear", "Cubic", "7-point" };
 
@@ -896,10 +891,11 @@ CALF_PLUGIN_INFO(fluidsynth) = { 0x8700, "Fluidsynth", "Calf Fluidsynth", "Fluid
 
 CALF_PORT_PROPS(fluidsynth) = {
     { 0.5,         0,   1, 100, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_PROP_OUTPUT_GAIN, NULL, "master", "Volume" },
-    { 0,          0,    0,    0, PF_STRING | PF_PROP_MSGCONTEXT, &fluidsynth_init_soundfont, "soundfont", "Soundfont" },
     { 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" },
 };
 
 ////////////////////////////////////////////////////////////////////////////

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list