Changes missing from previous commit
[ardour.git] / gtk2_ardour / lv2_plugin_ui.cc
index d18f7d80ce189403923653cf89c083db2da18841..812f2640a71f1500d0fc06f183aa4133ba8e2454 100644 (file)
@@ -18,8 +18,8 @@
 
 */
 
-#include <ardour/processor.h>
-#include <ardour/lv2_plugin.h>
+#include "ardour/processor.h"
+#include "ardour/lv2_plugin.h"
 
 #include "ardour_ui.h"
 #include "lv2_plugin_ui.h"
@@ -29,11 +29,12 @@ using namespace ARDOUR;
 using namespace PBD;
 
 void
-LV2PluginUI::lv2_ui_write(LV2UI_Controller controller,
-             uint32_t         port_index,
-             uint32_t         buffer_size,
-             uint32_t         format,
-             const void*      buffer)
+LV2PluginUI::lv2_ui_write(
+               LV2UI_Controller controller,
+               uint32_t         port_index,
+               uint32_t         buffer_size,
+               uint32_t         format,
+               const void*      buffer)
 {
        LV2PluginUI* me = (LV2PluginUI*)controller;
        if (*(float*)buffer != me->_values[port_index])
@@ -44,14 +45,20 @@ void
 LV2PluginUI::parameter_changed (uint32_t port_index, float val)
 {
        if (val != _values[port_index]) {
-               const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst);
-               LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_inst);
-               if (ui_desc->port_event)
-                       ui_desc->port_event(ui_handle, port_index, 4, 0, &val);
-               _values[port_index] = val;
+               parameter_update(port_index, val);
        }
 }
 
+void
+LV2PluginUI::parameter_update (uint32_t port_index, float val)
+{
+       const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst);
+       LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_inst);
+       if (ui_desc->port_event)
+               ui_desc->port_event(ui_handle, port_index, 4, 0, &val);
+       _values[port_index] = val;
+}
+
 bool
 LV2PluginUI::start_updating(GdkEventAny* event)
 {
@@ -107,9 +114,13 @@ LV2PluginUI::LV2PluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<
        _values = new float[num_ports];
        for (uint32_t i = 0; i < num_ports; ++i) {
                bool ok;
-               _values[i] = lv2p->nth_parameter(i, ok);
-               if (ok)
-                       lv2_ui_write(this, i, 4, /* FIXME: format */0, &_values[i]);
+               uint32_t port = lv2p->nth_parameter(i, ok);
+               if (ok) {
+                       _values[port] = lv2p->get_parameter(port);
+                       if (lv2p->parameter_is_control(port) && lv2p->parameter_is_input(port)) {
+                               parameter_update(port, _values[port]);
+                       }
+               }
        }
                
        _lv2->ParameterChanged.connect(mem_fun(*this, &LV2PluginUI::parameter_changed));
@@ -148,7 +159,7 @@ LV2PluginUI::package (Gtk::Window& win)
 bool
 LV2PluginUI::configure_handler (GdkEventConfigure* ev)
 {
-       cout << "CONFIGURE" << endl;
+       std::cout << "CONFIGURE" << std::endl;
        return false;
 }