diff options
author | David Robillard <d@drobilla.net> | 2009-11-14 20:44:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-11-14 20:44:40 +0000 |
commit | 6ae2018e81e7e81e4906e62dc6224ad34298d9c2 (patch) | |
tree | 11286438977c4f975b5148dc93b5f4dfafabdbdc /src/engine/events | |
parent | cfec427867f42d7aa7bea6dfbb0736b5ce99e9e2 (diff) | |
download | ingen-6ae2018e81e7e81e4906e62dc6224ad34298d9c2.tar.gz ingen-6ae2018e81e7e81e4906e62dc6224ad34298d9c2.tar.bz2 ingen-6ae2018e81e7e81e4906e62dc6224ad34298d9c2.zip |
Object extension.
Port resize extension.
Sensible extension(s) implementation design for Ingen.
Replace string port extension support in Ingen with Object port extension.
Implement port resize extension in Ingen.
Some test plugins for this stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2260 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events')
-rw-r--r-- | src/engine/events/ClearPatch.cpp | 2 | ||||
-rw-r--r-- | src/engine/events/Delete.cpp | 2 | ||||
-rw-r--r-- | src/engine/events/Move.cpp | 2 | ||||
-rw-r--r-- | src/engine/events/RequestMetadata.cpp | 19 | ||||
-rw-r--r-- | src/engine/events/SetPortValue.cpp | 49 | ||||
-rw-r--r-- | src/engine/events/SetPortValue.hpp | 2 |
6 files changed, 36 insertions, 40 deletions
diff --git a/src/engine/events/ClearPatch.cpp b/src/engine/events/ClearPatch.cpp index 3957294e..92c0156c 100644 --- a/src/engine/events/ClearPatch.cpp +++ b/src/engine/events/ClearPatch.cpp @@ -117,7 +117,7 @@ ClearPatch::execute(ProcessContext& context) if (port && port->type() == DataType::AUDIO) { _driver_ports->push_back( _engine.audio_driver()->remove_port(port->path())); - } else if (port && port->type() == DataType::EVENT) { + } else if (port && port->type() == DataType::EVENTS) { _driver_ports->push_back( _engine.midi_driver()->remove_port(port->path())); } diff --git a/src/engine/events/Delete.cpp b/src/engine/events/Delete.cpp index d8a8bef9..aa773176 100644 --- a/src/engine/events/Delete.cpp +++ b/src/engine/events/Delete.cpp @@ -155,7 +155,7 @@ Delete::execute(ProcessContext& context) if ( ! _port->parent_patch()->parent()) { if (_port->type() == DataType::AUDIO) _driver_port = _engine.audio_driver()->remove_port(_port->path()); - else if (_port->type() == DataType::EVENT) + else if (_port->type() == DataType::EVENTS) _driver_port = _engine.midi_driver()->remove_port(_port->path()); // Apparently this needs to be called in post_process?? diff --git a/src/engine/events/Move.cpp b/src/engine/events/Move.cpp index 1b12819e..9782e0d6 100644 --- a/src/engine/events/Move.cpp +++ b/src/engine/events/Move.cpp @@ -108,7 +108,7 @@ Move::execute(ProcessContext& context) if (port->type() == DataType::AUDIO) driver_port = _engine.audio_driver()->driver_port(_new_path); - else if (port->type() == DataType::EVENT) + else if (port->type() == DataType::EVENTS) driver_port = _engine.midi_driver()->driver_port(_new_path); if (driver_port) diff --git a/src/engine/events/RequestMetadata.cpp b/src/engine/events/RequestMetadata.cpp index e633ca10..06069f74 100644 --- a/src/engine/events/RequestMetadata.cpp +++ b/src/engine/events/RequestMetadata.cpp @@ -17,15 +17,17 @@ #include "interface/ClientInterface.hpp" #include "events/RequestMetadata.hpp" -#include "Responder.hpp" +#include "shared/LV2Object.hpp" +#include "AudioBuffer.hpp" +#include "ClientBroadcaster.hpp" #include "Engine.hpp" -#include "GraphObjectImpl.hpp" #include "EngineStore.hpp" -#include "ClientBroadcaster.hpp" -#include "PortImpl.hpp" +#include "GraphObjectImpl.hpp" +#include "ObjectBuffer.hpp" #include "PluginImpl.hpp" -#include "AudioBuffer.hpp" -#include "StringBuffer.hpp" +#include "PortImpl.hpp" +#include "ProcessContext.hpp" +#include "Responder.hpp" using namespace std; using namespace Raul; @@ -94,8 +96,9 @@ RequestMetadata::execute(ProcessContext& context) if (port) { if (port->type() == DataType::CONTROL || port->type() == DataType::AUDIO) _value = ((AudioBuffer*)port->buffer(0))->value_at(0); // TODO: offset - else if (port->type() == DataType::STRING) - _value = (char*)((StringBuffer*)port->buffer(0))->data(); + else if (port->type() == DataType::OBJECT) + LV2Object::to_atom(context.engine().world(), + ((ObjectBuffer*)port->buffer(0))->data(), _value); } else { _resource = 0; } diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp index 1964880d..6b9d8d9e 100644 --- a/src/engine/events/SetPortValue.cpp +++ b/src/engine/events/SetPortValue.cpp @@ -19,6 +19,7 @@ #include "event.lv2/event.h" #include "shared/LV2URIMap.hpp" #include "shared/LV2Features.hpp" +#include "shared/LV2Object.hpp" #include "module/World.hpp" #include "AudioBuffer.hpp" #include "ClientBroadcaster.hpp" @@ -27,11 +28,11 @@ #include "EventBuffer.hpp" #include "MessageContext.hpp" #include "NodeImpl.hpp" +#include "ObjectBuffer.hpp" #include "PortImpl.hpp" #include "ProcessContext.hpp" #include "Responder.hpp" #include "SetPortValue.hpp" -#include "StringBuffer.hpp" using namespace std; using namespace Raul; @@ -115,7 +116,8 @@ SetPortValue::pre_process() // Port is a message context port, set its value and // call the plugin's message run function once if (_port && _port->context() == Context::MESSAGE) { - apply(0, 0); + apply(*_engine.message_context()); + _port->parent_node()->set_port_valid(_port->index()); _engine.message_context()->run(_port->parent_node()); } @@ -132,13 +134,14 @@ SetPortValue::execute(ProcessContext& context) if (_port && _port->context() == Context::MESSAGE) return; - apply(context.start(), context.nframes()); + apply(context); } void -SetPortValue::apply(uint32_t start, uint32_t nframes) +SetPortValue::apply(Context& context) { + uint32_t start = context.start(); if (_error == NO_ERROR && !_port) _port = _engine.engine_store()->find_port(_port_path); @@ -170,15 +173,12 @@ SetPortValue::apply(uint32_t start, uint32_t nframes) return; } - const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI); - LV2URIMap* map = (LV2URIMap*)f->controller; + SharedPtr<LV2URIMap> map = PtrCast<LV2URIMap>( + _engine.world()->lv2_features->feature(LV2_URI_MAP_URI)); - // TODO: eliminate lookups EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf); if (ebuf) { - const uint32_t frames = std::max( - uint32_t(_time - start), - ebuf->latest_frames()); + const uint32_t frames = std::max(uint32_t(_time - start), ebuf->latest_frames()); // Size 0 event, pass it along to the plugin as a typed but empty event if (_value.data_size() == 0) { @@ -188,34 +188,27 @@ SetPortValue::apply(uint32_t start, uint32_t nframes) return; } else if (!strcmp(_value.get_blob_type(), "lv2midi:MidiEvent")) { - const uint32_t type_id = map->uri_to_id(NULL, - "http://lv2plug.in/ns/ext/midi#MidiEvent"); - - ebuf->prepare_write(start, nframes); - // FIXME: use OSC midi type? avoid MIDI over OSC entirely? - ebuf->append(frames, 0, type_id, _value.data_size(), + ebuf->prepare_write(context); + ebuf->append(frames, 0, map->midi_event, _value.data_size(), (const uint8_t*)_value.get_blob()); _port->raise_set_by_user_flag(); return; } } - StringBuffer* const sbuf = dynamic_cast<StringBuffer*>(buf); - if (sbuf) { - if (_value.type() != Atom::STRING) { - _error = TYPE_MISMATCH; + ObjectBuffer* const obuf = dynamic_cast<ObjectBuffer*>(buf); + if (obuf) { + obuf->data()->size = obuf->size() - sizeof(LV2_Object); + if (LV2Object::from_atom(_engine.world(), _value, obuf->data())) { + cout << "Converted atom " << _value << " :: " << obuf->data()->type + << " * " << obuf->data()->size << " @ " << obuf->data() << endl; return; + } else { + cerr << "WARNING: Failed to convert atom to LV2 object" << endl; } - strncpy(sbuf->data(), _value.get_string(), - std::min(sbuf->size(), strlen(_value.get_string()))); - return; } - - if (_value.type() == Atom::BLOB) - cerr << "WARNING: Unknown value blob type " << _value.get_blob_type() << endl; - else - cerr << "WARNING: Unknown value type " << (int)_value.type() << endl; + cerr << "WARNING: Unknown value type " << (int)_value.type() << endl; } } diff --git a/src/engine/events/SetPortValue.hpp b/src/engine/events/SetPortValue.hpp index 87f4f6f6..aab59811 100644 --- a/src/engine/events/SetPortValue.hpp +++ b/src/engine/events/SetPortValue.hpp @@ -77,7 +77,7 @@ private: TYPE_MISMATCH }; - void apply(uint32_t start, uint32_t nframes); + void apply(Context& context); bool _queued; bool _omni; |