diff options
author | David Robillard <d@drobilla.net> | 2012-03-19 20:16:46 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-19 20:16:46 +0000 |
commit | 254b434f0a79fea54bd963e8ff2e845a5b0cd3a6 (patch) | |
tree | ddf849fc5b64d1096846c28c1f1a742f54c3adff /src/server/events | |
parent | bc3afd8380d59c750c8f8e9bf1ed1b8d4a6826e9 (diff) | |
download | ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.tar.gz ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.tar.bz2 ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.zip |
Partially functioning communication between Ingen LV2 plugin and UI.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4078 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/events')
-rw-r--r-- | src/server/events/CreateNode.cpp | 2 | ||||
-rw-r--r-- | src/server/events/CreatePort.cpp | 40 | ||||
-rw-r--r-- | src/server/events/CreatePort.hpp | 9 | ||||
-rw-r--r-- | src/server/events/SetMetadata.cpp | 14 | ||||
-rw-r--r-- | src/server/events/SetPortValue.cpp | 45 |
5 files changed, 38 insertions, 72 deletions
diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index d74b0b6c..7098196a 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -61,7 +61,7 @@ CreateNode::CreateNode(Engine& engine, { const Resource::Properties::const_iterator p = properties.find( engine.world()->uris()->ingen_polyphonic); - if (p != properties.end() && p->second.type() == Raul::Atom::BOOL + if (p != properties.end() && p->second.type() == engine.world()->forge().Bool && p->second.get_bool()) _polyphonic = true; } diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 6fa4a6bf..cc6f7e93 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -49,7 +49,8 @@ CreatePort::CreatePort(Engine& engine, const Resource::Properties& properties) : Event(engine, client, id, timestamp) , _path(path) - , _data_type(PortType::UNKNOWN) + , _port_type(PortType::UNKNOWN) + , _buffer_type(0) , _patch(NULL) , _patch_port(NULL) , _ports_array(NULL) @@ -61,30 +62,31 @@ CreatePort::CreatePort(Engine& engine, typedef Resource::Properties::const_iterator Iterator; typedef std::pair<Iterator, Iterator> Range; + const Range types = properties.equal_range(uris.rdf_type); for (Iterator i = types.first; i != types.second; ++i) { const Raul::Atom& type = i->second; - if (type.type() != Atom::URI) { - warn << "Non-URI port type " << type << endl; - continue; - } - if (type == uris.lv2_AudioPort) { - _data_type = PortType::AUDIO; + _port_type = PortType::AUDIO; } else if (type == uris.lv2_ControlPort) { - _data_type = PortType::CONTROL; + _port_type = PortType::CONTROL; } else if (type == uris.cv_CVPort) { - _data_type = PortType::CV; - } else if (type == uris.ev_EventPort) { - _data_type = PortType::EVENTS; + _port_type = PortType::CV; } else if (type == uris.atom_ValuePort) { - _data_type = PortType::VALUE; + _port_type = PortType::VALUE; } else if (type == uris.atom_MessagePort) { - _data_type = PortType::MESSAGE; + _port_type = PortType::MESSAGE; + } + } + + const Range buffer_types = properties.equal_range(uris.atom_bufferType); + for (Iterator i = buffer_types.first; i != buffer_types.second; ++i) { + if (i->second.type() == _engine.world()->forge().URI) { + _buffer_type = _engine.world()->lv2_uri_map()->map_uri(i->second.get_uri()); } } - if (_data_type == PortType::UNKNOWN) { + if (_port_type == PortType::UNKNOWN) { _status = UNKNOWN_TYPE; } } @@ -104,7 +106,7 @@ CreatePort::pre_process() if (_patch != NULL) { assert(_patch->path() == _path.parent()); - size_t buffer_size = _engine.buffer_factory()->default_buffer_size(_data_type); + size_t buffer_size = _engine.buffer_factory()->default_buffer_size(_buffer_type); const uint32_t old_num_ports = (_patch->external_ports()) ? _patch->external_ports()->size() @@ -115,7 +117,7 @@ CreatePort::pre_process() index_i = _properties.insert( make_pair(uris.lv2_index, _engine.world()->forge().make(int32_t(old_num_ports)))); - } else if (index_i->second.type() != Atom::INT + } else if (index_i->second.type() != uris.forge.Int || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) { Event::pre_process(); _status = BAD_INDEX; @@ -123,10 +125,12 @@ CreatePort::pre_process() } Resource::Properties::const_iterator poly_i = _properties.find(uris.ingen_polyphonic); - bool polyphonic = (poly_i != _properties.end() && poly_i->second.type() == Atom::BOOL + bool polyphonic = (poly_i != _properties.end() && poly_i->second.type() == uris.forge.Bool && poly_i->second.get_bool()); - _patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(), _data_type, buffer_size, _is_output, polyphonic); + _patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(), + _port_type, _buffer_type, buffer_size, + _is_output, polyphonic); _patch_port->properties().insert(_properties.begin(), _properties.end()); diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index 331a1252..45fedebc 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -18,13 +18,13 @@ #ifndef INGEN_EVENTS_CREATEPORT_HPP #define INGEN_EVENTS_CREATEPORT_HPP +#include "ingen/Resource.hpp" +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "raul/Array.hpp" #include "raul/Path.hpp" -#include "ingen/Resource.hpp" - -#include "PortType.hpp" #include "Event.hpp" +#include "PortType.hpp" namespace Ingen { namespace Server { @@ -57,7 +57,8 @@ public: private: Raul::Path _path; Raul::URI _type; - PortType _data_type; + PortType _port_type; + LV2_URID _buffer_type; PatchImpl* _patch; PortImpl* _patch_port; Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index e2621fae..1c4ac0e6 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -129,7 +129,7 @@ SetMetadata::pre_process() if (is_patch) { uint32_t poly = 1; iterator p = _properties.find(uris.ingen_polyphony); - if (p != _properties.end() && p->second.is_valid() && p->second.type() == Atom::INT) + if (p != _properties.end() && p->second.is_valid() && p->second.type() == uris.forge.Int) poly = p->second.get_int32(); _create_event = new CreatePatch(_engine, _request_client, _request_id, _time, path, poly, _properties); @@ -186,7 +186,7 @@ SetMetadata::pre_process() PortImpl* port = dynamic_cast<PortImpl*>(_object); if (port) { if (key == uris.ingen_broadcast) { - if (value.type() == Atom::BOOL) { + if (value.type() == uris.forge.Bool) { op = ENABLE_BROADCAST; } else { _status = BAD_VALUE_TYPE; @@ -200,7 +200,7 @@ SetMetadata::pre_process() if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) { if (value == uris.wildcard) { _engine.control_bindings()->learn(port); - } else if (value.type() == Atom::DICT) { + } else if (value.type() == uris.forge.Dict) { op = CONTROL_BINDING; } else { _status = BAD_VALUE_TYPE; @@ -211,7 +211,7 @@ SetMetadata::pre_process() } } else if ((_patch = dynamic_cast<PatchImpl*>(_object))) { if (key == uris.ingen_enabled) { - if (value.type() == Atom::BOOL) { + if (value.type() == uris.forge.Bool) { op = ENABLE; // FIXME: defer this until all other metadata has been processed if (value.get_bool() && !_patch->enabled()) @@ -220,7 +220,7 @@ SetMetadata::pre_process() _status = BAD_VALUE_TYPE; } } else if (key == uris.ingen_polyphony) { - if (value.type() == Atom::INT) { + if (value.type() == uris.forge.Int) { op = POLYPHONY; _patch->prepare_internal_poly(*_engine.buffer_factory(), value.get_int32()); } else { @@ -230,7 +230,7 @@ SetMetadata::pre_process() } else if (key == uris.ingen_polyphonic) { PatchImpl* parent = dynamic_cast<PatchImpl*>(obj->parent()); if (parent) { - if (value.type() == Atom::BOOL) { + if (value.type() == uris.forge.Bool) { op = POLYPHONIC; obj->set_property(key, value, value.context()); NodeImpl* node = dynamic_cast<NodeImpl*>(obj); @@ -288,7 +288,7 @@ SetMetadata::execute(ProcessContext& context) std::vector<SpecialType>::const_iterator t = _types.begin(); for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p, ++t) { - const Raul::Atom& key = p->first; + const Raul::URI& key = p->first; const Raul::Atom& value = p->second; switch (*t) { case ENABLE_BROADCAST: diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index ecf9416e..00f72a51 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -22,7 +22,6 @@ #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/URIs.hpp" #include "ingen/shared/World.hpp" -#include "lv2/lv2plug.in/ns/ext/event/event.h" #include "raul/log.hpp" #include "AudioBuffer.hpp" @@ -31,10 +30,8 @@ #include "Driver.hpp" #include "Engine.hpp" #include "EngineStore.hpp" -#include "EventBuffer.hpp" #include "MessageContext.hpp" #include "NodeImpl.hpp" -#include "ObjectBuffer.hpp" #include "PortImpl.hpp" #include "ProcessContext.hpp" #include "SetPortValue.hpp" @@ -129,6 +126,8 @@ SetPortValue::apply(Context& context) if (_status == SUCCESS && !_port) _port = _engine.engine_store()->find_port(_port_path); + Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + if (!_port) { if (_status == SUCCESS) _status = PORT_NOT_FOUND; @@ -138,7 +137,7 @@ SetPortValue::apply(Context& context) Buffer* const buf = _port->buffer(0).get(); AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf); if (abuf) { - if (_value.type() != Atom::FLOAT) { + if (_value.type() != uris.forge.Float) { _status = TYPE_MISMATCH; return; } @@ -150,44 +149,6 @@ SetPortValue::apply(Context& context) return; } - Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); - Ingen::Shared::LV2URIMap& uri_map = *_engine.world()->lv2_uri_map().get(); - - EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf); - if (ebuf && _value.type() == Atom::BLOB) { - 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) { - const uint32_t type_id = uri_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(), - "http://lv2plug.in/ns/ext/midi#MidiEvent")) { - ebuf->prepare_write(context); - ebuf->append(frames, 0, - uri_map.global_to_event(uris.midi_MidiEvent.id).second, - _value.data_size(), - (const uint8_t*)_value.get_blob()); - _port->raise_set_by_user_flag(); - return; - } - } - - ObjectBuffer* const obuf = dynamic_cast<ObjectBuffer*>(buf); - if (obuf) { - obuf->atom()->size = obuf->size() - sizeof(LV2_Atom); - if (Ingen::Shared::LV2Atom::from_atom(uris, _value, obuf->atom())) { - debug << "Converted atom " << _value << " :: " << obuf->atom()->type - << " * " << obuf->atom()->size << " @ " << obuf->atom() << endl; - return; - } else { - warn << "Failed to convert atom to LV2 object" << endl; - } - } - warn << "Unknown value type " << (int)_value.type() << endl; } } |