copy plugin state to all instances when instantiating.
[ardour.git] / libs / ardour / vst_plugin.cc
index 1614b1d8fe394cc6a6ee62a6c9e9737a91347aec..83d7dc2ced1990eecdfb2a7430664666bf9f4c15 100644 (file)
@@ -44,6 +44,8 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
        , _handle (handle)
        , _state (0)
        , _plugin (0)
+       , _pi (0)
+       , _num (0)
 {
 
 }
@@ -565,7 +567,12 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
 
        uint32_t out_index = 0;
        for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) {
-               outs[i] = scratch_bufs.get_audio(i).data(offset);
+               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);
        }
 
        if (bufs.count().n_midi() > 0) {
@@ -592,16 +599,6 @@ 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;
 }
 
@@ -679,7 +676,7 @@ VSTPlugin::find_presets ()
 
        int const vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, NULL, 0);
        for (int i = 0; i < _plugin->numPrograms; ++i) {
-               PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", -1, false);
+               PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", false);
 
                if (vst_version >= 2) {
                        char buf[256];
@@ -709,7 +706,7 @@ VSTPlugin::find_presets ()
                        assert (uri);
                        assert (label);
 
-                       PresetRecord r (uri->value(), label->value(), -1, true);
+                       PresetRecord r (uri->value(), label->value(), true);
                        _presets.insert (make_pair (r.uri, r));
                }
        }