MacVST Program/Preset support
authorRobin Gareus <robin@gareus.org>
Mon, 14 Nov 2016 23:01:27 +0000 (00:01 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 14 Nov 2016 23:32:59 +0000 (00:32 +0100)
gtk2_ardour/mac_vst_plugin_ui.h
gtk2_ardour/mac_vst_plugin_ui.mm

index 87639526e9d8a5cbb001249edb62d979d8cb28c9..2082fa8578af147642e65807bc22e1dec01315eb 100644 (file)
@@ -51,9 +51,11 @@ private:
        int get_XID ();
        bool idle ();
        void lower_box_realized ();
+       void set_program ();
        NSWindow* get_nswindow();
 
        Gtk::EventBox low_box;
        NSView*          _ns_view;
        sigc::connection _idle_connection;
+       PBD::ScopedConnection _program_connection;
 };
index 2b10fc2a88e8190fbdb02e60e2d3fb4b65d032f4..2c0cd1c502a830715bccafddd095d5406fdce9d6 100644 (file)
@@ -56,6 +56,8 @@ MacVSTPluginUI::MacVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::share
        low_box.signal_realize().connect (mem_fun (this, &MacVSTPluginUI::lower_box_realized));
        pack_start (low_box, true, true);
        low_box.show ();
+       vst->LoadPresetProgram.connect (_program_connection, invalidator (*this), boost::bind (&MacVSTPluginUI::set_program, this), gui_context());
+
 }
 
 MacVSTPluginUI::~MacVSTPluginUI ()
@@ -149,3 +151,30 @@ MacVSTPluginUI::idle ()
        _vst->state()->wantIdle = plugin->dispatcher (plugin, effEditIdle, 0, 0, NULL, 0);
        return true; // _vst->state()->wantIdle;
 }
+
+void
+MacVSTPluginUI::set_program ()
+{
+       VSTState* vstfx = _vst->state();
+
+       if (vstfx->want_program != -1) {
+               if (vstfx->vst_version >= 2) {
+                       vstfx->plugin->dispatcher (vstfx->plugin, 67 /* effBeginSetProgram */, 0, 0, NULL, 0);
+               }
+
+               vstfx->plugin->dispatcher (vstfx->plugin, effSetProgram, 0, vstfx->want_program, NULL, 0);
+
+               if (vstfx->vst_version >= 2) {
+                       vstfx->plugin->dispatcher (vstfx->plugin, 68 /* effEndSetProgram */, 0, 0, NULL, 0);
+               }
+
+               vstfx->want_program = -1;
+       }
+
+       if (vstfx->want_chunk == 1) {
+               pthread_mutex_lock (&vstfx->state_lock);
+               vstfx->plugin->dispatcher (vstfx->plugin, 24 /* effSetChunk */, 1, vstfx->wanted_chunk_size, vstfx->wanted_chunk, 0);
+               vstfx->want_chunk = 0;
+               pthread_mutex_unlock (&vstfx->state_lock);
+       }
+}