summaryrefslogtreecommitdiff
path: root/gtk2_ardour/lv2_plugin_ui.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-25 08:43:23 +0000
committerDavid Robillard <d@drobilla.net>2012-02-25 08:43:23 +0000
commit4d7810dee89b36107b61f4124fd5ce3908abd705 (patch)
treef53d514f8df2578601c16b0810b1dcde3214d1d6 /gtk2_ardour/lv2_plugin_ui.cc
parent1cf6e280b877127e76733589f990c0b438054e36 (diff)
Full round-trip message communication between LV2 UIs and plugins.
Still a little bit rough around the edges, but it works. This can be tested with the eg-sampler plugin from LV2 svn (whose UI can load different samples). git-svn-id: svn://localhost/ardour2/branches/3.0@11519 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/lv2_plugin_ui.cc')
-rw-r--r--gtk2_ardour/lv2_plugin_ui.cc49
1 files changed, 37 insertions, 12 deletions
diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc
index 751985871d..70fbf448c6 100644
--- a/gtk2_ardour/lv2_plugin_ui.cc
+++ b/gtk2_ardour/lv2_plugin_ui.cc
@@ -40,23 +40,45 @@ using namespace PBD;
static SuilHost* ui_host = NULL;
void
-LV2PluginUI::lv2_ui_write(void* controller,
- uint32_t port_index,
- uint32_t /*buffer_size*/,
- uint32_t /*format*/,
- const void* buffer)
+LV2PluginUI::write_from_ui(void* controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void* buffer)
{
LV2PluginUI* me = (LV2PluginUI*)controller;
+ if (format == 0) {
+ if (port_index >= me->_controllables.size()) {
+ return;
+ }
- if (port_index >= me->_controllables.size()) {
- return;
+ boost::shared_ptr<AutomationControl> ac = me->_controllables[port_index];
+ if (ac) {
+ ac->set_value(*(float*)buffer);
+ }
+ } else if (format == me->_lv2->atom_eventTransfer()) {
+ me->_lv2->write_from_ui(port_index, format, buffer_size, (uint8_t*)buffer);
}
+}
- boost::shared_ptr<AutomationControl> ac = me->_controllables[port_index];
+void
+LV2PluginUI::write_to_ui(void* controller,
+ uint32_t port_index,
+ uint32_t buffer_size,
+ uint32_t format,
+ const void* buffer)
+{
+ LV2PluginUI* me = (LV2PluginUI*)controller;
+ fprintf(stderr, "MESSAGE FROM PLUGIN %u BYTES\n", buffer_size);
+ suil_instance_port_event((SuilInstance*)me->_inst,
+ port_index, buffer_size, format, buffer);
+}
- if (ac) {
- ac->set_value(*(float*)buffer);
- }
+bool
+LV2PluginUI::update_timeout()
+{
+ _lv2->emit_to_ui(this, &LV2PluginUI::write_to_ui);
+ return true;
}
void
@@ -173,7 +195,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
}
if (!ui_host) {
- ui_host = suil_host_new(LV2PluginUI::lv2_ui_write, NULL, NULL, NULL);
+ ui_host = suil_host_new(LV2PluginUI::write_from_ui, NULL, NULL, NULL);
}
const char* container_type = (is_external_ui)
? NS_UI "external"
@@ -245,6 +267,9 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
}
}
}
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(*this, &LV2PluginUI::update_timeout), 500);
}
void