don't display internal returns to user
[ardour.git] / libs / ardour / vst_plugin.cc
index 7fb5289f9c6156f0d0c2f91301f8199a475ab650..d805a2feec0fa9ff2b3c791d3cda9103e7ec24a4 100644 (file)
@@ -30,7 +30,6 @@
 #include <sys/stat.h>
 #include <cerrno>
 
-#include <glibmm/ustring.h>
 #include <glibmm/miscutils.h>
 
 #include <lrdf.h>
 #include "ardour/vst_plugin.h"
 #include "ardour/buffer_set.h"
 #include "ardour/audio_buffer.h"
+#include "ardour/midi_buffer.h"
 
 #include "pbd/stl_delete.h"
 
 #include "i18n.h"
 #include <locale.h>
 
+using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 using std::min;
@@ -105,12 +106,13 @@ VSTPlugin::~VSTPlugin ()
        fst_close (_fst);
 }
 
-void
+int 
 VSTPlugin::set_block_size (nframes_t nframes)
 {
        deactivate ();
        _plugin->dispatcher (_plugin, effSetBlockSize, 0, nframes, NULL, 0.0f);
        activate ();
+        return 0;
 }
 
 float
@@ -157,7 +159,7 @@ VSTPlugin::get_state()
                /* fetch the current chunk */
 
                guchar* data;
-               long  data_size;
+                int32_t data_size;
 
                if ((data_size = _plugin->dispatcher (_plugin, 23 /* effGetChunk */, 0, 0, &data, false)) == 0) {
                        return *root;
@@ -177,7 +179,7 @@ VSTPlugin::get_state()
 
                XMLNode* parameters = new XMLNode ("parameters");
 
-               for (long n = 0; n < _plugin->numParams; ++n) {
+               for (int32_t n = 0; n < _plugin->numParams; ++n) {
                        char index[64];
                        char val[32];
                        snprintf (index, sizeof (index), "param_%ld", n);
@@ -192,7 +194,7 @@ VSTPlugin::get_state()
 }
 
 int
-VSTPlugin::set_state(const XMLNode& node)
+VSTPlugin::set_state(const XMLNode& node, int)
 {
        LocaleGuard lg (X_("POSIX"));
 
@@ -204,7 +206,7 @@ VSTPlugin::set_state(const XMLNode& node)
        const XMLProperty* prop;
 
        if ((prop = node.property ("current-program")) != 0) {
-               _fst->current_program = atoi (prop->value());
+               _fst->current_program = atoi (prop->value().c_str());
        }
 
        XMLNode* child;
@@ -231,10 +233,10 @@ VSTPlugin::set_state(const XMLNode& node)
                XMLPropertyList::const_iterator i;
 
                for (i = child->properties().begin(); i != child->properties().end(); ++i) {
-                       long param;
+                       int32_t param;
                        float val;
 
-                       sscanf ((*i)->name().c_str(), "param_%ld", &param);
+                       sscanf ((*i)->name().c_str(), "param_%d", &param);
                        sscanf ((*i)->value().c_str(), "%f", &val);
 
                        _plugin->setParameter (_plugin, param, val);
@@ -392,11 +394,13 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
 
        const uint32_t nbufs = bufs.count().n_audio();
 
+       int in_index = 0;
        for (i = 0; i < (int32_t) _plugin->numInputs; ++i) {
                ins[i] = bufs.get_audio(min((uint32_t) in_index, nbufs - 1)).data() + offset;
                in_index++;
        }
 
+       int out_index = 0;
        for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) {
                outs[i] = bufs.get_audio(min((uint32_t) out_index, nbufs - 1)).data() + offset;
 
@@ -410,6 +414,11 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
        }
 
 
+       if (bufs.count().n_midi() > 0) {
+               VstEvents* v = bufs.get_vst_midi (0);
+               _plugin->dispatcher (_plugin, effProcessEvents, 0, 0, v, 0);
+       }
+
        /* we already know it can support processReplacing */
 
        _plugin->processReplacing (_plugin, ins, outs, nframes);