diff options
author | David Robillard <d@drobilla.net> | 2011-03-07 05:34:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-03-07 05:34:19 +0000 |
commit | a7d7fae434dc32e6787dfe54d1c30e0bccc660bd (patch) | |
tree | 74c46b462b3541e05d58b0219531a6aef1bd946a | |
parent | 3dddff18969b94438bc44b8d3d3c769b9ffc0a1b (diff) | |
download | ingen-a7d7fae434dc32e6787dfe54d1c30e0bccc660bd.tar.gz ingen-a7d7fae434dc32e6787dfe54d1c30e0bccc660bd.tar.bz2 ingen-a7d7fae434dc32e6787dfe54d1c30e0bccc660bd.zip |
Apply LV2 UI MIDI event fix from Lars Luthman (ticket #651) with minor changes.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3048 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/client/PluginUI.cpp | 4 | ||||
-rw-r--r-- | src/engine/InputPort.cpp | 10 | ||||
-rw-r--r-- | src/engine/events/SetPortValue.cpp | 6 | ||||
-rw-r--r-- | src/shared/LV2URIMap.cpp | 22 | ||||
-rw-r--r-- | src/shared/LV2URIMap.hpp | 4 |
5 files changed, 42 insertions, 4 deletions
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 6ae2623c..8233506c 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -71,7 +71,9 @@ lv2_ui_write(LV2UI_Controller controller, lv2_event_begin(&iter, buf); while (lv2_event_is_valid(&iter)) { LV2_Event* const ev = lv2_event_get(&iter, &data); - if (ev->type == uris.midi_MidiEvent.id) { + std::pair<bool, uint16_t> midi_id = + uris.global_to_event(uris.midi_MidiEvent.id); + if (midi_id.first && ev->type == midi_id.second) { // FIXME: bundle multiple events by writing an entire buffer here ui->world()->engine()->set_property( port->path(), diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp index 0cd6e87a..f82b522a 100644 --- a/src/engine/InputPort.cpp +++ b/src/engine/InputPort.cpp @@ -210,7 +210,15 @@ InputPort::pre_process(Context& context) void InputPort::post_process(Context& context) { - _set_by_user = false; + if (_set_by_user) { + if (buffer_type() == PortType::EVENTS) { + // Clear events received via a SetPortValue + for (uint32_t v = 0; v < _poly; ++v) { + buffer(v)->clear(); + } + } + _set_by_user = false; + } } diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp index a0c432c4..a8adf658 100644 --- a/src/engine/events/SetPortValue.cpp +++ b/src/engine/events/SetPortValue.cpp @@ -166,8 +166,10 @@ SetPortValue::apply(Context& context) } else if (!strcmp(_value.get_blob_type(), "http://lv2plug.in/ns/ext/midi#MidiEvent")) { ebuf->prepare_write(context); - ebuf->append(frames, 0, uris.midi_MidiEvent.id, _value.data_size(), - (const uint8_t*)_value.get_blob()); + ebuf->append(frames, 0, + uris.global_to_event(uris.midi_MidiEvent.id).second, + _value.data_size(), + (const uint8_t*)_value.get_blob()); _port->raise_set_by_user_flag(); return; } diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index 768982d0..d72739df 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -170,6 +170,28 @@ LV2URIMap::id_to_uri(const char* map, } +std::pair<bool, uint32_t> +LV2URIMap::event_to_global(uint16_t event_id) const +{ + EventToGlobal::const_iterator i = _event_to_global.find(event_id); + if (i == _event_to_global.end()) { + return std::make_pair(false, uint32_t(0)); + } + return std::make_pair(true, i->second); +} + + +std::pair<bool, uint16_t> +LV2URIMap::global_to_event(uint32_t global_id) const +{ + GlobalToEvent::const_iterator i = _global_to_event.find(global_id); + if (i == _global_to_event.end()) { + return std::make_pair(false, uint16_t(0)); + } + return std::make_pair(true, i->second); +} + + uint32_t LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char* map, diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp index fe98bbc3..20957a6a 100644 --- a/src/shared/LV2URIMap.hpp +++ b/src/shared/LV2URIMap.hpp @@ -19,6 +19,7 @@ #define INGEN_SHARED_LV2URIMAP_HPP #include <map> +#include <utility> #include <boost/utility.hpp> @@ -59,6 +60,9 @@ public: virtual uint32_t uri_to_id(const char* map, const char* uri); virtual const char* id_to_uri(const char* map, uint32_t id); + std::pair<bool, uint32_t> event_to_global(uint16_t event_id) const; + std::pair<bool, uint16_t> global_to_event(uint32_t global_id) const; + private: static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char* map, |