[SCM] calf/master: + Control port names are stored with other parameters (the other port names are stored in a separate array, port_names) + It is possible to run several plugins in one calfjackhost at the same time; it's very primitive, but so is the whole calfjackhost

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:36:46 UTC 2013


The following commit has been merged in the master branch:
commit 3f4c1f476a5e9d4af380da070e8bd3e139ead3bd
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Thu Dec 20 22:44:43 2007 +0000

    + Control port names are stored with other parameters (the other port names are stored in a separate array, port_names)
    + It is possible to run several plugins in one calfjackhost at the same time; it's very primitive, but so is the whole calfjackhost
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@31 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 69f263a..65390aa 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -84,6 +84,7 @@ struct parameter_properties
     float def_value, min, max, step;
     uint32_t flags;
     const char **choices;
+    const char *short_name, *name;
     float from_01(float value01) const;
     float to_01(float value) const;
     std::string to_string(float value) const;
@@ -156,7 +157,7 @@ struct ladspa_wrapper
         descriptor.Copyright = i.copyright;
         descriptor.Properties = Module::rt_capable ? LADSPA_PROPERTY_HARD_RT_CAPABLE : 0;
         descriptor.PortCount = ins + outs + params;
-        descriptor.PortNames = Module::param_names;
+        descriptor.PortNames = new char *[descriptor.PortCount];
         descriptor.PortDescriptors = new LADSPA_PortDescriptor[descriptor.PortCount];
         descriptor.PortRangeHints = new LADSPA_PortRangeHint[descriptor.PortCount];
         for (int i = 0; i < ins + outs + params; i++)
@@ -165,11 +166,13 @@ struct ladspa_wrapper
             ((int *)descriptor.PortDescriptors)[i] = i < ins ? LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO
                                                   : i < ins + outs ? LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO
                                                                    : LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
-            if (i < ins + outs)
+            if (i < ins + outs) {
                 prh.HintDescriptor = 0;
-            else {            
+                ((const char **)descriptor.PortNames)[i] = Module::port_names[i];
+            } else {            
                 prh.HintDescriptor = LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW;
                 parameter_properties &pp = Module::param_props[i - ins - outs];
+                ((const char **)descriptor.PortNames)[i] = pp.name;
                 prh.LowerBound = pp.min;
                 prh.UpperBound = pp.max;
                 switch(pp.flags & PF_TYPEMASK) {
@@ -350,7 +353,7 @@ struct ladspa_wrapper
     }
     
     std::string generate_rdf() {
-        return synth::generate_ladspa_rdf(info, Module::param_props, Module::param_names, Module::param_count, Module::in_count + Module::out_count);
+        return synth::generate_ladspa_rdf(info, Module::param_props, (const char **)descriptor.PortNames, Module::param_count, Module::in_count + Module::out_count);
     };
 };
 
diff --git a/src/calf/gui.h b/src/calf/gui.h
index e6d5dc9..3fd9cc0 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -58,7 +58,6 @@ struct plugin_ctl_iface
     virtual float get_param_value(int param_no) = 0;
     virtual void set_param_value(int param_no, float value) = 0;
     virtual int get_param_count() = 0;
-    virtual const char ** get_param_names()=0;
     virtual ~plugin_ctl_iface() {}
 };
 
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 85dccd1..17f1f3b 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -31,6 +31,61 @@
 
 namespace synth {
 
+class jack_host_base;
+    
+class jack_client {
+public:
+    jack_client_t *client;
+    int input_nr, output_nr, midi_nr;
+    std::string input_name, output_name, midi_name;
+    std::vector<jack_host_base *> plugins;
+    int sample_rate;
+
+    jack_client()
+    {
+        input_nr = output_nr = midi_nr = 1;
+        input_name = "input_%d";
+        output_name = "output_%d";
+        midi_name = "midi_%d";
+        sample_rate = 0;
+        client = NULL;
+    }
+    
+    void add(jack_host_base *plugin)
+    {
+        plugins.push_back(plugin);
+    }
+    
+    void open(const char *client_name)
+    {
+        jack_status_t status;
+        client = jack_client_open(client_name, JackNullOption, &status);
+        if (!client)
+            throw audio_exception("Could not initialize Jack subsystem");
+        sample_rate = jack_get_sample_rate(client);
+        jack_set_process_callback(client, do_jack_process, this);
+        jack_set_buffer_size_callback(client, do_jack_bufsize, this);
+    }
+    
+    void activate()
+    {
+        jack_activate(client);        
+    }
+
+    void deactivate()
+    {
+        jack_deactivate(client);        
+    }
+    
+    void close()
+    {
+        jack_client_close(client);
+    }
+    
+    static int do_jack_process(jack_nframes_t nframes, void *p);
+    static int do_jack_bufsize(jack_nframes_t numsamples, void *p);
+};
+    
 class jack_host_base: public plugin_ctl_iface {
 public:
     typedef int (*process_func)(jack_nframes_t nframes, void *p);
@@ -40,9 +95,7 @@ public:
         port() : handle(NULL), data(NULL) {}
         ~port() { }
     };
-    jack_client_t *client;
-    jack_status_t status;
-    int sample_rate;
+    jack_client *client;
     bool changed;
     port midi_port;
     virtual int get_input_count()=0;
@@ -52,12 +105,11 @@ public:
     virtual float *get_params()=0;
     virtual void init_module()=0;
     virtual void cache_ports()=0;
-    virtual process_func get_process_func()=0;
     virtual bool get_midi()=0;
+    virtual int process(jack_nframes_t nframes)=0;
     
     jack_host_base() {
         client = NULL;
-        sample_rate = 0;
         changed = true;
     }
     
@@ -70,62 +122,47 @@ public:
         changed = true;
     }
     
-    void open(const char *client_name, const char *in_prefix, const char *out_prefix, const char *midi_name)
+    void open(jack_client *_client)
     {
-        client = jack_client_open(client_name, JackNullOption, &status);
-        
-        if (!client)
-            throw audio_exception("Could not initialize Jack subsystem");
-        
-        sample_rate = jack_get_sample_rate(client);
+        client = _client; //jack_client_open(client_name, JackNullOption, &status);
         
-        create_ports(in_prefix, out_prefix, midi_name);
+        create_ports();
         
         cache_ports();
         
-        jack_set_process_callback(client, get_process_func(), this);
-        jack_set_buffer_size_callback(client, do_jack_bufsize, this);
-
         init_module();
         changed = false;
-
-        jack_activate(client);        
     }
     
-    virtual void create_ports(const char *in_prefix, const char *out_prefix, const char *midi_name) {
+    virtual void create_ports() {
         char buf[32];
         port *inputs = get_inputs();
         port *outputs = get_outputs();
         int in_count = get_input_count(), out_count = get_output_count();
         for (int i=0; i<in_count; i++) {
-            sprintf(buf, "%s%d", in_prefix, i+1);
-            inputs[i].handle = jack_port_register(client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
+            sprintf(buf, client->input_name.c_str(), client->input_nr++);
+            inputs[i].handle = jack_port_register(client->client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
             inputs[i].data = NULL;
         }
         for (int i=0; i<out_count; i++) {
-            sprintf(buf, "%s%d", out_prefix, i+1);
-            outputs[i].handle = jack_port_register(client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0);
+            sprintf(buf, client->output_name.c_str(), client->output_nr++);
+            outputs[i].handle = jack_port_register(client->client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0);
             outputs[i].data = NULL;
         }
-        if (get_midi())
-            midi_port.handle = jack_port_register(client, midi_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
-    }
-    
-    static int do_jack_bufsize(jack_nframes_t numsamples, void *p) {
-        jack_host_base *app = (jack_host_base *)p;
-        app->cache_ports();
-        return 0;
+        if (get_midi()) {
+            sprintf(buf, client->midi_name.c_str(), client->midi_nr++);
+            midi_port.handle = jack_port_register(client->client, buf, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
+        }
     }
     
     void close() {
-        jack_client_close(client);
-        client = NULL;
         port *inputs = get_inputs(), *outputs = get_outputs();
         int input_count = get_input_count(), output_count = get_output_count();
         for (int i = 0; i < input_count; i++)
             inputs[i].data = NULL;
         for (int i = 0; i < output_count; i++)
             outputs[i].data = NULL;
+        client = NULL;
     }
 
     virtual ~jack_host_base() {
@@ -150,47 +187,46 @@ public:
     }
     
     virtual void init_module() {
-        module.set_sample_rate(sample_rate);
+        module.set_sample_rate(client->sample_rate);
         module.activate();
         module.params_changed();
     }
 
     virtual synth::parameter_properties* get_param_props(int param_no) { return Module::param_props + param_no; }
     
-    static void handle_event(Module *module, uint8_t *buffer, uint32_t size)
+    void handle_event(uint8_t *buffer, uint32_t size)
     {
         int value;
         switch(buffer[0] >> 4)
         {
         case 8:
-            module->note_off(buffer[1], buffer[2]);
+            module.note_off(buffer[1], buffer[2]);
             break;
         case 9:
-            module->note_on(buffer[1], buffer[2]);
+            module.note_on(buffer[1], buffer[2]);
             break;
         case 10:
-            module->program_change(buffer[1]);
+            module.program_change(buffer[1]);
             break;
         case 11:
-            module->control_change(buffer[1], buffer[2]);
+            module.control_change(buffer[1], buffer[2]);
             break;
         case 14:
             value = buffer[1] + 128 * buffer[2] - 8192;
-            module->pitch_bend(value);
+            module.pitch_bend(value);
             break;
         }
     }
-    static int do_jack_process(jack_nframes_t nframes, void *p) {
-        jack_host *host = (jack_host *)p;
-        Module *module = &host->module;
+    int process(jack_nframes_t nframes)
+    {
         for (int i=0; i<Module::in_count; i++) {
-            module->ins[i] = host->inputs[i].data = (float *)jack_port_get_buffer(host->inputs[i].handle, 0);
+            module.ins[i] = inputs[i].data = (float *)jack_port_get_buffer(inputs[i].handle, 0);
         }
         if (Module::support_midi)
-            host->midi_port.data = (float *)jack_port_get_buffer(host->midi_port.handle, 0);
-        if (host->changed) {
-            module->params_changed();
-            host->changed = false;
+            midi_port.data = (float *)jack_port_get_buffer(midi_port.handle, 0);
+        if (changed) {
+            module.params_changed();
+            changed = false;
         }
 
         unsigned int time = 0;
@@ -199,33 +235,33 @@ public:
         {
             jack_midi_event_t event;
 #ifdef OLD_JACK
-            int count = jack_midi_get_event_count(host->midi_port.data, nframes);
+            int count = jack_midi_get_event_count(midi_port.data, nframes);
 #else
-            int count = jack_midi_get_event_count(host->midi_port.data);
+            int count = jack_midi_get_event_count(midi_port.data);
 #endif
             for (int i = 0; i < count; i++)
             {
 #ifdef OLD_JACK
-                jack_midi_event_get(&event, host->midi_port.data, i, nframes);
+                jack_midi_event_get(&event, midi_port.data, i, nframes);
 #else
-                jack_midi_event_get(&event, host->midi_port.data, i);
+                jack_midi_event_get(&event, midi_port.data, i);
 #endif
-                mask = module->process(time, event.time - time, -1, -1);
+                mask = module.process(time, event.time - time, -1, -1);
                 for (int i = 0; i < Module::out_count; i++) {
                     if (!(mask & (1 << i)))
-                        dsp::zero(module->outs[i] + time, event.time - time);
+                        dsp::zero(module.outs[i] + time, event.time - time);
                 }
                 
-                handle_event(module, event.buffer, event.size);
+                handle_event(event.buffer, event.size);
                 
                 time = event.time;
             }
         }
-        mask = module->process(time, nframes - time, -1, -1);
+        mask = module.process(time, nframes - time, -1, -1);
         for (int i = 0; i < Module::out_count; i++) {
             // zero unfilled outputs
             if (!(mask & (1 << i)))
-                dsp::zero(module->outs[i] + time, nframes - time);
+                dsp::zero(module.outs[i] + time, nframes - time);
         }
         return 0;
     }
@@ -248,8 +284,6 @@ public:
     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 process_func get_process_func() { return do_jack_process; }
-    virtual const char ** get_param_names() { return Module::param_names + Module::in_count + Module::out_count; }
     virtual bool get_midi() { return Module::support_midi; }
     virtual float get_param_value(int param_no) {
         return params[param_no];
@@ -260,6 +294,8 @@ public:
     }
 };
 
+extern jack_host_base *create_jack_host(const char *name);
+
 #endif
 
 };
diff --git a/src/calf/modules.h b/src/calf/modules.h
index ce431a7..15ceaf9 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -52,7 +52,7 @@ public:
     float *outs[2];
     float *params[1];
     uint32_t srate;
-    static const char *param_names[];
+    static const char *port_names[];
     static parameter_properties param_props[];
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         if (!inputs_mask)
@@ -72,7 +72,7 @@ class flanger_audio_module: public null_audio_module
 public:
     enum { par_delay, par_depth, par_rate, par_fb, par_amount, param_count };
     enum { in_count = 2, out_count = 2, support_midi = false, rt_capable = true };
-    static const char *param_names[];
+    static const char *port_names[];
     dsp::simple_flanger<float, 2048> left, right;
     float *ins[in_count]; 
     float *outs[out_count];
@@ -116,7 +116,7 @@ class reverb_audio_module: public null_audio_module
 public:    
     enum { par_decay, par_hfdamp, par_amount, param_count };
     enum { in_count = 2, out_count = 2, support_midi = false, rt_capable = true };
-    static const char *param_names[];
+    static const char *port_names[];
     dsp::reverb<float> reverb;
     uint32_t srate;
     float *ins[in_count]; 
@@ -161,7 +161,7 @@ public:
     float *ins[in_count]; 
     float *outs[out_count];
     float *params[param_count];
-    static const char *param_names[];
+    static const char *port_names[];
     dsp::biquad<float> left[3], right[3];
     uint32_t srate;
     static parameter_properties param_props[];
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index fda0bba..0724d97 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -42,7 +42,7 @@ public:
     enum { par_drawbar1, par_drawbar2, par_drawbar3, par_drawbar4, par_drawbar5, par_drawbar6, par_drawbar7, par_drawbar8, par_drawbar9, par_foldover,
         par_percmode, par_percharm, par_vibrato, par_master, param_count };
     enum { in_count = 0, out_count = 2, support_midi = true, rt_capable = true };
-    static const char *param_names[];
+    static const char *port_names[];
     float *ins[in_count]; 
     float *outs[out_count];
     float *params[param_count];
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index bb5e0d6..bf094d4 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -40,7 +40,7 @@ public:
     enum { par_wave1, par_wave2, par_detune, par_osc2xpose, par_oscmode, par_oscmix, par_filtertype, par_cutoff, par_resonance, par_cutoffsep, par_envmod, par_envtores, par_attack, par_decay, par_sustain, par_release, par_keyfollow, par_legato, par_portamento, par_vel2amp, par_vel2filter, param_count };
     enum { in_count = 0, out_count = 2, support_midi = true, rt_capable = true };
     enum { step_size = 64 };
-    static const char *param_names[];
+    static const char *port_names[];
     float *ins[in_count]; 
     float *outs[out_count];
     float *params[param_count];
diff --git a/src/giface.cpp b/src/giface.cpp
index 01d122b..26fbc4f 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -192,9 +192,9 @@ std::string synth::generate_ladspa_rdf(const ladspa_info &info, parameter_proper
     for (unsigned int i = 0; i < count; i++) {
         rdf += 
             "    <ladspa:hasPort>\n"
-            "      <ladspa:InputControlPort rdf:about=\"" + plugin_id + "."+i2s(i )+"\" "
+            "      <ladspa:InputControlPort rdf:about=\"" + plugin_id + "."+i2s(i)+"\" "
             + unit_to_string(params[i]) +
-            "ladspa:hasLabel=\"par_"+i2s(i + ctl_ofs)+"\" "
+            "ladspa:hasLabel=\"" + params[i].short_name + "\" "
             + scale_to_string(params[i]) + 
             ">\n"
             "    </ladspa:hasPort>\n";
diff --git a/src/gui.cpp b/src/gui.cpp
index c87ebc9..45c720e 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -222,11 +222,11 @@ GtkWidget *plugin_gui::create(plugin_ctl_iface *_plugin, const char *title)
     
     for (int i = 0; i < param_count; i++) {
         int trow = i;
-        GtkWidget *label = gtk_label_new (plugin->get_param_names()[i]);
+        parameter_properties &props = *plugin->get_param_props(i);
+        GtkWidget *label = gtk_label_new (props.name);
         gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
         gtk_table_attach (GTK_TABLE (table), label, 0, 1, trow, trow + 1, GTK_FILL, GTK_FILL, 2, 2);
         
-        parameter_properties &props = *plugin->get_param_props(i);
         
         GtkWidget *widget = NULL;
         
@@ -367,7 +367,7 @@ void plugin_gui_window::create(plugin_ctl_iface *_jh, const char *title, const c
     toplevel = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL));
     GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(false, 5));
     
-    gtk_window_set_title(GTK_WINDOW (toplevel), (string(title) + " - " + effect).c_str());
+    gtk_window_set_title(GTK_WINDOW (toplevel), title);
     gtk_container_add(GTK_CONTAINER(toplevel), GTK_WIDGET(vbox));
 
     gui = new plugin_gui(this);
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index fe70d3f..9ca4034 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -40,11 +40,27 @@ using namespace std;
 // I don't need anyone to tell me this is stupid. I already know that :)
 plugin_gui_window *gui_win;
 
-const char *effect_name = "flanger";
+jack_client client;
+
 const char *client_name = "calfhost";
-const char *input_name = "input";
-const char *output_name = "output";
-const char *midi_name = "midi";
+
+jack_host_base *synth::create_jack_host(const char *effect_name)
+{
+    if (!strcmp(effect_name, "reverb"))
+        return new jack_host<reverb_audio_module>();
+    else if (!strcmp(effect_name, "flanger"))
+        return new jack_host<flanger_audio_module>();
+    else if (!strcmp(effect_name, "filter"))
+        return new jack_host<filter_audio_module>();
+    else if (!strcmp(effect_name, "monosynth"))
+        return new jack_host<monosynth_audio_module>();
+#ifdef ENABLE_EXPERIMENTAL
+    else if (!strcmp(effect_name, "organ"))
+        return new jack_host<organ_audio_module>();
+#endif
+    else
+        return NULL;
+}
 
 void destroy(GtkWindow *window, gpointer data)
 {
@@ -55,87 +71,118 @@ static struct option long_options[] = {
     {"help", 0, 0, 'h'},
     {"version", 0, 0, 'v'},
     {"client", 1, 0, 'c'},
-    {"effect", 1, 0, 'e'},
-    {"plugin", 1, 0, 'p'},
+    {"effect", 0, 0, 'e'},
+    {"plugin", 0, 0, 'p'},
     {"input", 1, 0, 'i'},
     {"output", 1, 0, 'o'},
     {0,0,0,0},
 };
 
+void print_help(char *argv[])
+{
+    printf("JACK host for Calf effects\n"
+        "Syntax: %s [--client <name>] [--input <name>] [--output <name>] [--midi <name>]\n"
+        "       [--help] [--version] pluginname ...\n", 
+        argv[0]);
+}
+
+int jack_client::do_jack_process(jack_nframes_t nframes, void *p)
+{
+    jack_client *self = (jack_client *)p;
+    for(unsigned int i = 0; i < self->plugins.size(); i++)
+        self->plugins[i]->process(nframes);
+    return 0;
+}
+
+int jack_client::do_jack_bufsize(jack_nframes_t numsamples, void *p)
+{
+    jack_client *self = (jack_client *)p;
+    for(unsigned int i = 0; i < self->plugins.size(); i++)
+        self->plugins[i]->cache_ports();
+    return 0;
+}
+
 int main(int argc, char *argv[])
 {
+    vector<string> names;
+    vector<jack_host_base *> hosts;
+    vector<plugin_gui_window *> guis;
     gtk_init(&argc, &argv);
     glade_init();
     while(1) {
         int option_index;
-        int c = getopt_long(argc, argv, "c:e:i:o:m:p:hv", long_options, &option_index);
+        int c = getopt_long(argc, argv, "c:i:o:m:ephv", long_options, &option_index);
         if (c == -1)
             break;
         switch(c) {
             case 'h':
             case '?':
-                printf("JACK host for Calf effects\n"
-                    "Syntax: %s [--plugin reverb|flanger|filter|monosynth] [--client <name>] [--input <name>]"
-                    "       [--output <name>] [--midi <name>] [--help] [--version]\n", 
-                    argv[0]);
+                print_help(argv);
                 return 0;
             case 'v':
                 printf("%s\n", PACKAGE_STRING);
                 return 0;
             case 'e':
             case 'p':
-                effect_name = optarg;
+                fprintf(stderr, "Warning: switch -%c is deprecated!\n", c);
                 break;
             case 'c':
                 client_name = optarg;
                 break;
             case 'i':
-                input_name = optarg;
+                client.input_name = string(optarg) + "_%d";
                 break;
             case 'o':
-                output_name = optarg;
+                client.output_name = string(optarg) + "_%d";
                 break;
             case 'm':
-                midi_name = optarg;
+                client.midi_name = string(optarg) + "_%d";
                 break;
         }
     }
+    while(optind < argc)
+        names.push_back(argv[optind++]);
+    if (!names.size()) {
+        print_help(argv);
+        return 0;
+    }
     try {
         struct stat st;
         if (!stat(get_preset_filename().c_str(), &st))
             load_presets(get_preset_filename().c_str());
         else if (!stat(PKGLIBDIR "/presets.xml", &st))
             load_presets(PKGLIBDIR "/presets.xml");
-        jack_host_base *jh = NULL;
-        if (!strcmp(effect_name, "reverb"))
-            jh = new jack_host<reverb_audio_module>();
-        else if (!strcmp(effect_name, "flanger"))
-            jh = new jack_host<flanger_audio_module>();
-        else if (!strcmp(effect_name, "filter"))
-            jh = new jack_host<filter_audio_module>();
-        else if (!strcmp(effect_name, "monosynth"))
-            jh = new jack_host<monosynth_audio_module>();
-#ifdef ENABLE_EXPERIMENTAL
-        else if (!strcmp(effect_name, "organ"))
-            jh = new jack_host<organ_audio_module>();
-#endif
-        else {
-#ifdef ENABLE_EXPERIMENTAL
-            fprintf(stderr, "Unknown plugin name; allowed are: reverb, flanger, filter, monosynth, organ\n");
-#else
-            fprintf(stderr, "Unknown plugin name; allowed are: reverb, flanger, filter, monosynth\n");
-#endif
-            return 1;
+        
+        client.open(client_name);
+        for (unsigned int i = 0; i < names.size(); i++) {
+            jack_host_base *jh = create_jack_host(names[i].c_str());
+            if (!jh) {
+    #ifdef ENABLE_EXPERIMENTAL
+                fprintf(stderr, "Unknown plugin name; allowed are: reverb, flanger, filter, monosynth, organ\n");
+    #else
+                fprintf(stderr, "Unknown plugin name; allowed are: reverb, flanger, filter, monosynth\n");
+    #endif
+                return 1;
+            }
+            jh->open(&client);
+            gui_win = new plugin_gui_window;
+            gui_win->create(jh, (string(client_name)+" - "+names[i]).c_str(), names[i].c_str());
+            gtk_signal_connect(GTK_OBJECT(gui_win->toplevel), "destroy", G_CALLBACK(destroy), NULL);
+            guis.push_back(gui_win);
+            hosts.push_back(jh);
+            client.add(jh);
         }
-        jh->open(client_name, input_name, output_name, midi_name);
-        gui_win = new plugin_gui_window;
-        gui_win->create(jh, client_name, effect_name);
-        gtk_signal_connect(GTK_OBJECT(gui_win->toplevel), "destroy", G_CALLBACK(destroy), NULL);
+        client.activate();
         gtk_main();
-        delete gui_win;
-        jh->close();
+        client.deactivate();
+        for (unsigned int i = 0; i < names.size(); i++) {
+            delete guis[i];
+            hosts[i]->close();
+            delete hosts[i];
+        }
+        client.close();
+        
         save_presets(get_preset_filename().c_str());
-        delete jh;
     }
     catch(std::exception &e)
     {
diff --git a/src/modules.cpp b/src/modules.cpp
index 1d45358..620567a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -31,10 +31,10 @@ using namespace synth;
 
 const char *copyright = "(C) 2001-2007 Krzysztof Foltman, license: LGPL";
 
-const char *amp_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Gain"};
+const char *amp_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
 parameter_properties amp_audio_module::param_props[] = {
-    { 1, 0, 4, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL }
+    { 1, 0, 4, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL, "gain", "Gain" }
 };
 
 static synth::ladspa_info amp_info = { 0x847c, "Amp", "Calf Const Amp", "Krzysztof Foltman", copyright, "AmplifierPlugin" };
@@ -45,14 +45,14 @@ static synth::ladspa_wrapper<amp_audio_module> amp(amp_info);
 
 ////////////////////////////////////////////////////////////////////////////
 
-const char *flanger_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Minimum delay", "Modulation depth", "Modulation rate", "Feedback", "Amount"};
+const char *flanger_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
 parameter_properties flanger_audio_module::param_props[] = {
-    { 0.1,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
-    { 0.5,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
-    { 0.25,    0.01, 20, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
-    { 0.90,   -0.99, 0.99, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
-    { 1, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
+    { 0.1,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "min_delay", "Minimum delay" },
+    { 0.5,      0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "mod_depth", "Modulation depth" },
+    { 0.25,    0.01, 20, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "mod_rate", "Modulation rate" },
+    { 0.90,   -0.99, 0.99, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "feedback", "Feedback" },
+    { 1, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
 };
 
 static synth::ladspa_info flanger_info = { 0x847d, "Flanger", "Calf Flanger", "Krzysztof Foltman", copyright, "FlangerPlugin" };
@@ -63,12 +63,12 @@ static synth::ladspa_wrapper<flanger_audio_module> flanger(flanger_info);
 
 ////////////////////////////////////////////////////////////////////////////
 
-const char *reverb_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Decay time", "HF Damp", "Amount"};
+const char *reverb_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
 parameter_properties reverb_audio_module::param_props[] = {
-    { 1.5,      1.0,  4.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL },
-    { 5000,    2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
-    { 0.25,       0,    2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
+    { 1.5,      1.0,  4.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "decay_time", "Decay time" },
+    { 5000,    2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hf_damp", "High Frq Damp" },
+    { 0.25,       0,    2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
 };
 
 static synth::ladspa_info reverb_info = { 0x847e, "Reverb", "Calf Reverb", "Krzysztof Foltman", copyright, "ReverbPlugin" };
@@ -79,7 +79,7 @@ static synth::ladspa_wrapper<reverb_audio_module> reverb(reverb_info);
 
 ////////////////////////////////////////////////////////////////////////////
 
-const char *filter_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Frequency", "Resonance", "Mode", "Inertia"};
+const char *filter_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
 
 const char *filter_choices[] = {
     "12dB/oct Lowpass",
@@ -91,10 +91,10 @@ const char *filter_choices[] = {
 };
 
 parameter_properties filter_audio_module::param_props[] = {
-    { 2000,      10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
-    { 0.707,  0.707,   20,  1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
-    { 0,          0,    5,    1, PF_ENUM | PF_CTL_COMBO, filter_choices },
-    { 20,         5,  100,    1, PF_INT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL},
+    { 2000,      10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Frequency" },
+    { 0.707,  0.707,   20,  1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "res", "Resonance" },
+    { 0,          0,    5,    1, PF_ENUM | PF_CTL_COMBO, filter_choices, "mode", "Mode" },
+    { 20,         5,  100,    1, PF_INT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "inertia", "Inertia"},
 };
 
 static synth::ladspa_info filter_info = { 0x847f, "Filter", "Calf Filter", "Krzysztof Foltman", copyright, "FilterPlugin" };
@@ -105,29 +105,29 @@ static synth::ladspa_wrapper<filter_audio_module> filter(filter_info);
 
 ////////////////////////////////////////////////////////////////////////////
 #ifdef ENABLE_EXPERIMENTAL
-const char *organ_audio_module::param_names[] = {"Out L", "Out R", "16'", "5 1/3'", "8'", "4'", "2 2/3'", "2'", "1 3/5'", "1 1/3'", "1'", "Foldover", "Perc Mode", "Perc Harm", "Vibrato Speed", "Master Volume"};
+const char *organ_audio_module::port_names[] = {"Out L", "Out R"};
 
 const char *organ_percussion_mode_names[] = { "Off", "Short", "Long" };
 const char *organ_percussion_harmonic_names[] = { "2nd", "3rd" };
 const char *organ_vibrato_speed_names[] = { "Off", "Swell", "Tremolo", "HoldPedal", "ModWheel" };
 
 parameter_properties organ_audio_module::param_props[] = {
-    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL },
-
-    { 1,         0,  1, 1.01, PF_BOOL | PF_CTL_TOGGLE, NULL },
-    { 1,         0,  2, 1.01, PF_ENUM | PF_CTL_COMBO, organ_percussion_mode_names },
-    { 3,         2,  3, 1.01, PF_ENUM | PF_CTL_COMBO, organ_percussion_harmonic_names },
-    { 1,         0,  4, 1.01, PF_ENUM | PF_CTL_COMBO, organ_vibrato_speed_names },
-
-    { 0.2,         0,  1, 1.01, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL },
+    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h1", "16'" },
+    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h3", "5 1/3'" },
+    { 0.3,       0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h2", "8'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h4", "4'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h6", "2 2/3'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h8", "2'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h10", "1 3/5'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h12", "1 1/3'" },
+    { 0,         0,  1, 1.01, PF_FLOAT | PF_SCALE_QUAD | PF_CTL_FADER, NULL, "h16", "1'" },
+
+    { 1,         0,  1, 1.01, PF_BOOL | PF_CTL_TOGGLE, NULL, "foldover", "Foldover" },
+    { 1,         0,  2, 1.01, PF_ENUM | PF_CTL_COMBO, organ_percussion_mode_names, "perc mode", "Perc. mode" },
+    { 3,         2,  3, 1.01, PF_ENUM | PF_CTL_COMBO, organ_percussion_harmonic_names, "perc_hrm", "Perc. harmonic" },
+    { 1,         0,  4, 1.01, PF_ENUM | PF_CTL_COMBO, organ_vibrato_speed_names, "vib_speed", "Vibrato mode" },
+
+    { 0.2,         0,  1, 1.01, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL, "amount", "Amount" },
 };
 
 static synth::ladspa_info organ_info = { 0x8481, "Organ", "Calf Organ", "Krzysztof Foltman", copyright, "SynthesizerPlugin" };
@@ -139,13 +139,9 @@ static synth::ladspa_wrapper<organ_audio_module> organ(organ_info);
 #endif
 ////////////////////////////////////////////////////////////////////////////
 
-const char *monosynth_audio_module::param_names[] = {
+const char *monosynth_audio_module::port_names[] = {
     "Out L", "Out R", 
-    "Osc1 Wave", "Osc2 Wave", "Osc 1/2 Detune", "Osc 2 Transpose", "Phase Mode", "Osc Mix", 
-    "Filter", "Cutoff", "Resonance", "Separation", "Env->Cutoff", "Env->Res", 
-    "Attack", "Decay", "Sustain", "Release", 
-    "Key Follow", "Legato", "Portamento", 
-    "Vel->Amp", "Vel->Filter"};
+};
 
 const char *monosynth_waveform_names[] = { "Sawtooth", "Square", "Pulse", "Sine", "Triangle" };
 const char *monosynth_mode_names[] = { "0 : 0", "0 : 180", "0 : 90", "90 : 90", "90 : 270", "Random" };
@@ -163,30 +159,30 @@ const char *monosynth_filter_choices[] = {
 };
 
 parameter_properties monosynth_audio_module::param_props[] = {
-    { wave_saw,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names },
-    { wave_sqr,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names },
-    { 10,         0,  100, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL },
-    { 12,       -24,   24, 1.01, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL },
-    { 0,          0,    5, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_mode_names },
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL },
-    { 1,          0,    7, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_filter_choices },
-    { 33,        10,16000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
-    { 2,        0.7,    8, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
-    { 0,      -2400, 2400, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL },
-    { 8000,  -10800,10800, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL },
-    { 1,          0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL },
+    { wave_saw,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names, "o1_wave", "Osc1 Wave" },
+    { wave_sqr,         0, wave_count - 1, 1, PF_ENUM | PF_CTL_COMBO, monosynth_waveform_names, "o2_wave", "Osc2 Wave" },
+    { 10,         0,  100, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "osc_detune", "O1<>2 Detune" },
+    { 12,       -24,   24, 1.01, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "osc_xpose", "Osc transpose" },
+    { 0,          0,    5, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_mode_names, "phase_mode", "Phase mode" },
+    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL, "o12_mix", "O1<>2 Mix" },
+    { 1,          0,    7, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_filter_choices, "filter", "Filter" },
+    { 33,        10,16000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "cutoff", "Cutoff" },
+    { 2,        0.7,    8, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL, "res", "Resonance" },
+    { 0,      -2400, 2400, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "filter_sep", "Separation" },
+    { 8000,  -10800,10800, 1.01, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "e2cutoff", "Env->Cutoff" },
+    { 1,          0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "e2res", "Env->Res" },
     
-    { 1,          1,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
-    { 350,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
-    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL },
-    { 50,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
+    { 1,          1,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_a", "Attack" },
+    { 350,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_d", "Decay" },
+    { 0.5,        0,    1, 1.01, PF_FLOAT | PF_SCALE_PERC, NULL, "adsr_s", "Sustain" },
+    { 50,       10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "adsr_r", "Release" },
     
-    { 0,          0,    1, 1.01, PF_BOOL | PF_CTL_TOGGLE, NULL },
-    { 0,          0,    3, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_legato_names },
-    { 1,          1, 2000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
+    { 0,          0,    1, 1.01, PF_BOOL | PF_CTL_TOGGLE, NULL, "key_follow", "Key Follow" },
+    { 0,          0,    3, 1.01, PF_ENUM | PF_CTL_COMBO, monosynth_legato_names, "legato", "Legato Mode" },
+    { 1,          1, 2000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "portamento", "Portamento" },
     
-    { 0,          0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL },
-    { 0.5,        0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL },
+    { 0,          0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "vel2amp", "Vel->Amp" },
+    { 0.5,        0,    1,  0.1, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL, "vel2flt", "Vel->Filter" },
 };
 
 static synth::ladspa_info monosynth_info = { 0x8480, "Monosynth", "Calf Monosynth", "Krzysztof Foltman", copyright, "SynthesizerPlugin" };
diff --git a/src/preset_gui.cpp b/src/preset_gui.cpp
index 3736f62..4447bbf 100644
--- a/src/preset_gui.cpp
+++ b/src/preset_gui.cpp
@@ -46,7 +46,7 @@ void store_preset_ok(GtkAction *action, plugin_gui *gui)
     sp.plugin = gui->effect_name;
     int count = gui->plugin->get_param_count();
     for (int i = 0; i < count; i++) {
-        sp.param_names.push_back(gui->plugin->get_param_names()[i]);
+        sp.param_names.push_back(gui->plugin->get_param_props(i)->name);
         sp.values.push_back(gui->plugin->get_param_value(i));
     }
     add_preset(sp);
@@ -83,7 +83,7 @@ void synth::activate_preset(GtkAction *action, activate_preset_params *params)
     map<string, int> names;
     int count = gui->plugin->get_param_count();
     for (int i = 0; i < count; i++) 
-        names[gui->plugin->get_param_names()[i]] = i;
+        names[gui->plugin->get_param_props(i)->name] = i;
     // no support for unnamed parameters... tough luck :)
     for (unsigned int i = 0; i < min(p.param_names.size(), p.values.size()); i++)
     {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list