[SCM] calf/master: + JackHost: started implementing LASH support + x86-64 fixes

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


The following commit has been merged in the master branch:
commit f6c5e1dea3d50db54b3bf22c4502b13263ab74ac
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Wed Jan 9 19:43:35 2008 +0000

    + JackHost: started implementing LASH support
    + x86-64 fixes
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@82 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/configure.in b/configure.in
index 61d35eb..4a7c28b 100644
--- a/configure.in
+++ b/configure.in
@@ -55,6 +55,7 @@ AC_SUBST(JACK_DEPS_CFLAGS)
 AC_SUBST(JACK_DEPS_LIBS)
 
 PKG_CHECK_MODULES(LV2_DEPS, lv2core >= 1, LV2_ENABLED="yes", LV2_ENABLED="no")
+PKG_CHECK_MODULES(LASH_DEPS, lash-1.0 >= 0.5.0, LASH_ENABLED="yes", LASH_ENABLED="no")
 
 PHAT_ENABLED="no"
 if test "$JACK_FOUND" = "yes" -o "$DSSI_FOUND" = "yes" -o "$LV2_ENABLED" = "yes"; then
@@ -106,6 +107,7 @@ AM_CONDITIONAL(USE_LV2, test "$LV2_ENABLED" = "yes")
 AM_CONDITIONAL(USE_GUI, test "$GUI_ENABLED" = "yes")
 AM_CONDITIONAL(USE_DSSI_GUI, test "$DSSI_GUI_ENABLED" = "yes")
 AM_CONDITIONAL(USE_PHAT, test "$PHAT_ENABLED" = "yes")
+AM_CONDITIONAL(USE_LASH, test "$LASH_ENABLED" = "yes")
 AM_CONDITIONAL(ENABLE_EXPERIMENTAL, test "$set_enable_experimental" = "yes")
 AM_CONDITIONAL(OLD_JACK, test "$OLD_JACK" = "yes")
 
@@ -160,6 +162,7 @@ AC_MSG_RESULT([
     DSSI GUI enabled:       $DSSI_GUI_ENABLED
     JACK host enabled:      $JACK_ENABLED
     LV2 enabled:            $LV2_ENABLED (unused for now)
+    LASH enabled:           $LASH_ENABLED (unused for now)
     Old-style JACK MIDI:    $OLD_JACK
     PHAT GUI enabled:       $PHAT_ENABLED
     
diff --git a/src/Makefile.am b/src/Makefile.am
index f93b7a6..9009efe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,7 @@ if USE_DSSI_GUI
 noinst_PROGRAMS += calfdssigui
 endif
 
-AM_CXXFLAGS = -ffast-math -march=i686 -finline-limit=80 -DPKGLIBDIR=\"$(pkglibdir)\"
+AM_CXXFLAGS = -ffast-math -finline-limit=80 -DPKGLIBDIR=\"$(pkglibdir)\"
 
 if USE_JACK
 AM_CXXFLAGS += -DUSE_JACK=1 $(JACK_DEPS_CFLAGS) $(GUI_DEPS_CFLAGS)
@@ -29,7 +29,11 @@ if USE_PHAT
 AM_CXXFLAGS += -DUSE_PHAT=1 $(PHAT_DEPS_CFLAGS)
 calfjackhost_LDADD += $(PHAT_DEPS_LIBS)
 endif
+if USE_LASH
+calfjackhost_LDADD += $(LASH_DEPS_LIBS)
 endif
+endif
+
 if ENABLE_EXPERIMENTAL
 AM_CXXFLAGS += -DENABLE_EXPERIMENTAL=1
 endif
@@ -46,6 +50,12 @@ endif
 if USE_DSSI_GUI
 AM_CXXFLAGS += -DUSE_DSSI_GUI=1
 endif
+if USE_LV2
+AM_CXXFLAGS += -DUSE_LV2=1
+endif
+if USE_LASH
+AM_CXXFLAGS += -DUSE_LASH=1 $(LASH_DEPS_CFLAGS)
+endif
 
 calfbenchmark_SOURCES = benchmark.cpp
 calfbenchmark_LDADD =  -lglib-2.0
diff --git a/src/calf/preset.h b/src/calf/preset.h
index 00d4dcc..5250bf1 100644
--- a/src/calf/preset.h
+++ b/src/calf/preset.h
@@ -40,8 +40,10 @@ struct plugin_preset
     std::vector<float> values;
     std::string blob;
 
+    plugin_preset() : bank(0), program(0) {}
     std::string to_xml();    
     void activate(plugin_ctl_iface *plugin);
+    void get_from(plugin_ctl_iface *plugin);
 };
 
 struct preset_exception
diff --git a/src/giface.cpp b/src/giface.cpp
index 68a47cd..53a5ef2 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -111,7 +111,7 @@ int parameter_properties::get_char_count() const
         return 6;
     if ((flags & PF_SCALEMASK) == PF_SCALE_GAIN) {
         char buf[256];
-        uint32_t len = 0;
+        size_t len = 0;
         sprintf(buf, "%0.0f dB", 6.0 * log(min) / log(2));
         len = strlen(buf);
         sprintf(buf, "%0.0f dB", 6.0 * log(max) / log(2));
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index a170bdf..9ec2355 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -26,6 +26,9 @@
 #include <config.h>
 #include <glade/glade.h>
 #include <jack/jack.h>
+#if USE_LASH
+#include <lash/lash.h>
+#endif
 #include <calf/giface.h>
 #include <calf/jackhost.h>
 #include <calf/modules.h>
@@ -40,8 +43,6 @@ using namespace std;
 // I don't need anyone to tell me this is stupid. I already know that :)
 plugin_gui_window *gui_win;
 
-jack_client client;
-
 const char *client_name = "calfhost";
 
 jack_host_base *synth::create_jack_host(const char *effect_name)
@@ -107,16 +108,234 @@ int jack_client::do_jack_bufsize(jack_nframes_t numsamples, void *p)
     return 0;
 }
 
-int main(int argc, char *argv[])
+struct host_session
 {
-    vector<string> names;
+    string client_name, input_name, output_name, midi_name;
+    vector<string> plugin_names;
+    map<int, string> presets;
+#if USE_LASH
+    lash_client_t *lash_client;
+    lash_args_t *lash_args;
+#endif
+    
+    // these are not saved
+    jack_client client;
+    string autoconnect_midi;
+    set<int> chains;
     vector<jack_host_base *> plugins;
     vector<plugin_gui_window *> guis;
-    set<int> chains;
+    int lash_source_id;
+    bool restoring_session;
+    
+    host_session();
+    void open();
+    void connect();
+    void close();
+    static gboolean update_lash(void *self) { ((host_session *)self)->update_lash(); return TRUE; }
+    void update_lash();
+#if USE_LASH
+    void send_lash(LASH_Event_Type type, const std::string &data) {
+        lash_send_event(lash_client, lash_event_new_with_all(type, data.c_str()));
+    }
+    void send_config(const char *key, const std::string &data) {
+        char *buffer = new char[data.length()];
+        memcpy(buffer, data.data(), data.length());
+        lash_config_t *cfg = lash_config_new_with_key(strdup(key));
+        lash_config_set_value(cfg, buffer, data.length());
+        lash_send_config(lash_client, cfg);
+    }
+#endif
+};
+
+host_session::host_session()
+{
+    client_name = "calf";
+    lash_client = NULL;
+    lash_args = NULL;
+    lash_source_id = 0;
+    restoring_session = false;
+}
+
+void host_session::open()
+{
+    if (!input_name.empty()) client.input_name = input_name;
+    if (!output_name.empty()) client.output_name = output_name;
+    if (!midi_name.empty()) client.midi_name = midi_name;
+    client.open(client_name.c_str());
+    for (unsigned int i = 0; i < plugin_names.size(); i++) {
+        // if (presets.count(i))
+        //    printf("%s : %s\n", names[i].c_str(), presets[i].c_str());
+        jack_host_base *jh = create_jack_host(plugin_names[i].c_str());
+        if (!jh) {
+#ifdef ENABLE_EXPERIMENTAL
+            throw audio_exception("Unknown plugin name; allowed are: reverb, flanger, filter, vintagedelay, monosynth, organ, rotaryspeaker\n");
+#else
+            throw audio_exception("Unknown plugin name; allowed are: reverb, flanger, filter, vintagedelay, monosynth\n");
+#endif
+        }
+        jh->open(&client);
+        gui_win = new plugin_gui_window;
+        gui_win->conditions.insert("jackhost");
+        gui_win->conditions.insert("directlink");
+        gui_win->create(jh, (string(client_name)+" - "+plugin_names[i]).c_str(), plugin_names[i].c_str());
+        gtk_signal_connect(GTK_OBJECT(gui_win->toplevel), "destroy", G_CALLBACK(destroy), NULL);
+        gtk_widget_show_all(GTK_WIDGET(gui_win->toplevel));
+        guis.push_back(gui_win);
+        plugins.push_back(jh);
+        client.add(jh);
+        if (presets.count(i)) {
+            string cur_plugin = plugin_names[i];
+            string preset = presets[i];
+            preset_vector &pvec = global_presets.presets;
+            bool found = false;
+            for (unsigned int i = 0; i < pvec.size(); i++) {
+                if (pvec[i].name == preset && pvec[i].plugin == cur_plugin)
+                {
+                    pvec[i].activate(jh);
+                    gui_win->gui->refresh();
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                fprintf(stderr, "Warning: unknown preset %s %s\n", preset.c_str(), cur_plugin.c_str());
+            }
+        }
+    }
+}
+
+void host_session::connect()
+{
+    client.activate();
+#if USE_LASH
+    if (lash_client)
+        lash_jack_client_name(lash_client, client.get_name().c_str());
+#endif
+    if (!restoring_session) 
+    {
+        string cnp = client.get_name() + ":";
+        for (unsigned int i = 0; i < plugins.size(); i++) {
+            if (chains.count(i)) {
+                if (!i)
+                {
+                    if (plugins[0]->get_output_count() < 2)
+                    {
+                        fprintf(stderr, "Cannot connect input to plugin %s - incompatible ports\n", plugins[0]->name.c_str());
+                    } else {
+                        client.connect("system:capture_1", cnp + plugins[0]->get_inputs()[0].name);
+                        client.connect("system:capture_2", cnp + plugins[0]->get_inputs()[1].name);
+                    }
+                }
+                else
+                {
+                    if (plugins[i - 1]->get_output_count() < 2 || plugins[i]->get_input_count() < 2)
+                    {
+                        fprintf(stderr, "Cannot connect plugins %s and %s - incompatible ports\n", plugins[i - 1]->name.c_str(), plugins[i]->name.c_str());
+                    }
+                    else {
+                        client.connect(cnp + plugins[i - 1]->get_outputs()[0].name, cnp + plugins[i]->get_inputs()[0].name);
+                        client.connect(cnp + plugins[i - 1]->get_outputs()[1].name, cnp + plugins[i]->get_inputs()[1].name);
+                    }
+                }
+            }
+        }
+        if (chains.count(plugins.size()) && plugins.size())
+        {
+            int last = plugins.size() - 1;
+            if (plugins[last]->get_output_count() < 2)
+            {
+                fprintf(stderr, "Cannot connect plugin %s to output - incompatible ports\n", plugins[last]->name.c_str());
+            } else {
+                client.connect(cnp + plugins[last]->get_outputs()[0].name, "system:playback_1");
+                client.connect(cnp + plugins[last]->get_outputs()[1].name, "system:playback_2");
+            }
+        }
+        if (autoconnect_midi != "") {
+            for (unsigned int i = 0; i < plugins.size(); i++)
+            {
+                if (plugins[i]->get_midi())
+                    client.connect(autoconnect_midi, cnp + plugins[i]->get_midi_port()->name);
+            }
+        }
+    }
+#if USE_LASH
+    send_lash(LASH_Client_Name, "calf-"+client_name);
+    lash_source_id = g_timeout_add_full(G_PRIORITY_LOW, 250, update_lash, this, NULL); // 4 LASH reads per second... should be enough?
+#endif
+}
+
+void host_session::close()
+{
+    if (lash_source_id)
+        g_source_remove(lash_source_id);
+    client.deactivate();
+    for (unsigned int i = 0; i < plugin_names.size(); i++) {
+        delete guis[i];
+        plugins[i]->close();
+        delete plugins[i];
+    }
+    client.close();
+}
+
+#if USE_LASH
+void host_session::update_lash()
+{
+    do {
+        lash_event_t *event = lash_get_event(lash_client);
+        if (!event)
+            break;
+        
+        switch(lash_event_get_type(event)) {        
+            case LASH_Save_Data_Set:
+            {
+                for (unsigned int i = 0; i < plugins.size(); i++) {
+                    char ss[32];
+                    plugin_preset preset;
+                    preset.plugin = plugin_names[i];
+                    preset.get_from(plugins[i]);
+                    sprintf(ss, "plugin%d", i);
+                    string pstr = preset.to_xml();
+                    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);
+                }
+                send_lash(LASH_Save_Data_Set, "");
+                break;
+            }
+                
+            case LASH_Quit:
+                gtk_main_quit();
+                break;
+            
+            default:
+                printf("Unhandled event %d (%s)\n", lash_event_get_type(event), lash_event_get_string(event));
+                break;
+        }
+    } while(1);
+}
+#endif
+
+host_session current_session;
+
+int main(int argc, char *argv[])
+{
+    host_session &sess = current_session;
     map<int, string> preset_options;
-    map<int, string> presets;
-    string autoconnect_midi;
     gtk_init(&argc, &argv);
+#if USE_LASH
+    for (int i = 1; i < argc; i++)
+    {
+        if (!strncmp(argv[i], "--lash-project=", 14)) {
+            sess.restoring_session = true;
+            break;
+        }
+    }
+    sess.lash_args = lash_extract_args(&argc, &argv);
+    sess.lash_client = lash_init(sess.lash_args, PACKAGE_NAME, LASH_Config_Data_Set, LASH_PROTOCOL(2, 0));
+    if (!sess.lash_client) {
+        fprintf(stderr, "Warning: failed to create a LASH connection\n");
+    }
+#endif
     glade_init();
     while(1) {
         int option_index;
@@ -138,39 +357,39 @@ int main(int argc, char *argv[])
                 preset_options[optind] = optarg;
                 break;
             case 'c':
-                client_name = optarg;
+                sess.client_name = optarg;
                 break;
             case 'i':
-                client.input_name = string(optarg) + "_%d";
+                sess.input_name = string(optarg) + "_%d";
                 break;
             case 'o':
-                client.output_name = string(optarg) + "_%d";
+                sess.output_name = string(optarg) + "_%d";
                 break;
             case 'm':
-                client.midi_name = string(optarg) + "_%d";
+                sess.midi_name = string(optarg) + "_%d";
                 break;
             case 'M':
                 if (atoi(optarg))
-                    autoconnect_midi = "system:midi_capture_" + string(optarg);
+                    sess.autoconnect_midi = "system:midi_capture_" + string(optarg);
                 else
-                    autoconnect_midi = string(optarg);
+                    sess.autoconnect_midi = string(optarg);
                 break;
         }
     }
     while(optind < argc) {
         if (!strcmp(argv[optind], "!")) {
-            chains.insert(names.size());
+            sess.chains.insert(sess.plugin_names.size());
             optind++;
         } else {
             while (!preset_options.empty() && preset_options.begin()->first < optind) {
-                presets[names.size()] = preset_options.begin()->second;
+                sess.presets[sess.plugin_names.size()] = preset_options.begin()->second;
                 // printf("preset[%s] = %s\n", argv[optind], presets[names.size()].c_str());
                 preset_options.erase(preset_options.begin());
             }
-            names.push_back(argv[optind++]);
+            sess.plugin_names.push_back(argv[optind++]);
         }
     }
-    if (!names.size()) {
+    if (!sess.plugin_names.size()) {
         print_help(argv);
         return 0;
     }
@@ -183,102 +402,16 @@ int main(int argc, char *argv[])
         exit(1);
     }
     try {
-        client.open(client_name);
-        string cnp = client.get_name() + ":";
-        for (unsigned int i = 0; i < names.size(); i++) {
-            // if (presets.count(i))
-            //    printf("%s : %s\n", names[i].c_str(), presets[i].c_str());
-            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, vintagedelay, monosynth, organ, rotaryspeaker\n");
-#else
-                fprintf(stderr, "Unknown plugin name; allowed are: reverb, flanger, filter, vintagedelay, monosynth\n");
-#endif
-                return 1;
-            }
-            jh->open(&client);
-            gui_win = new plugin_gui_window;
-            gui_win->conditions.insert("jackhost");
-            gui_win->conditions.insert("directlink");
-            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);
-            gtk_widget_show_all(GTK_WIDGET(gui_win->toplevel));
-            guis.push_back(gui_win);
-            plugins.push_back(jh);
-            client.add(jh);
-            if (presets.count(i)) {
-                string cur_plugin = names[i];
-                string preset = presets[i];
-                preset_vector &pvec = global_presets.presets;
-                bool found = false;
-                for (unsigned int i = 0; i < pvec.size(); i++) {
-                    if (pvec[i].name == preset && pvec[i].plugin == cur_plugin)
-                    {
-                        pvec[i].activate(jh);
-                        gui_win->gui->refresh();
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found) {
-                    fprintf(stderr, "Warning: unknown preset %s %s\n", preset.c_str(), cur_plugin.c_str());
-                }
-            }
-        }
-        client.activate();
-        for (unsigned int i = 0; i < plugins.size(); i++) {
-            if (chains.count(i)) {
-                if (!i)
-                {
-                    if (plugins[0]->get_output_count() < 2)
-                    {
-                        fprintf(stderr, "Cannot connect input to plugin %s - incompatible ports\n", plugins[0]->name.c_str());
-                    } else {
-                        client.connect("system:capture_1", cnp + plugins[0]->get_inputs()[0].name);
-                        client.connect("system:capture_2", cnp + plugins[0]->get_inputs()[1].name);
-                    }
-                }
-                else
-                {
-                    if (plugins[i - 1]->get_output_count() < 2 || plugins[i]->get_input_count() < 2)
-                    {
-                        fprintf(stderr, "Cannot connect plugins %s and %s - incompatible ports\n", plugins[i - 1]->name.c_str(), plugins[i]->name.c_str());
-                    }
-                    else {
-                        client.connect(cnp + plugins[i - 1]->get_outputs()[0].name, cnp + plugins[i]->get_inputs()[0].name);
-                        client.connect(cnp + plugins[i - 1]->get_outputs()[1].name, cnp + plugins[i]->get_inputs()[1].name);
-                    }
-                }
-            }
-        }
-        if (chains.count(plugins.size()) && plugins.size())
-        {
-            int last = plugins.size() - 1;
-            if (plugins[last]->get_output_count() < 2)
-            {
-                fprintf(stderr, "Cannot connect plugin %s to output - incompatible ports\n", plugins[last]->name.c_str());
-            } else {
-                client.connect(cnp + plugins[last]->get_outputs()[0].name, "system:playback_1");
-                client.connect(cnp + plugins[last]->get_outputs()[1].name, "system:playback_2");
-            }
-        }
-        if (autoconnect_midi != "") {
-            for (unsigned int i = 0; i < plugins.size(); i++)
-            {
-                if (plugins[i]->get_midi())
-                    client.connect(autoconnect_midi, cnp + plugins[i]->get_midi_port()->name);
-            }
-        }
+        sess.open();
+        sess.connect();
+        sess.client.activate();
         gtk_main();
-        client.deactivate();
-        for (unsigned int i = 0; i < names.size(); i++) {
-            delete guis[i];
-            plugins[i]->close();
-            delete plugins[i];
-        }
-        client.close();
+        sess.close();
         
+#if USE_LASH
+        if (sess.lash_args)
+            lash_args_destroy(sess.lash_args);
+#endif
         // this is now done on preset add
         // save_presets(get_preset_filename().c_str());
     }
diff --git a/src/preset.cpp b/src/preset.cpp
index aaf26e1..250bd1a 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -69,6 +69,15 @@ void plugin_preset::activate(plugin_ctl_iface *plugin)
         plugin->set_param_value(pos->second, values[i]);
     }
 }
+
+void plugin_preset::get_from(plugin_ctl_iface *plugin)
+{
+    int count = plugin->get_param_count();
+    for (int i = 0; i < count; i++) {
+        param_names.push_back(plugin->get_param_props(i)->short_name);
+        values.push_back(plugin->get_param_value(i));
+    }
+}
     
 string synth::preset_list::get_preset_filename()
 {
diff --git a/src/preset_gui.cpp b/src/preset_gui.cpp
index b24eda3..d95b699 100644
--- a/src/preset_gui.cpp
+++ b/src/preset_gui.cpp
@@ -44,11 +44,7 @@ void store_preset_ok(GtkAction *action, plugin_gui *gui)
     sp.bank = 0;
     sp.program = 0;
     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_props(i)->short_name);
-        sp.values.push_back(gui->plugin->get_param_value(i));
-    }
+    sp.get_from(gui->plugin);
     preset_list tmp;
     try {
         tmp.load(tmp.get_preset_filename().c_str());

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list