add IsSkip enum to enums.cc
[ardour.git] / libs / ardour / plugin_insert.cc
index 10368bfb428bf6a1b3efc3a235e22cf7c3d7a89c..5279a3696216e3ac216ed11e57d8adb5a6b80168 100644 (file)
@@ -352,6 +352,9 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                }
        }
 
+       bufs.set_count(ChanCount::max(bufs.count(), in_streams));
+       bufs.set_count(ChanCount::max(bufs.count(), out_streams));
+
        /* Note that we've already required that plugins
           be able to handle in-place processing.
        */
@@ -452,51 +455,43 @@ PluginInsert::silence (framecnt_t nframes)
 }
 
 void
-PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t /*end_frame*/, pframes_t nframes, bool)
 {
        if (_pending_active) {
                /* run as normal if we are active or moving from inactive to active */
 
-               if (_session.transport_rolling()) {
-                       automation_run (bufs, nframes);
+               if (_session.transport_rolling() || _session.bounce_processing()) {
+                       automation_run (bufs, start_frame, nframes);
                } else {
                        connect_and_run (bufs, nframes, 0, false);
                }
 
        } else {
-               if (has_no_audio_inputs()) {
+               uint32_t in = input_streams ().n_audio ();
+               uint32_t out = output_streams().n_audio ();
+
+               if (has_no_audio_inputs() || in == 0) {
 
                        /* silence all (audio) outputs. Should really declick
                         * at the transitions of "active"
                         */
 
-                       uint32_t out = output_streams().n_audio ();
-
                        for (uint32_t n = 0; n < out; ++n) {
                                bufs.get_audio (n).silence (nframes);
                        }
 
-                       bufs.count().set_audio (out);
-
-               } else {
-
-                       /* does this need to be done with MIDI? it appears not */
-
-                       uint32_t in = input_streams ().n_audio ();
-                       uint32_t out = output_streams().n_audio ();
+               } else if (out > in) {
 
-                       if (out > in) {
+                       /* not active, but something has make up for any channel count increase */
 
-                               /* not active, but something has make up for any channel count increase */
-                               
-                               // TODO: option round-robin (n % in) or silence additional buffers ??
-                               for (uint32_t n = in; n < out; ++n) {
-                                       bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes);
-                               }
+                       // TODO: option round-robin (n % in) or silence additional buffers ??
+                       // for now , simply replicate last buffer
+                       for (uint32_t n = in; n < out; ++n) {
+                               bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes);
                        }
-
-                       bufs.count().set_audio (out);
                }
+
+               bufs.count().set_audio (out);
        }
 
        _active = _pending_active;
@@ -543,10 +538,10 @@ PluginInsert::get_parameter (Evoral::Parameter param)
 }
 
 void
-PluginInsert::automation_run (BufferSet& bufs, pframes_t nframes)
+PluginInsert::automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes)
 {
        Evoral::ControlEvent next_event (0, 0.0f);
-       framepos_t now = _session.transport_frame ();
+       framepos_t now = start;
        framepos_t end = now + nframes;
        framecnt_t offset = 0;
 
@@ -719,6 +714,10 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 PluginInsert::Match
 PluginInsert::private_can_support_io_configuration (ChanCount const & inx, ChanCount& out)
 {
+       if (_plugins.empty()) {
+               return Match();
+       }
+
        PluginInfoPtr info = _plugins.front()->get_info();
        ChanCount in; in += inx;
        midi_bypass.reset();
@@ -977,6 +976,22 @@ PluginInsert::set_state(const XMLNode& node, int version)
 
        boost::shared_ptr<Plugin> plugin = find_plugin (_session, prop->value(), type);
 
+       /* treat linux and windows VST plugins equivalent if they have the same uniqueID
+        * allow to move sessions windows <> linux */
+#ifdef LXVST_SUPPORT
+       if (plugin == 0 && type == ARDOUR::Windows_VST) {
+               type = ARDOUR::LXVST;
+               plugin = find_plugin (_session, prop->value(), type);
+       }
+#endif
+
+#ifdef WINDOWS_VST_SUPPORT
+       if (plugin == 0 && type == ARDOUR::LXVST) {
+               type = ARDOUR::Windows_VST;
+               plugin = find_plugin (_session, prop->value(), type);
+       }
+#endif
+
        if (plugin == 0) {
                error << string_compose(
                        _("Found a reference to a plugin (\"%1\") that is unknown.\n"
@@ -1188,6 +1203,10 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Param
        _logarithmic = desc.logarithmic;
        _sr_dependent = desc.sr_dependent;
        _toggled = desc.toggled;
+
+       if (desc.toggled) {
+               set_flags(Controllable::Toggle);
+       }
 }
 
 /** @param val `user' value */