summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-05-20 03:55:46 +0000
committerDavid Robillard <d@drobilla.net>2008-05-20 03:55:46 +0000
commit161d33090fdf8db67aa8c3a84b2cea01d8b9ac9e (patch)
tree5890a6a0b78325adb8b1053930924dd0a9a4cc53
parent99ea289658f06b2ff53cebd91113c1f1db6c0e09 (diff)
downloadingen-161d33090fdf8db67aa8c3a84b2cea01d8b9ac9e.tar.gz
ingen-161d33090fdf8db67aa8c3a84b2cea01d8b9ac9e.tar.bz2
ingen-161d33090fdf8db67aa8c3a84b2cea01d8b9ac9e.zip
Write individual events from UIs over OSC instead of entire event buffer.
git-svn-id: http://svn.drobilla.net/lad/ingen@1221 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/libs/client/PluginUI.cpp37
-rw-r--r--src/libs/engine/EventBuffer.cpp1
-rw-r--r--src/libs/engine/InputPort.cpp13
3 files changed, 36 insertions, 15 deletions
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
index 9dcbfcba..c7c3ffc5 100644
--- a/src/libs/client/PluginUI.cpp
+++ b/src/libs/client/PluginUI.cpp
@@ -16,6 +16,7 @@
*/
#include <iostream>
+#include "lv2ext/lv2_event_helpers.h"
#include "shared/LV2URIMap.hpp"
#include "PluginUI.hpp"
#include "NodeModel.hpp"
@@ -35,10 +36,8 @@ lv2_ui_write(LV2UI_Controller controller,
uint32_t format,
const void* buffer)
{
-#if 0
- cerr << "********* LV2 UI WRITE (FORMAT " << format << "):" << endl;
- /*lv2_osc_message_print((const LV2Message*)buffer);*/
-
+ /*
+ cerr << "lv2_ui_write (format " << format << "):" << endl;
fprintf(stderr, "RAW:\n");
for (uint32_t i=0; i < buffer_size; ++i) {
unsigned char byte = ((unsigned char*)buffer)[i];
@@ -48,7 +47,7 @@ lv2_ui_write(LV2UI_Controller controller,
fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]);
}
fprintf(stderr, "\n");
-#endif
+ */
PluginUI* ui = (PluginUI*)controller;
@@ -57,15 +56,35 @@ lv2_ui_write(LV2UI_Controller controller,
LV2URIMap* map = (LV2URIMap*)ui->world()->lv2_features->feature(LV2_URI_MAP_URI);
assert(map);
- if (format == 0) { // float (special case)
+ // float (special case, always 0)
+ if (format == 0) {
assert(buffer_size == 4);
if (*(float*)buffer == port->value().get_float())
return; // do nothing (handle stupid plugin UIs that feed back)
+
+ ui->world()->engine->set_port_value_immediate(port->path(),
+ port->type().uri(),
+ buffer_size, buffer);
+
+ // FIXME: assumes event
+ } else {
+ LV2_Event_Buffer* buf = (LV2_Event_Buffer*)buffer;
+ LV2_Event_Iterator iter;
+ uint8_t* data;
+ lv2_event_begin(&iter, buf);
+ while (lv2_event_is_valid(&iter)) {
+ LV2_Event* const ev = lv2_event_get(&iter, &data);
+
+ // FIXME: bundle multiple events
+ ui->world()->engine->set_port_value_immediate(port->path(),
+ port->type().uri(),
+ ev->size, data);
+
+ lv2_event_increment(&iter);
+ }
}
- ui->world()->engine->set_port_value_immediate(port->path(),
- port->type().uri(),
- buffer_size, buffer);
+
}
diff --git a/src/libs/engine/EventBuffer.cpp b/src/libs/engine/EventBuffer.cpp
index d11989ab..c9b4f249 100644
--- a/src/libs/engine/EventBuffer.cpp
+++ b/src/libs/engine/EventBuffer.cpp
@@ -102,7 +102,6 @@ void
EventBuffer::prepare_read(SampleCount nframes)
{
//cerr << "\t" << this << " prepare_read: " << event_count() << endl;
-
rewind();
_this_nframes = nframes;
}
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp
index 6e216384..7a90bc21 100644
--- a/src/libs/engine/InputPort.cpp
+++ b/src/libs/engine/InputPort.cpp
@@ -20,6 +20,7 @@
#include <cstdlib>
#include <cassert>
#include "AudioBuffer.hpp"
+#include "EventBuffer.hpp"
#include "ConnectionImpl.hpp"
#include "OutputPort.hpp"
#include "NodeImpl.hpp"
@@ -184,17 +185,19 @@ InputPort::pre_process(ProcessContext& context)
/*cerr << path() << " poly = " << _poly << ", mixdown: " << do_mixdown
<< ", fixed buffers: " << _fixed_buffers << ", joined: " << _buffers->at(0)->is_joined()
- << " to " << _buffers->at(0)->joined_buffer() << endl;
+ << " to " << _buffers->at(0)->joined_buffer() << endl;*/
- if (type() == DataType::MIDI)
+ /*if (type() == DataType::EVENT)
for (uint32_t i=0; i < _poly; ++i)
- cerr << path() << " (" << buffer(i) << ") # events: " << ((MidiBuffer*)buffer(i))->event_count() << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
+ cerr << path() << " (" << buffer(i) << ") # events: "
+ << ((EventBuffer*)buffer(i))->event_count()
+ << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
if (!do_mixdown) {
-/*#ifndef NDEBUG
+ /*#ifndef NDEBUG
for (uint32_t i=0; i < _poly; ++i)
assert(buffer(i) == (*_connections.begin())->buffer(i));
-#endif*/
+ #endif*/
return;
}