From 8ef6955d43a441a5873abaa27049041dea18f79e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 29 Sep 2008 03:17:06 +0000 Subject: * Context extension work. * Better support for set_port_value on event ports. * Don't pop audio ports when clicking in event mode. * Clicking an event port in event mode will 'bang' the event port (example 'bang' plugin prints when it receives one). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1534 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/SetPortValueEvent.cpp | 45 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'src/libs/engine/events') diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index f69ba9a3..90e66c1c 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -138,21 +138,36 @@ SetPortValueEvent::execute(ProcessContext& context) } EventBuffer* const ebuf = dynamic_cast(buf); - // FIXME: eliminate string comparisons - if (ebuf && _value.type() == Atom::BLOB - && !strcmp(_value.get_blob_type(), "lv2_midi:MidiEvent")) { - const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI); - LV2URIMap* map = (LV2URIMap*)f->controller; - const uint32_t type_id = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent"); - const uint32_t frames = std::max((uint32_t)(_time - context.start()), ebuf->latest_frames()); - ebuf->prepare_write(context.start(), context.nframes()); - // FIXME: how should this work? binary over OSC, ick - // Message is an event: - ebuf->append(frames, 0, type_id, _value.data_size(), (const uint8_t*)_value.get_blob()); - // Message is an event buffer: - //ebuf->append((LV2_Event_Buffer*)_data); - _port->raise_set_by_user_flag(); - return; + + const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI); + LV2URIMap* map = (LV2URIMap*)f->controller; + + // FIXME: eliminate lookups + // FIXME: need a proper prefix system + if (ebuf && _value.type() == Atom::BLOB) { + const uint32_t frames = std::max( + (uint32_t)(_time - context.start()), + ebuf->latest_frames()); + + // Size 0 event, pass it along to the plugin as a typed but empty event + if (_value.data_size() == 0) { + cout << "BANG!" << endl; + const uint32_t type_id = map->uri_to_id(NULL, _value.get_blob_type()); + ebuf->append(frames, 0, type_id, 0, NULL); + _port->raise_set_by_user_flag(); + return; + + } else if (!strcmp(_value.get_blob_type(), "lv2_midi:MidiEvent")) { + const uint32_t type_id = map->uri_to_id(NULL, + "http://lv2plug.in/ns/ext/midi#MidiEvent"); + + ebuf->prepare_write(context.start(), context.nframes()); + // FIXME: use OSC midi type? avoid MIDI over OSC entirely? + ebuf->append(frames, 0, type_id, _value.data_size(), + (const uint8_t*)_value.get_blob()); + _port->raise_set_by_user_flag(); + return; + } } -- cgit v1.2.1