copy plugin state to all instances when instantiating.
[ardour.git] / libs / ardour / session_vst.cc
index 2aed71aa9c5204748ea68f44266aa4763e60cdbb..0e16ac1ebe8ca9ec8b6cd0e64fbe9b88f5ed3b17 100644 (file)
@@ -26,6 +26,7 @@
 #include "ardour/debug.h"
 #include "ardour/session.h"
 #include "ardour/tempo.h"
+#include "ardour/plugin_insert.h"
 #include "ardour/windows_vst_plugin.h"
 #include "ardour/vestige/aeffectx.h"
 #include "ardour/vst_types.h"
@@ -124,11 +125,25 @@ intptr_t Session::vst_callback (
                }
                switch (value) {
                        case 0:
+                               if (plug->plugin_insert ()) {
+                                       bool valid;
+                                       const ChanMapping& map (plug->plugin_insert ()->input_map (plug->plugin_number ()));
+                                       map.get (DataType::AUDIO, index, &valid);
+                                       return valid ? 0 : 1;
+                               }
                                if (index < plug->plugin()->numInputs) {
                                        return 0;
                                }
                                break;
                        case 1:
+#if 0 // investigate, the outputs *are* connected to scratch buffers
+                               if (plug->plugin_insert ()) {
+                                       bool valid;
+                                       const ChanMapping& map (plug->plugin_insert ()->output_map (plug->plugin_number ()));
+                                       map.get (DataType::AUDIO, index, &valid);
+                                       return valid ? 0 : 1;
+                               }
+#endif
                                if (index < plug->plugin()->numOutputs) {
                                        return 0;
                                }
@@ -249,11 +264,18 @@ intptr_t Session::vst_callback (
                                _timeInfo.flags |= (kVstSmpteValid);
                        }
 
+                       //ToDo: 
+                       //if this is found to be burdensome to plugins,
+                       //we should cache the previous state at a global level,
+                       //and only set this flag when the transport changes state
+                       _timeInfo.flags |= (kVstTransportChanged);
+
                        if (session->transport_speed() != 0.0f) {
                                _timeInfo.flags |= (kVstTransportPlaying);
                        }
 
                        if (session->get_play_loop()) {
+                               _timeInfo.flags |= (kVstTransportCycleActive);
                        }
 
                } else {
@@ -318,9 +340,11 @@ intptr_t Session::vst_callback (
 
        case audioMasterSizeWindow:
                SHOW_CALLBACK ("audioMasterSizeWindow");
-               plug->state()->width = index;
-               plug->state()->height = value;
-               plug->state()->want_resize = 1;
+               if (plug && plug->state()) {
+                       plug->state()->width = index;
+                       plug->state()->height = value;
+                       plug->state()->want_resize = 1;
+               }
                return 0;
 
        case audioMasterGetSampleRate: