[SCM] calf/master: + Framework: general clean-up and simplification of wrapper-related code, moved various utility functions to utils.h/cpp, removed dependency of 2 more .cpp files on plugin classes

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


The following commit has been merged in the master branch:
commit b067762a11f577e430990e6107aab2711a39dbe8
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Tue Nov 4 23:38:19 2008 +0000

    + Framework: general clean-up and simplification of wrapper-related code, moved various utility functions to utils.h/cpp, removed dependency of 2 more .cpp files on plugin classes

diff --git a/src/benchmark.cpp b/src/benchmark.cpp
index 479c8e1..d09e1e9 100644
--- a/src/benchmark.cpp
+++ b/src/benchmark.cpp
@@ -17,13 +17,15 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+#include <assert.h>
 #include <getopt.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <config.h>
-#include <calf/giface.h>
-#include <calf/modules.h>
-#include <calf/modules_dev.h>
+#include <calf/audio_fx.h>
+//#include <calf/giface.h>
+//#include <calf/modules.h>
+//#include <calf/modules_dev.h>
 #include <calf/loudness.h>
 #include <calf/benchmark.h>
 
@@ -209,6 +211,7 @@ void alignment_test()
         do_simple_benchmark<aligned_double>();
 }
 
+#if 0
 template<class Effect>
 void get_default_effect_params(float params[Effect::param_count], uint32_t &sr);
 
@@ -296,6 +299,12 @@ void effect_test()
     dsp::do_simple_benchmark<effect_benchmark<synth::filter_audio_module> >(5, 10000);
 }
 
+#else
+void effect_test()
+{
+    printf("Test temporarily removed due to refactoring\n");
+}
+#endif
 void reverbir_calc()
 {
     enum { LEN = 1048576 };
@@ -303,7 +312,7 @@ void reverbir_calc()
     
     for (int t = 1; t < 38; t++)
     {
-        reverb<float> rvb;
+        dsp::reverb<float> rvb;
         
         memset(data, 0, sizeof(data));
         data[0][0] = 1;
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 4892f94..ad181bf 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -23,16 +23,6 @@
 
 #include <stdint.h>
 #include <stdlib.h>
-#if USE_LADSPA
-#include <ladspa.h>
-#endif
-#if USE_DSSI
-#include <dssi.h>
-#endif
-#if USE_JACK
-#include <jack/jack.h>
-#include <jack/midiport.h>
-#endif
 #include <exception>
 #include <string>
 #include "primitives.h"
@@ -175,101 +165,96 @@ struct send_configure_iface
 
 struct plugin_command_info;
 
+/// General information about the plugin - @todo XXXKF lacks the "new" id-label-name triple
+struct ladspa_plugin_info
+{
+    /// LADSPA ID
+    uint32_t unique_id;
+    /// plugin short name (camel case)
+    const char *label;
+    /// plugin human-readable name
+    const char *name;
+    /// maker (author)
+    const char *maker;
+    /// copyright notice
+    const char *copyright;
+    /// plugin type for LRDF/LV2
+    const char *plugin_type;
+};
+
+/// An interface returning metadata about a plugin
 struct plugin_metadata_iface
 {
     /// @return plugin long name
-    virtual const char *inst_get_name() = 0;
+    virtual const char *get_name() = 0;
     /// @return plugin LV2 label
-    virtual const char *inst_get_id() = 0;
+    virtual const char *get_id() = 0;
     /// @return plugin human-readable label
-    virtual const char *inst_get_label() = 0;
+    virtual const char *get_label() = 0;
+    /// @return total number of parameters
+    virtual int get_param_count() = 0;
+    /// Return custom XML
+    virtual const char *get_gui_xml() = 0;
+    /// @return number of audio inputs
+    virtual int get_input_count()=0;
+    /// @return number of audio outputs
+    virtual int get_output_count()=0;
+    /// @return true if plugin can work in hard-realtime conditions
+    virtual bool is_rt_capable()=0;
+    /// @return true if plugin has MIDI input
+    virtual bool get_midi()=0;
+    /// @return true if plugin has MIDI input
+    virtual bool requires_midi()=0;
+    /// @return port offset of first control (parameter) port (= number of audio inputs + number of audio outputs in all existing plugins as for 1 Aug 2008)
+    virtual int get_param_port_offset() = 0;
+    /// @return line_graph_iface if any
+    virtual line_graph_iface *get_line_graph_iface() = 0;
+    /// @return NULL-terminated list of menu commands
+    virtual plugin_command_info *get_commands() { return NULL; }
+    /// @return description structure for given parameter
+    virtual parameter_properties *get_param_props(int param_no) = 0;
+    /// @return retrieve names of audio ports (@note control ports are named in parameter_properties, not here)
+    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?
+    virtual bool is_noisy(int param_no) = 0;
+
+    /// Do-nothing destructor to silence compiler warning
+    virtual ~plugin_metadata_iface() {}
 };
 
 /// Interface for host-GUI-plugin interaction (should be really split in two, but ... meh)
 struct plugin_ctl_iface: public virtual plugin_metadata_iface
 {
-    /// @return description structure for given parameter
-    virtual parameter_properties *get_param_props(int param_no) = 0;
-    /// @return total number of parameters
-    virtual int get_param_count() = 0;
     /// @return value of given parameter
     virtual float get_param_value(int param_no) = 0;
     /// Set value of given parameter
     virtual void set_param_value(int param_no, float value) = 0;
-    /// Return custom XML
-    virtual const char *get_gui_xml() = 0;
-    /// @return line_graph_iface if any
-    virtual line_graph_iface *get_line_graph_iface() = 0;
-    /// @return port offset of first control (parameter) port (= number of audio inputs + number of audio outputs in all existing plugins as for 1 Aug 2008)
-    virtual int get_param_port_offset() = 0;
     /// Load preset with given number
     virtual bool activate_preset(int bank, int program) = 0;
-    /// @return number of audio inputs
-    virtual int get_input_count()=0;
-    /// @return number of audio outputs
-    virtual int get_output_count()=0;
-    /// @return true if plugin has MIDI input
-    virtual bool get_midi()=0;
     /// @return volume level for port'th port (if supported by the implementation, currently only jack_host<Module> implements that by measuring signal level on plugin ports)
     virtual float get_level(unsigned int port)=0;
-    /// @return NULL-terminated list of menu commands
-    virtual plugin_command_info *get_commands() { return NULL; }
     /// 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; }
     /// 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
-    virtual void clear_preset()=0;
+    /// Restore all state (parameters and configure vars) to default values - implemented in giface.cpp
+    virtual void clear_preset();
     /// Do-nothing destructor to silence compiler warning
     virtual ~plugin_ctl_iface() {}
 };
 
-/// General information about the plugin
-struct ladspa_plugin_info
-{
-    /// LADSPA ID
-    uint32_t unique_id;
-    /// plugin short name (camel case)
-    const char *label;
-    /// plugin human-readable name
-    const char *name;
-    /// maker (author)
-    const char *maker;
-    /// copyright notice
-    const char *copyright;
-    /// plugin type for LRDF/LV2
-    const char *plugin_type;
-};
-
-struct giface_plugin_info
-{
-    /// information like LADSPA ID, LADSPA label, name, maker, copyright and LRDF/LV2 plugin type (category)
-    ladspa_plugin_info *info;
-    /// number of inputs
-    int inputs;
-    /// number of outputs
-    int outputs;
-    /// number of control ports (inputs or outputs)
-    int params;
-    /// is realtime-capable?
-    bool rt_capable;
-    /// has MIDI input?
-    bool midi_in_capable;
-    /// requires MIDI input handling (a synth or equivalent)
-    bool midi_in_required;
-    /// parameter properties structure
-    parameter_properties *param_props;
-    /// is a given parameter a control voltage?
-    bool (*is_cv)(int param_no);
-    /// is the given parameter non-interpolated?
-    bool (*is_noisy)(int param_no);
-};
-
 struct plugin_list_info_iface;
 
-extern void get_all_plugins(std::vector<giface_plugin_info> &plugins);
+extern void get_all_plugins(std::vector<plugin_metadata_iface *> &plugins);
 extern void get_all_small_plugins(plugin_list_info_iface *plii);
 
 
@@ -283,15 +268,14 @@ public:
     virtual ~audio_exception() throw () {}
 };
 
-/// Escape a string to be used in XML file
-std::string xml_escape(const std::string &src);
-
 /// Empty implementations for plugin functions. Note, that functions aren't virtual, because they're called via the particular
 /// subclass (flanger_audio_module etc) via template wrappers (ladspa_wrapper<> etc), not via base class pointer/reference
 template<class Metadata>
 class audio_module: public Metadata
 {
 public:
+    typedef Metadata metadata_type;
+
     /// Handle MIDI Note On
     inline void note_on(int note, int velocity) {}
     /// Handle MIDI Note Off
@@ -311,30 +295,17 @@ public:
     inline void deactivate() {}
     /// Set sample rate for the plugin
     inline void set_sample_rate(uint32_t sr) { }
-    /// Get "live" graph
-    inline bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) { return false; }
-    inline static const char *get_gui_xml() { return NULL; }
-    /// Get "static" graph (one that is dependent on single parameter value and doesn't use other parameters or plugin internal state).
-    /// Used by waveform graphs.
-    inline static bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context) { return false; }
-    /// Return the NULL-terminated list of menu commands
-    inline static plugin_command_info *get_commands() { return NULL; }
-    /// does parameter number represent a CV port? (yes by default, except for synths)
-    static bool is_cv(int param_no) { return true; }
-    /// does parameter change cause an audible click?
-    static bool is_noisy(int param_no) { return false; }
     /// Execute menu command with given number
     inline void execute(int cmd_no) {}
     /// DSSI configure call
     inline char *configure(const char *key, const char *value) { return NULL; }
     /// Send all understood configure vars
     inline void send_configures(send_configure_iface *sci) {}
-    /// Get all configure vars that are supposed to be set to initialize a preset
-    static inline const char **get_default_configure_vars() { return NULL; }
     /// Reset parameter values for epp:trigger type parameters (ones activated by oneshot push button instead of check box)
     inline void params_reset() {}
 };
 
+/// Metadata base class template, to provide default versions of interface functions
 template<class Metadata>
 class plugin_metadata: public virtual plugin_metadata_iface
 {    
@@ -343,19 +314,37 @@ public:
     static parameter_properties param_props[];
     static synth::ladspa_plugin_info plugin_info;
 
-    const char *inst_get_name() { return Metadata::get_name(); } 
-    const char *inst_get_id() { return Metadata::get_id(); } 
-    const char *inst_get_label() { return Metadata::get_label(); } 
-    
+    // These below are stock implementations based on enums and static members in Metadata class
+    // they may be overridden to provide more interesting functionality
+
+    const char *get_name() { return Metadata::impl_get_name(); } 
+    const char *get_id() { return Metadata::impl_get_id(); } 
+    const char *get_label() { return Metadata::impl_get_label(); } 
+    int get_input_count() { return Metadata::in_count; }
+    int get_output_count() { return Metadata::out_count; }
+    int get_param_count() { return Metadata::param_count; }
+    bool get_midi() { return Metadata::support_midi; }
+    bool requires_midi() { return Metadata::require_midi; }
+    bool is_rt_capable() { return Metadata::rt_capable; }
+    line_graph_iface *get_line_graph_iface() { return dynamic_cast<line_graph_iface *>(this); }    
+    int get_param_port_offset()  { return Metadata::in_count + Metadata::out_count; }
+    const char *get_gui_xml() { return NULL; }
+    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; }
 };
 
 #define CALF_PORT_NAMES(name) template<> const char *synth::plugin_metadata<name##_metadata>::port_names[]
 #define CALF_PORT_PROPS(name) template<> parameter_properties plugin_metadata<name##_metadata>::param_props[]
 #define CALF_PLUGIN_INFO(name) template<> synth::ladspa_plugin_info plugin_metadata<name##_metadata>::plugin_info
 #define PLUGIN_NAME_ID_LABEL(name, id, label) \
-    static const char *get_name() { return name; } \
-    static const char *get_id() { return id; } \
-    static const char *get_label() { return label; } \
+    static const char *impl_get_name() { return name; } \
+    static const char *impl_get_id() { return id; } \
+    static const char *impl_get_label() { return label; } \
     
 
 extern const char *calf_copyright_info;
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index f1e1eab..51eb18e 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -23,6 +23,8 @@
 
 #if USE_JACK
 
+#include <jack/jack.h>
+#include <jack/midiport.h>
 #include "gui.h"
 #include "utils.h"
 #include <pthread.h>
@@ -379,15 +381,7 @@ public:
     virtual port *get_inputs() { return inputs; }
     virtual port *get_outputs() { return outputs; }
     virtual float *get_params() { return param_values; }
-    virtual int get_input_count() { return Module::in_count; }
-    virtual int get_output_count() { return Module::out_count; }
-    virtual int get_param_count() { return Module::param_count; }
-    virtual bool get_midi() { return Module::support_midi; }
     virtual bool activate_preset(int bank, int program) { return false; }
-    virtual int get_param_port_offset() 
-    {
-        return Module::in_count + Module::out_count;
-    }
     virtual float get_param_value(int param_no) {
         return param_values[param_no];
     }
@@ -395,28 +389,6 @@ public:
         param_values[param_no] = value;
         changed = true;
     }
-    virtual const char *get_gui_xml() {
-        return Module::get_gui_xml();
-    }
-    virtual line_graph_iface *get_line_graph_iface()
-    {
-        return dynamic_cast<line_graph_iface *>(this);
-    }
-    virtual const char *get_name()
-    {
-        return Module::get_name();
-    }
-    virtual const char *get_id()
-    {
-        return Module::get_id();
-    }
-    virtual const char *get_label()
-    {
-        return Module::get_label();
-    }
-    virtual plugin_command_info *get_commands() {
-        return Module::get_commands();
-    }
     virtual void execute(int cmd_no) {
         Module::execute(cmd_no);
     }
@@ -426,17 +398,6 @@ public:
     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++)
-            param_values[i] = Module::param_props[i].def_value;
-        // This is never called in practice, at least for now
-        const char **p = Module::get_default_configure_vars();
-        if (p)
-        {
-            for(; p[0]; p += 2)
-                configure(p[0], p[1]);
-        }
-    }
 };
 
 extern jack_host_base *create_jack_host(const char *name);
diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index 6057b98..a8e34c5 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -23,6 +23,10 @@
 
 #if USE_LADSPA
 
+#include <ladspa.h>
+#if USE_DSSI
+#include <dssi.h>
+#endif
 #include "giface.h"
 
 namespace synth {
diff --git a/src/calf/modules.h b/src/calf/modules.h
index dbdac04..9e60550 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -261,6 +261,8 @@ struct filter_metadata: public plugin_metadata<filter_metadata>
     enum { par_cutoff, par_resonance, par_mode, par_inertia, param_count };
     enum { in_count = 2, out_count = 2, rt_capable = true, require_midi = false, support_midi = false };
     PLUGIN_NAME_ID_LABEL("filter", "filter", "Filter")
+    /// do not export mode and inertia as CVs, as those are settings and not parameters
+    bool is_cv(int param_no) { return param_no != par_mode && param_no != par_inertia; }
 };
 
 class filter_audio_module: public audio_module<filter_metadata>
@@ -283,8 +285,6 @@ public:
         order = 0;
     }
     
-    /// do not export mode and inertia as CVs, as those are settings and not parameters
-    inline static bool is_cv(int param_no) { return param_no != par_mode && param_no != par_inertia; }
     void calculate_filter()
     {
         float freq = inertia_cutoff.get_last();
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index aa9ae23..447a5bb 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -43,11 +43,12 @@ struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
     enum { in_count = 0, out_count = 2, support_midi = true, require_midi = true, rt_capable = true };
     enum { step_size = 64 };
     PLUGIN_NAME_ID_LABEL("monosynth", "monosynth", "Monosynth")
+    const char *get_gui_xml();
 };
     
 /// Monosynth-in-making. Parameters may change at any point, so don't make songs with it!
 /// It lacks inertia for parameters, even for those that really need it.
-class monosynth_audio_module: public audio_module<monosynth_metadata>
+class monosynth_audio_module: public audio_module<monosynth_metadata>, public line_graph_iface
 {
 public:
     float *ins[in_count]; 
@@ -74,7 +75,6 @@ public:
     synth::keystack stack;
     dsp::gain_smoothing master;
     
-    static const char *get_gui_xml();
     static void generate_waves();
     void set_sample_rate(uint32_t sr);
     void delayed_note_on();
@@ -158,9 +158,9 @@ public:
         return filter_type == flt_2lp12 || filter_type == flt_2bp6;
     }
     /// No CV inputs for now
-    static bool is_cv(int param_no) { return false; }
+    bool is_cv(int param_no) { return false; }
     /// Practically all the stuff here is noisy
-    static bool is_noisy(int param_no) { return true; }
+    bool is_noisy(int param_no) { return true; }
     /// Calculate control signals and produce step_size samples of output.
     void calculate_step();
     /// Main processing function
@@ -197,9 +197,6 @@ public:
             
         return 3;
     }
-    static const char *get_name() { return "monosynth"; }
-    static const char *get_id() { return "monosynth"; }
-    static const char *get_label() { return "Monosynth"; }
 };
 
 struct organ_metadata: public plugin_metadata<organ_metadata>
@@ -207,6 +204,9 @@ struct organ_metadata: public plugin_metadata<organ_metadata>
     enum { in_count = 0, out_count = 2, support_midi = true, require_midi = true, rt_capable = true };
     enum { param_count = drawbar_organ::param_count };
     PLUGIN_NAME_ID_LABEL("organ", "organ", "Organ")
+    plugin_command_info *get_commands();
+    const char **get_default_configure_vars();
+    const char *get_gui_xml();
 };
 
 struct organ_audio_module: public audio_module<organ_metadata>, public drawbar_organ
@@ -229,7 +229,6 @@ public:
     : drawbar_organ(&par_values)
     {
     }
-    static const char *get_gui_xml();
 
     void set_sample_rate(uint32_t sr) {
         srate = sr;
@@ -261,18 +260,14 @@ public:
         return 3;
     }
     /// No CV inputs for now
-    static bool is_cv(int param_no) { return false; }
+    bool is_cv(int param_no) { return false; }
     /// Practically all the stuff here is noisy
-    static bool is_noisy(int param_no) { return true; }
+    bool is_noisy(int param_no) { return true; }
     void execute(int cmd_no);
     bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
-    static const char *get_name() { return "organ"; }    
-    static const char *get_id() { return "organ"; }    
-    static const char *get_label() { return "Organ"; }    
-    static plugin_command_info *get_commands();
+    
     char *configure(const char *key, const char *value);
     void send_configures(send_configure_iface *);
-    static const char **get_default_configure_vars();
 };
 
 };
diff --git a/src/calf/utils.h b/src/calf/utils.h
index e791399..a70cf2c 100644
--- a/src/calf/utils.h
+++ b/src/calf/utils.h
@@ -28,6 +28,7 @@
 namespace calf_utils
 {
 
+/// Pthreads based mutex class
 class ptmutex
 {
 public:
@@ -63,6 +64,7 @@ public:
     }
 };
 
+/// Exception-safe mutex lock
 class ptlock
 {
     ptmutex &mutex;
@@ -89,6 +91,7 @@ public:
     }
 };
 
+/// Exception-safe temporary assignment
 template<class T>
 class scope_assign
 {
@@ -105,26 +108,22 @@ public:
     }
 };
 
+/// String-to-string mapping
 typedef std::map<std::string, std::string> dictionary;
 
-extern std::string encodeMap(const dictionary &data);
-extern void decodeMap(dictionary &data, const std::string &src);
+/// Serialize a dictonary to a string
+extern std::string encode_map(const dictionary &data);
+/// Deserialize a dictonary from a string
+extern void decode_map(dictionary &data, const std::string &src);
 
-static inline std::string i2s(int value)
-{
-    char buf[32];
-    sprintf(buf, "%d", value);
-    
-    return std::string(buf);
-}
+/// int-to-string
+extern std::string i2s(int value);
 
-static inline std::string f2s(double value)
-{
-    // XXXKF might not work with some locale settings
-    char buf[64];
-    sprintf(buf, "%g", value);
-    return buf;
-}
+/// float-to-string
+extern std::string f2s(double value);
+
+/// Escape a string to be used in XML file
+std::string xml_escape(const std::string &src);
 
 };
 
diff --git a/src/dssigui.cpp b/src/dssigui.cpp
index e2b57a2..630279c 100644
--- a/src/dssigui.cpp
+++ b/src/dssigui.cpp
@@ -85,25 +85,25 @@ struct plugin_proxy_base: public plugin_ctl_iface
     }
 };
 
-template<class Module>
-struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
+template<class Metadata>
+struct plugin_proxy: public plugin_proxy_base, public Metadata
 {
-    float params[Module::param_count];
+    using Metadata::param_count;
+    
+    float params[param_count];
+
     plugin_proxy()
     {
-        for (unsigned int i = 0; i < Module::param_count; i++)
+        for (unsigned int i = 0; i < param_count; i++)
             params[i] = get_param_props(i)->def_value;
     }
-    virtual parameter_properties *get_param_props(int param_no) {
-        return Module::param_props + param_no;
-    }
     virtual float get_param_value(int param_no) {
-        if (param_no < 0 || param_no >= Module::param_count)
+        if (param_no < 0 || param_no >= param_count)
             return 0;
         return params[param_no];
     }
     virtual void set_param_value(int param_no, float value) {
-        if (param_no < 0 || param_no >= Module::param_count)
+        if (param_no < 0 || param_no >= param_count)
             return;
         params[param_no] = value;
         if (send_osc)
@@ -113,18 +113,6 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
             client->send("/control", str);
         }
     }
-    virtual int get_param_count() {
-        return Module::param_count;
-    }
-    virtual int get_param_port_offset() {
-        return Module::in_count + Module::out_count;
-    }
-    virtual const char *get_gui_xml() {
-        return Module::get_gui_xml();
-    }
-    virtual line_graph_iface *get_line_graph_iface() {
-        return this;
-    }
     virtual bool activate_preset(int bank, int program) { 
         if (send_osc) {
             osc_inline_typed_strstream str;
@@ -134,28 +122,7 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
         }
         return false;
     }
-    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) {
-        return Module::get_static_graph(index, subindex, params[index], data, points, context);
-    }
-    virtual const char *inst_get_name()
-    {
-        return Module::get_name();
-    }
-    virtual const char *inst_get_id()
-    {
-        return Module::get_id();
-    }
-    virtual const char *inst_get_label()
-    {
-        return Module::get_label();
-    }
-    virtual int get_input_count() { return Module::in_count; }
-    virtual int get_output_count() { return Module::out_count; }
-    virtual bool get_midi() { return Module::support_midi; }
     virtual float get_level(unsigned int port) { return 0.f; }
-    virtual plugin_command_info *get_commands() {
-        return Module::get_commands();
-    }
     virtual void execute(int command_no) { 
         if (send_osc) {
             stringstream ss;
@@ -182,7 +149,7 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
             sci->send_configure(i->first.c_str(), i->second.c_str());
     }
     void clear_preset() {
-        const char **p = Module::get_default_configure_vars();
+        const char **p = get_default_configure_vars();
         if (p)
         {
             for(; p[0]; p += 2)
@@ -193,7 +160,7 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
 
 plugin_proxy_base *create_plugin_proxy(const char *effect_name)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!strcmp(effect_name, jackname)) return new plugin_proxy<name##_audio_module>();
+    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!strcmp(effect_name, jackname)) return new plugin_proxy<name##_metadata>();
     #include <calf/modulelist.h>
     return NULL;
 }
diff --git a/src/giface.cpp b/src/giface.cpp
index 4580adc..2565507 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -185,16 +185,15 @@ std::string parameter_properties::to_string(float value) const
     return string(buf);
 }
 
-std::string synth::xml_escape(const std::string &src)
-{
-    string dest;
-    for (size_t i = 0; i < src.length(); i++) {
-        // XXXKF take care of string encoding
-        if (src[i] < 0 || src[i] == '"' || src[i] == '<' || src[i] == '>' || src[i] == '&')
-            dest += "&"+i2s((uint8_t)src[i])+";";
-        else
-            dest += src[i];
+void synth::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]);
     }
-    return dest;
 }
-
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index f1d4ecd..8cb6c94 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -244,7 +244,7 @@ void host_session::remove_plugin(plugin_ctl_iface *plugin)
 
 bool host_session::activate_preset(int plugin_no, const std::string &preset, bool builtin)
 {
-    string cur_plugin = dynamic_cast<plugin_metadata_iface *>(plugins[plugin_no])->inst_get_id();
+    string cur_plugin = plugins[plugin_no]->get_id();
     preset_vector &pvec = (builtin ? get_builtin_presets() : get_user_presets()).presets;
     for (unsigned int i = 0; i < pvec.size(); i++) {
         if (pvec[i].name == preset && pvec[i].plugin == cur_plugin)
@@ -361,7 +361,7 @@ void host_session::update_lash()
                 tmp["input_prefix"] = i_name;
                 tmp["output_prefix"] = stripfmt(client.output_name);
                 tmp["midi_prefix"] = stripfmt(client.midi_name);
-                pstr = encodeMap(tmp);
+                pstr = encode_map(tmp);
                 lash_config_set_value(cfg, pstr.c_str(), pstr.length());
                 lash_send_config(lash_client, cfg);
                 
@@ -369,7 +369,7 @@ void host_session::update_lash()
                     jack_host_base *p = plugins[i];
                     char ss[32];
                     plugin_preset preset;
-                    preset.plugin = dynamic_cast<plugin_metadata_iface *>(p)->inst_get_id();
+                    preset.plugin = p->get_id();
                     preset.get_from(p);
                     sprintf(ss, "Plugin%d", i);
                     pstr = preset.to_xml();
@@ -381,7 +381,7 @@ void host_session::update_lash()
                     if (p->get_midi_port())
                         tmp["midi_name"] = p->get_midi_port()->name.substr(m_name.length());
                     tmp["preset"] = pstr;
-                    pstr = encodeMap(tmp);
+                    pstr = encode_map(tmp);
                     lash_config_t *cfg = lash_config_new_with_key(ss);
                     lash_config_set_value(cfg, pstr.c_str(), pstr.length());
                     lash_send_config(lash_client, cfg);
@@ -400,7 +400,7 @@ void host_session::update_lash()
                     if (!strcmp(key, "global"))
                     {
                         dictionary dict;
-                        decodeMap(dict, data);
+                        decode_map(dict, data);
                         if (dict.count("input_prefix")) client.input_name = dict["input_prefix"]+"%d";
                         if (dict.count("output_prefix")) client.output_name = dict["output_prefix"]+"%d";
                         if (dict.count("midi_prefix")) client.midi_name = dict["midi_prefix"]+"%d";
@@ -409,7 +409,7 @@ void host_session::update_lash()
                     {
                         unsigned int nplugin = atoi(key + 6);
                         dictionary dict;
-                        decodeMap(dict, data);
+                        decode_map(dict, data);
                         data = dict["preset"];
                         if (dict.count("input_name")) client.input_nr = atoi(dict["input_name"].c_str());
                         if (dict.count("output_name")) client.output_nr = atoi(dict["output_name"].c_str());
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 62e822b..6679a99 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -59,78 +59,40 @@ struct plugin_proxy_base: public plugin_ctl_iface
     
 };
 
-template<class Module>
-struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
+template<class Metadata>
+struct plugin_proxy: public plugin_proxy_base, public Metadata
 {
-    float params[Module::param_count];
+    using Metadata::param_count;
+    
+    float params[param_count];
     plugin_proxy()
     {
         send = true;
-        for (int i = 0; i < Module::param_count; i++)
-            params[i] = Module::param_props[i].def_value;
+        for (int i = 0; i < param_count; i++)
+            params[i] = Metadata::param_props[i].def_value;
     }
     
-    virtual parameter_properties *get_param_props(int param_no) {
-        return Module::param_props + param_no;
-    }
     virtual float get_param_value(int param_no) {
-        if (param_no < 0 || param_no >= Module::param_count)
+        if (param_no < 0 || param_no >= Metadata::param_count)
             return 0;
         return params[param_no];
     }
     virtual void set_param_value(int param_no, float value) {
-        if (param_no < 0 || param_no >= Module::param_count)
+        if (param_no < 0 || param_no >= Metadata::param_count)
             return;
         params[param_no] = value;
         if (send) {
             scope_assign<bool> _a_(send, false);
-            write_function(controller, param_no + Module::in_count + Module::out_count, sizeof(float), 0, &params[param_no]);
+            write_function(controller, param_no + Metadata::in_count + Metadata::out_count, sizeof(float), 0, &params[param_no]);
         }
     }
-    virtual int get_param_count()
-    {
-        return Module::param_count;
-    }
-    virtual int get_param_port_offset()
-    {
-        return Module::in_count + Module::out_count;
-    }
-    virtual const char *get_gui_xml()
-    {
-        return Module::get_gui_xml();
-    }
-    virtual line_graph_iface *get_line_graph_iface()
-    {
-        return this;
-    }
+    
     virtual bool activate_preset(int bank, int program)
     {
         return false;
     }
-    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_t *context) 
-    {
-        return Module::get_static_graph(index, subindex, params[index], data, points, context);
-    }
-    virtual const char *inst_get_name()
-    {
-        return Module::get_name();
-    }
-    virtual const char *inst_get_id()
-    {
-        return Module::get_id();
-    }
-    virtual const char *inst_get_label()
-    {
-        return Module::get_label();
-    }
-    virtual int get_input_count() { return Module::in_count; }
-    virtual int get_output_count() { return Module::out_count; }
-    virtual bool get_midi() { return Module::support_midi; }
     virtual float get_level(unsigned int port) { return 0.f; }
     virtual void execute(int command_no) { assert(0); }
-    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");
     }
@@ -141,7 +103,7 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
 
 plugin_proxy_base *create_plugin_proxy(const char *effect_name)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!strcmp(effect_name, name##_audio_module::plugin_info.label)) return new plugin_proxy<name##_audio_module>();
+    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!strcmp(effect_name, name##_metadata::plugin_info.label)) return new plugin_proxy<name##_metadata>();
     #include <calf/modulelist.h>
     return NULL;
 }
diff --git a/src/main_win.cpp b/src/main_win.cpp
index 5c88c34..43c6f21 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -191,9 +191,7 @@ main_window::plugin_strip *main_window::create_strip(plugin_ctl_iface *plugin)
     gtk_widget_show(sep);
     row++;
     
-    plugin_metadata_iface *pmi = dynamic_cast<plugin_metadata_iface *>(plugin);
-    assert(pmi);
-    GtkWidget *label = gtk_toggle_button_new_with_label(pmi->inst_get_label());
+    GtkWidget *label = gtk_toggle_button_new_with_label(plugin->get_label());
     gtk_table_attach(GTK_TABLE(strips_table), label, 0, 1, row, row + 2, ao, GTK_SHRINK, 0, 0);
     strip->name = label;
     gtk_signal_connect(GTK_OBJECT(label), "toggled", G_CALLBACK(gui_button_pressed), 
@@ -252,9 +250,7 @@ void main_window::update_strip(plugin_ctl_iface *plugin)
 void main_window::open_gui(plugin_ctl_iface *plugin)
 {
     plugin_gui_window *gui_win = new plugin_gui_window(this);
-    plugin_metadata_iface *pmi = dynamic_cast<plugin_metadata_iface *>(plugin);
-    assert(pmi);
-    gui_win->create(plugin, (prefix + pmi->inst_get_name()).c_str(), pmi->inst_get_id());
+    gui_win->create(plugin, (prefix + plugin->get_name()).c_str(), plugin->get_id());
     gtk_widget_show_all(GTK_WIDGET(gui_win->toplevel));
     plugins[plugin]->gui_win = gui_win; 
 }
@@ -293,15 +289,18 @@ void main_window::new_plugin(const char *plugin)
 std::string main_window::make_plugin_list(GtkActionGroup *actions)
 {
     string s = plugin_pre_xml;
-    std::vector<giface_plugin_info> plugins;
+    std::vector<plugin_metadata_iface *> plugins;
     synth::get_all_plugins(plugins);
     for(unsigned int i = 0; i < plugins.size(); i++)
     {
-        string action_name = "Add" + string(plugins[i].info->label)+"Action";
+        synth::plugin_metadata_iface *p = plugins[i];
+        string action_name = "Add" + string(p->get_label())+"Action";
         s += string("<menuitem action=\"") + action_name + "\" />";
-        GtkActionEntry ae = { action_name.c_str(), NULL, plugins[i].info->name, NULL, NULL, (GCallback)add_plugin_action };
-        gtk_action_group_add_actions_full(actions, &ae, 1, (gpointer)new add_plugin_params(this, plugins[i].info->label), action_destroy_notify);
+        GtkActionEntry ae = { action_name.c_str(), NULL, p->get_name(), NULL, NULL, (GCallback)add_plugin_action };
+        gtk_action_group_add_actions_full(actions, &ae, 1, (gpointer)new add_plugin_params(this, p->get_label()), action_destroy_notify);
+        delete p;
     }
+    plugins.clear();
     return s + plugin_post_xml;
 }
 
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
index d9ecb43..585d8ef 100644
--- a/src/makerdf.cpp
+++ b/src/makerdf.cpp
@@ -22,8 +22,6 @@
 #include <stdlib.h>
 #include <config.h>
 #include <calf/giface.h>
-#include <calf/modules.h>
-#include <calf/modules_dev.h>
 #include <calf/plugininfo.h>
 #include <calf/utils.h>
 #if USE_LV2
@@ -129,13 +127,17 @@ void make_rdf()
     
     rdf += "<rdf:RDF xmlns:rdf=\"&rdf;\" xmlns:rdfs=\"&rdfs;\" xmlns:dc=\"&dc;\" xmlns:ladspa=\"&ladspa;\">\n";
 
-    #define RDF_EXPR(Module) \
-        generate_ladspa_rdf(Module::plugin_info, Module::param_props, Module::port_names, Module::param_count, Module::in_count + Module::out_count);
-    
-    #define PER_MODULE_ITEM(name, isSynth, jackname) if (!isSynth) rdf += RDF_EXPR(name##_metadata)
-    #define PER_SMALL_MODULE_ITEM(...)
-    #include <calf/modulelist.h>
-    
+    vector<synth::plugin_metadata_iface *> plugins;
+    synth::get_all_plugins(plugins);
+    for (unsigned int i = 0; i < plugins.size(); i++)
+    {
+        synth::plugin_metadata_iface *p = plugins[i];
+        if (!p->requires_midi()) {
+            rdf += generate_ladspa_rdf(p->get_plugin_info(), p->get_param_props(0), p->get_port_names(), p->get_param_count(), p->get_param_port_offset());
+        }
+        delete p;
+    }    
+    plugins.clear();
     rdf += "</rdf:RDF>\n";
     
     printf("%s\n", rdf.c_str());
@@ -194,7 +196,7 @@ static const char *units[] = {
 
 //////////////// To all haters: calm down, I'll rewrite it to use the new interface one day
 
-static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, giface_plugin_info *gpi, int param)
+static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, plugin_metadata_iface *pmi, int param)
 {
     stringstream ss;
     const char *ind = "        ";
@@ -218,9 +220,9 @@ static void add_ctl_port(string &ports, parameter_properties &pp, int pidx, gifa
         ss << ind << "lv2:portProperty epp:expensive ;\n";
     if (pp.flags & PF_PROP_OPTIONAL)
         ss << ind << "lv2:portProperty lv2:connectionOptional ;\n";
-    if ((*gpi->is_noisy)(param))
+    if (pmi->is_noisy(param))
         ss << ind << "lv2:portProperty epp:causesArtifacts ;\n";
-    if (!(*gpi->is_cv)(param))
+    if (!pmi->is_cv(param))
         ss << ind << "lv2:portProperty epp:notAutomatic ;\n";
     if (pp.flags & PF_PROP_OUTPUT_GAIN)
         ss << ind << "lv2:portProperty epp:outputGain ;\n";
@@ -447,7 +449,7 @@ void make_ttl(string path_prefix)
         "\n"
     ;
     
-    vector<synth::giface_plugin_info> plugins;
+    vector<synth::plugin_metadata_iface *> plugins;
     synth::get_all_plugins(plugins);
     
     map<string, string> classes;
@@ -486,18 +488,19 @@ void make_ttl(string path_prefix)
 #endif
     
     for (unsigned int i = 0; i < plugins.size(); i++) {
-        synth::giface_plugin_info &pi = plugins[i];
-        string uri = string("<http://calf.sourceforge.net/plugins/")  + string(pi.info->label) + ">";
+        synth::plugin_metadata_iface *pi = plugins[i];
+        const synth::ladspa_plugin_info &lpi = pi->get_plugin_info();
+        string uri = string("<http://calf.sourceforge.net/plugins/")  + string(lpi.label) + ">";
         string ttl;
         ttl = "@prefix : " + uri + " .\n" + header + gui_header;
         
         ttl += uri + " a lv2:Plugin ;\n";
         
-        if (classes.count(pi.info->plugin_type))
-            ttl += "    a " + classes[pi.info->plugin_type]+" ;\n";
+        if (classes.count(lpi.plugin_type))
+            ttl += "    a " + classes[lpi.plugin_type]+" ;\n";
         
             
-        ttl += "    doap:name \""+string(pi.info->name)+"\" ;\n";
+        ttl += "    doap:name \""+string(lpi.name)+"\" ;\n";
 
 #if USE_LV2_GUI
         ttl += "    uiext:ui <http://calf.sourceforge.net/plugins/gui/gtk2-gui> ;\n";
@@ -506,11 +509,11 @@ void make_ttl(string path_prefix)
         ttl += "    doap:license <http://usefulinc.com/doap/licenses/lgpl> ;\n";
         // XXXKF not really optional for now, to be honest
         ttl += "    lv2:optionalFeature epp:supportsStrictBounds ;\n";
-        if (pi.rt_capable)
+        if (pi->is_rt_capable())
             ttl += "    lv2:optionalFeature lv2:hardRtCapable ;\n";
-        if (pi.midi_in_capable)
+        if (pi->get_midi())
         {
-            if (pi.midi_in_required) {
+            if (pi->requires_midi()) {
                 ttl += "    lv2:requiredFeature <" LV2_EVENT_URI "> ;\n";
                 ttl += "    lv2:requiredFeature <" LV2_URI_MAP_URI "> ;\n";                
             }
@@ -524,20 +527,20 @@ void make_ttl(string path_prefix)
         int pn = 0;
         const char *in_names[] = { "in_l", "in_r" };
         const char *out_names[] = { "out_l", "out_r" };
-        for (int i = 0; i < pi.inputs; i++)
+        for (int i = 0; i < pi->get_input_count(); i++)
             add_port(ports, in_names[i], in_names[i], "Input", pn++);
-        for (int i = 0; i < pi.outputs; i++)
+        for (int i = 0; i < pi->get_output_count(); i++)
             add_port(ports, out_names[i], out_names[i], "Output", pn++);
-        for (int i = 0; i < pi.params; i++)
-            add_ctl_port(ports, pi.param_props[i], pn++, &pi, i);
-        if (pi.midi_in_capable) {
+        for (int i = 0; i < pi->get_param_count(); i++)
+            add_ctl_port(ports, *pi->get_param_props(i), pn++, pi, i);
+        if (pi->get_midi()) {
             add_port(ports, "event_in", "Event", "Input", pn++, "lv2ev:EventPort", true);
         }
         if (!ports.empty())
             ttl += "    lv2:port " + ports + "\n";
         ttl += ".\n\n";
         
-        FILE *f = fopen((path_prefix+string(pi.info->label)+".ttl").c_str(), "w");
+        FILE *f = fopen((path_prefix+string(lpi.label)+".ttl").c_str(), "w");
         fprintf(f, "%s\n", ttl.c_str());
         fclose(f);
     }
@@ -594,12 +597,12 @@ void make_manifest()
         "kf:MIDIPlugin a rdfs:Class ; rdfs:label \"MIDI\" ; rdfs:subClassOf lv2:UtilityPlugin ; rdfs:comment \"\"\"Operations on MIDI streams (filters, transposers, mappers etc.)\"\"\" .\n"
     ;
     
-    vector<synth::giface_plugin_info> plugins;
+    vector<synth::plugin_metadata_iface *> plugins;
     synth::get_all_plugins(plugins);
     for (unsigned int i = 0; i < plugins.size(); i++)
         ttl += string("<http://calf.sourceforge.net/plugins/") 
-            + string(plugins[i].info->label)
-            + "> a lv2:Plugin ; lv2:binary <calf.so> ; rdfs:seeAlso <" + string(plugins[i].info->label) + ".ttl> .\n";
+            + string(plugins[i]->get_plugin_info().label)
+            + "> a lv2:Plugin ; lv2:binary <calf.so> ; rdfs:seeAlso <" + string(plugins[i]->get_plugin_info().label) + ".ttl> .\n";
 
     lv2_plugin_list lpl;
     synth::get_all_small_plugins(&lpl);
diff --git a/src/modules.cpp b/src/modules.cpp
index 178db81..a3c2fc2 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -25,16 +25,11 @@
 #include <jack/jack.h>
 #endif
 #include <calf/giface.h>
-#include <calf/lv2wrap.h>
 #include <calf/modules.h>
 #include <calf/modules_dev.h>
 
 using namespace synth;
 
-#if USE_LV2
-template<class Module> LV2_Descriptor lv2_small_wrapper<Module>::descriptor;
-#endif
-
 const char *synth::calf_copyright_info = "(C) 2001-2008 Krzysztof Foltman, license: LGPL";
 
 ////////////////////////////////////////////////////////////////////////////
@@ -204,26 +199,9 @@ CALF_PLUGIN_INFO(compressor) = { 0x8502, "Compressor", "Calf Compressor", "Thor
 
 ////////////////////////////////////////////////////////////////////////////
 
-template<class Module>
-giface_plugin_info create_plugin_info(ladspa_plugin_info &info)
-{
-    giface_plugin_info pi;
-    pi.info = &info;
-    pi.inputs = Module::in_count;
-    pi.outputs = Module::out_count;
-    pi.params = Module::param_count;
-    pi.rt_capable = Module::rt_capable;
-    pi.midi_in_capable = Module::support_midi;
-    pi.midi_in_required = Module::require_midi;
-    pi.param_props = Module::param_props;
-    pi.is_noisy = Module::is_noisy;
-    pi.is_cv = Module::is_cv;
-    return pi;
-}
-
-void synth::get_all_plugins(std::vector<giface_plugin_info> &plugins)
+void synth::get_all_plugins(std::vector<plugin_metadata_iface *> &plugins)
 {
-    #define PER_MODULE_ITEM(name, isSynth, jackname) plugins.push_back(create_plugin_info<name##_audio_module>(name##_audio_module::plugin_info));
+    #define PER_MODULE_ITEM(name, isSynth, jackname) plugins.push_back(new name##_metadata);
     #define PER_SMALL_MODULE_ITEM(...)
     #include <calf/modulelist.h>
 }
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index 7c179df..f9a306f 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -224,7 +224,7 @@ CALF_PORT_PROPS(monosynth) = {
 
 float silence[4097];
 
-const char *monosynth_audio_module::get_gui_xml()
+const char *monosynth_metadata::get_gui_xml()
 {
     return monosynth_gui_xml;
 }
diff --git a/src/organ.cpp b/src/organ.cpp
index 80a6f96..3c80aac 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -51,7 +51,7 @@ CALF_PLUGIN_INFO(organ) = { 0x8481, "Organ", "Calf Organ", "Krzysztof Foltman",
             "<value  attach-x=\"" no "\" attach-y=\"11\" param=\"pan" no "\"/>" \
             "<combo  attach-x=\"" no "\" attach-y=\"12\" param=\"routing" no "\"/>" 
 
-const char *organ_audio_module::get_gui_xml()
+const char *organ_metadata::get_gui_xml()
 {
     return 
     "<vbox border=\"10\">"
@@ -382,6 +382,23 @@ const char *organ_audio_module::get_gui_xml()
     ;
 }
 
+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[] = {
+        { "cmd_panic", "Panic!", "Stop all sounds and reset all controllers" },
+        { NULL }
+    };
+    return cmds;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 bool organ_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_t *context)
 {
     if (index == par_master) {
@@ -1290,17 +1307,3 @@ void organ_audio_module::send_configures(send_configure_iface *sci)
     sci->send_configure("map_curve", var_map_curve.c_str());
 }
 
-const char **organ_audio_module::get_default_configure_vars()
-{
-    static const char *data[] = { "map_curve", "2\n0 1\n1 1\n", NULL };
-    return data;
-}
-
-plugin_command_info *organ_audio_module::get_commands()
-{
-    static plugin_command_info cmds[] = {
-        { "cmd_panic", "Panic!", "Stop all sounds and reset all controllers" },
-        { NULL }
-    };
-    return cmds;
-}
diff --git a/src/preset.cpp b/src/preset.cpp
index 42464ca..c4bb56e 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -29,9 +29,11 @@
 #include <expat.h>
 #include <calf/preset.h>
 #include <calf/giface.h>
+#include <calf/utils.h>
 
 using namespace synth;
 using namespace std;
+using namespace calf_utils;
 
 extern synth::preset_list &synth::get_builtin_presets()
 {
diff --git a/src/utils.cpp b/src/utils.cpp
index b1b6b4b..68799a1 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -23,11 +23,12 @@
 #include <calf/osctl.h>
 #include <calf/utils.h>
 
-using namespace calf_utils;
 using namespace std;
 using namespace osctl;
 
-string calf_utils::encodeMap(const dictionary &data)
+namespace calf_utils {
+
+string encode_map(const dictionary &data)
 {
     osctl::string_buffer sb;
     osc_stream<osctl::string_buffer> str(sb);
@@ -39,7 +40,7 @@ string calf_utils::encodeMap(const dictionary &data)
     return sb.data;
 }
 
-void calf_utils::decodeMap(dictionary &data, const string &src)
+void decode_map(dictionary &data, const string &src)
 {
     osctl::string_buffer sb(src);
     osc_stream<osctl::string_buffer> str(sb);
@@ -54,3 +55,35 @@ void calf_utils::decodeMap(dictionary &data, const string &src)
         data[tmp] = tmp2;
     }
 }
+
+std::string xml_escape(const std::string &src)
+{
+    string dest;
+    for (size_t i = 0; i < src.length(); i++) {
+        // XXXKF take care of string encoding
+        if (src[i] < 0 || src[i] == '"' || src[i] == '<' || src[i] == '>' || src[i] == '&')
+            dest += "&"+i2s((uint8_t)src[i])+";";
+        else
+            dest += src[i];
+    }
+    return dest;
+}
+
+
+std::string i2s(int value)
+{
+    char buf[32];
+    sprintf(buf, "%d", value);
+    
+    return std::string(buf);
+}
+
+std::string f2s(double value)
+{
+    // XXXKF might not work with some locale settings
+    char buf[64];
+    sprintf(buf, "%g", value);
+    return buf;
+}
+
+}

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list