Fix a problem where VST automation data wasn't getting written (if the adjustments...
[ardour.git] / libs / ardour / vst_plugin.cc
index 24020e835672f4c2d2de5029706082e600b887a7..08db7dec5e56fa18d533a366a13dd6f9377e51bf 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include <glib.h>
-#include <glib/gstdio.h>
+#include "pbd/gstdio_compat.h"
 
 #include <glibmm/fileutils.h>
 #include <glibmm/miscutils.h>
@@ -117,6 +117,12 @@ VSTPlugin::set_parameter (uint32_t which, float newval)
        }
 }
 
+void
+VSTPlugin::set_parameter_automated (uint32_t which, float newval)
+{
+       Plugin::set_parameter_automated (which, newval);
+}
+
 uint32_t
 VSTPlugin::nth_parameter (uint32_t n, bool& ok) const
 {
@@ -158,7 +164,7 @@ VSTPlugin::set_chunk (gchar const * data, bool single)
 void
 VSTPlugin::add_state (XMLNode* root) const
 {
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        if (_plugin->flags & 32 /* effFlagsProgramsChunks */) {
 
@@ -195,7 +201,7 @@ VSTPlugin::add_state (XMLNode* root) const
 int
 VSTPlugin::set_state (const XMLNode& node, int version)
 {
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
        int ret = -1;
 
        if (node.name() != state_node_name()) {
@@ -549,7 +555,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
        */
 
        float** ins = (float**)alloca(_plugin->numInputs*sizeof(float*));
-       float** outs = (float**)alloca(_plugin->numInputs*sizeof(float*));
+       float** outs = (float**)alloca(_plugin->numOutputs*sizeof(float*));
 
        int32_t i;
 
@@ -565,12 +571,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
 
        uint32_t out_index = 0;
        for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) {
-               uint32_t  index;
-               bool      valid = false;
-               index = out_map.get(DataType::AUDIO, out_index++, &valid);
-               outs[i] = (valid)
-                                       ? bufs.get_audio(index).data(offset)
-                                       : scratch_bufs.get_audio(0).data(offset);
+               outs[i] = scratch_bufs.get_audio(i).data(offset);
        }
 
        if (bufs.count().n_midi() > 0) {
@@ -597,6 +598,16 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
        _plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes);
        _midi_out_buf = 0;
 
+       out_index = 0;
+       for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) {
+               uint32_t  index;
+               bool      valid = false;
+               index = out_map.get(DataType::AUDIO, out_index++, &valid);
+               if (!valid) {
+                       continue;
+               }
+               copy_vector (bufs.get_audio(index).data(offset), outs[i], nframes);
+       }
        return 0;
 }
 
@@ -614,6 +625,9 @@ VSTPlugin::unique_id () const
 const char *
 VSTPlugin::name () const
 {
+       if (!_info->name.empty ()) {
+               return _info->name.c_str();
+       }
        return _handle->name;
 }