From 5a1ccca68baf9e8efffe3e0297730a911617693d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 17 Oct 2010 01:11:29 +0000 Subject: Support current versions of LV2 atom, atom-port, and context extensions. Working use case in this revision: lolep.parse => lolep.print (set parse input to some string, it will be parsed, send to print as an LV2 atom, then printed to the console by print). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2631 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/PortModel.cpp | 3 ++- src/common/interface/PortType.hpp | 4 ++-- src/engine/AudioBuffer.cpp | 4 ++-- src/engine/AudioBuffer.hpp | 6 +++--- src/engine/BufferFactory.cpp | 4 ++-- src/engine/ConnectionImpl.cpp | 22 +++++++++++++++++----- src/engine/InputPort.cpp | 6 ++++-- src/engine/LV2BlobFeature.hpp | 34 +++++++++++++++++----------------- src/engine/LV2Info.cpp | 6 ++++-- src/engine/LV2Node.cpp | 14 +++++++------- src/engine/ObjectBuffer.cpp | 4 ++-- src/engine/PortImpl.cpp | 2 +- src/gui/Configuration.cpp | 15 +++++++++------ src/gui/Configuration.hpp | 1 + src/gui/Port.cpp | 2 -- src/gui/PropertiesWindow.hpp | 2 +- src/module/World.cpp | 4 +++- src/shared/LV2URIMap.cpp | 7 +++---- src/shared/LV2URIMap.hpp | 7 +++---- src/shared/ResourceImpl.cpp | 4 ++-- 20 files changed, 85 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index f3ff819f..c473772e 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -19,6 +19,7 @@ #include "PortModel.hpp" #include "NodeModel.hpp" + namespace Ingen { namespace Client { @@ -37,7 +38,7 @@ PortModel::set_property(const Raul::URI& uri, bool PortModel::supports(const Raul::URI& value_type) const { - return has_property(_uris.obj_supports, value_type); + return has_property(_uris.aport_supports, value_type); } diff --git a/src/common/interface/PortType.hpp b/src/common/interface/PortType.hpp index 89cb1e91..192ea458 100644 --- a/src/common/interface/PortType.hpp +++ b/src/common/interface/PortType.hpp @@ -84,8 +84,8 @@ private: "http://lv2plug.in/ns/lv2core#AudioPort", "http://lv2plug.in/ns/lv2core#ControlPort", "http://lv2plug.in/ns/ext/event#EventPort", - "http://lv2plug.in/ns/ext/objects#ValuePort", - "http://lv2plug.in/ns/ext/objects#MessagePort" + "http://lv2plug.in/ns/ext/atom-port#ValuePort", + "http://lv2plug.in/ns/ext/atom-port#MessagePort" }; return uris[symbol_num]; } diff --git a/src/engine/AudioBuffer.cpp b/src/engine/AudioBuffer.cpp index 56ae2b57..33394254 100644 --- a/src/engine/AudioBuffer.cpp +++ b/src/engine/AudioBuffer.cpp @@ -55,7 +55,7 @@ AudioBuffer::AudioBuffer(BufferFactory& bufs, Shared::PortType type, size_t size } else { assert(type == PortType::AUDIO); atom()->type = 0;//map->vector_type; - LV2_Vector_Body* body = (LV2_Vector_Body*)atom()->body; + LV2_Atom_Vector* body = (LV2_Atom_Vector*)atom()->body; body->elem_count = size / sizeof(Sample); body->elem_type = 0;//map->float_type; } @@ -75,7 +75,7 @@ void AudioBuffer::resize(size_t size) { if (_type == PortType::AUDIO) { - ObjectBuffer::resize(size + sizeof(LV2_Vector_Body)); + ObjectBuffer::resize(size + sizeof(LV2_Atom_Vector)); vector()->elem_count = size / sizeof(Sample); } clear(); diff --git a/src/engine/AudioBuffer.hpp b/src/engine/AudioBuffer.hpp index 7c6115e2..38623696 100644 --- a/src/engine/AudioBuffer.hpp +++ b/src/engine/AudioBuffer.hpp @@ -48,13 +48,13 @@ public: inline Sample* data() const { return (is_control()) ? (Sample*)atom()->body - : (Sample*)(atom()->body + sizeof(LV2_Vector_Body)); + : (Sample*)(atom()->body + sizeof(LV2_Atom_Vector)); } inline SampleCount nframes() const { return (is_control()) ? 1 - : (_size - sizeof(LV2_Atom) - sizeof(LV2_Vector_Body)) / sizeof(Sample); + : (_size - sizeof(LV2_Atom) - sizeof(LV2_Atom_Vector)) / sizeof(Sample); } inline Sample& value_at(size_t offset) const @@ -68,7 +68,7 @@ public: private: enum State { OK, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; - LV2_Vector_Body* vector() { return(LV2_Vector_Body*)atom()->body; } + LV2_Atom_Vector* vector() { return(LV2_Atom_Vector*)atom()->body; } State _state; ///< State of buffer for setting values next cycle Sample _set_value; ///< Value set by set_value (for completing the set next cycle) diff --git a/src/engine/BufferFactory.cpp b/src/engine/BufferFactory.cpp index b048be28..75803649 100644 --- a/src/engine/BufferFactory.cpp +++ b/src/engine/BufferFactory.cpp @@ -70,7 +70,7 @@ BufferFactory::set_block_length(SampleCount block_length) size_t BufferFactory::audio_buffer_size(SampleCount nframes) { - return sizeof(LV2_Atom) + sizeof(LV2_Vector_Body) + (nframes * sizeof(float)); + return sizeof(LV2_Atom) + sizeof(LV2_Atom_Vector) + (nframes * sizeof(float)); } @@ -134,7 +134,7 @@ BufferFactory::create(Shared::PortType type, size_t size) if (type.is_control()) { AudioBuffer* ret = new AudioBuffer(*this, type, size); ret->atom()->type = _uris->object_class_vector.id; - ((LV2_Vector_Body*)ret->atom()->body)->elem_type = _uris->object_class_float32.id; + ((LV2_Atom_Vector*)ret->atom()->body)->elem_type = _uris->object_class_float32.id; buffer = ret; } else if (type.is_audio()) { AudioBuffer* ret = new AudioBuffer(*this, type, size); diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp index c308cea5..43f9136a 100644 --- a/src/engine/ConnectionImpl.cpp +++ b/src/engine/ConnectionImpl.cpp @@ -129,16 +129,28 @@ ConnectionImpl::can_connect(const OutputPort* src, const InputPort* dst) { const LV2URIMap& uris = src->bufs().uris(); return ( + // (Audio | Control) => (Audio | Control) ( (src->is_a(PortType::CONTROL) || src->is_a(PortType::AUDIO)) && (dst->is_a(PortType::CONTROL) || dst->is_a(PortType::AUDIO))) - || ( src->is_a(PortType::EVENTS) && src->context() == Context::AUDIO - && dst->is_a(PortType::MESSAGE) && dst->context() == Context::MESSAGE) - || ( src->is_a(PortType::MESSAGE) && src->context() == Context::MESSAGE - && dst->is_a(PortType::EVENTS) && dst->context() == Context::AUDIO) - || (src->is_a(PortType::EVENTS) && dst->is_a(PortType::EVENTS)) + + // (Events | Message) => (Events | Message) + || ( (src->is_a(PortType::EVENTS) || src->is_a(PortType::MESSAGE)) + && (dst->is_a(PortType::EVENTS) || dst->is_a(PortType::MESSAGE))) + + // (Message | Value) => (Message | Value) + || ( (src->is_a(PortType::MESSAGE) || src->is_a(PortType::VALUE)) + && (dst->is_a(PortType::MESSAGE) || dst->is_a(PortType::VALUE))) + + // Control => atom:Float32 Value || (src->is_a(PortType::CONTROL) && dst->supports(uris.object_class_float32)) + + // Audio => atom:Vector Value || (src->is_a(PortType::AUDIO) && dst->supports(uris.object_class_vector)) + + // atom:Float32 Value => Control || (src->supports(uris.object_class_float32) && dst->is_a(PortType::CONTROL)) + + // atom:Vector Value => Audio || (src->supports(uris.object_class_vector) && dst->is_a(PortType::AUDIO))); } diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp index 95ff2d37..0cd6e87a 100644 --- a/src/engine/InputPort.cpp +++ b/src/engine/InputPort.cpp @@ -217,8 +217,10 @@ InputPort::post_process(Context& context) bool InputPort::direct_connect() const { - return _connections.size() == 1 && !_connections.front()->must_mix() - && !_connections.front()->must_queue(); + return (context() == Context::AUDIO) + && _connections.size() == 1 + && !_connections.front()->must_mix() + && !_connections.front()->must_queue(); } diff --git a/src/engine/LV2BlobFeature.hpp b/src/engine/LV2BlobFeature.hpp index 78ed1ac0..b071a067 100644 --- a/src/engine/LV2BlobFeature.hpp +++ b/src/engine/LV2BlobFeature.hpp @@ -25,31 +25,31 @@ namespace Ingen { struct BlobFeature : public Shared::LV2Features::Feature { BlobFeature() { LV2_Blob_Support* data = (LV2_Blob_Support*)malloc(sizeof(LV2_Blob_Support)); - data->data = NULL; - data->reference_size = sizeof(LV2_Blob*); - data->lv2_blob_new = &blob_new; - data->lv2_reference_get = &reference_get; - data->lv2_reference_copy = &reference_copy; - data->lv2_reference_reset = &reference_reset; - _feature.URI = LV2_BLOB_SUPPORT_URI; - _feature.data = data; + data->data = NULL; + data->ref_size = sizeof(LV2_Blob*); + data->blob_new = &blob_new; + data->ref_get = &ref_get; + data->ref_copy = &ref_copy; + data->ref_reset = &ref_reset; + _feature.URI = LV2_BLOB_SUPPORT_URI; + _feature.data = data; } static void blob_new(LV2_Blob_Support_Data data, - LV2_Reference* reference, - LV2_Blob_Destroy destroy_func, + LV2_Atom* reference, + LV2_Blob_Destroy destroy, uint32_t type, size_t size) {} - static LV2_Blob* reference_get(LV2_Blob_Support_Data data, - LV2_Reference* ref) { return 0; } + static LV2_Blob* ref_get(LV2_Blob_Support_Data data, + LV2_Atom* ref) { return 0; } - static void reference_copy(LV2_Blob_Support_Data data, - LV2_Reference* dst, - LV2_Reference* src) {} + static void ref_copy(LV2_Blob_Support_Data data, + LV2_Atom* dst, + LV2_Atom* src) {} - static void reference_reset(LV2_Blob_Support_Data data, - LV2_Reference* ref) {} + static void ref_reset(LV2_Blob_Support_Data data, + LV2_Atom* ref) {} SharedPtr feature(Shared::Node*) { return SharedPtr(&_feature, NullDeleter); diff --git a/src/engine/LV2Info.cpp b/src/engine/LV2Info.cpp index 0c226c65..c96d5874 100644 --- a/src/engine/LV2Info.cpp +++ b/src/engine/LV2Info.cpp @@ -36,8 +36,10 @@ LV2Info::LV2Info(Ingen::Shared::World* world) , control_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_CONTROL)) , audio_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_AUDIO)) , event_class(slv2_value_new_uri(world->slv2_world(), SLV2_PORT_CLASS_EVENT)) - , value_port_class(slv2_value_new_uri(world->slv2_world(), LV2_ATOM_URI "#ValuePort")) - , message_port_class(slv2_value_new_uri(world->slv2_world(), LV2_ATOM_URI "#MessagePort")) + , value_port_class(slv2_value_new_uri(world->slv2_world(), + "http://lv2plug.in/ns/ext/atom-port#ValuePort")) + , message_port_class(slv2_value_new_uri(world->slv2_world(), + "http://lv2plug.in/ns/ext/atom-port#MessagePort")) , _world(world) { assert(world); diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp index 872a7b83..e2b4b2cd 100644 --- a/src/engine/LV2Node.cpp +++ b/src/engine/LV2Node.cpp @@ -160,7 +160,8 @@ LV2Node::instantiate(BufferFactory& bufs) slv2_instance_free); if (!instance(i)) { - error << "Failed to instantiate plugin" << endl; + error << "Failed to instantiate plugin " << _lv2_plugin->uri() + << " voice " << i << endl; return false; } @@ -203,7 +204,7 @@ LV2Node::instantiate(BufferFactory& bufs) "http://lv2plug.in/ns/lv2core#portProperty"); SLV2Value supports_pred = slv2_value_new_uri(info->lv2_world(), - LV2_ATOM_URI "#supports"); + "http://lv2plug.in/ns/ext/atom-port#supports"); //SLV2Value as_large_as_pred = slv2_value_new_uri(info->lv2_world(), // "http://lv2plug.in/ns/ext/resize-port#asLargeAs"); @@ -273,6 +274,7 @@ LV2Node::instantiate(BufferFactory& bufs) } if (data_type == PortType::UNKNOWN || direction == UNKNOWN) { + warn << "Unknown type or direction for port `" << port_name << "'" << endl; ret = false; break; } @@ -306,14 +308,12 @@ LV2Node::instantiate(BufferFactory& bufs) } } - // Set obj:supports properties + // Set aport:supports properties SLV2Values types = slv2_port_get_value(plug, id, supports_pred); for (uint32_t i = 0; i < slv2_values_size(types); ++i) { SLV2Value type = slv2_values_get_at(types, i); - Raul::info << path() << " port " << id << " supports " << - slv2_value_as_uri(type) << std::endl; if (slv2_value_is_uri(type)) { - port->add_property(uris.obj_supports, Raul::URI(slv2_value_as_uri(type))); + port->add_property(uris.aport_supports, Raul::URI(slv2_value_as_uri(type))); } } @@ -390,7 +390,7 @@ LV2Node::message_run(MessageContext& context) _valid_ports = calloc(num_ports() / 8, 1); if (_message_funcs) - (*_message_funcs->message_run)(instance(0)->lv2_handle, _valid_ports, _valid_ports); + (*_message_funcs->run)(instance(0)->lv2_handle, _valid_ports, _valid_ports); } diff --git a/src/engine/ObjectBuffer.cpp b/src/engine/ObjectBuffer.cpp index aabe2be3..9ae153f5 100644 --- a/src/engine/ObjectBuffer.cpp +++ b/src/engine/ObjectBuffer.cpp @@ -111,7 +111,7 @@ ObjectBuffer::port_data(PortType port_type, SampleCount offset) case PortType::CONTROL: return (float*)atom()->body; case PortType::AUDIO: - return (float*)((LV2_Vector_Body*)atom()->body)->elems + offset; + return (float*)((LV2_Atom_Vector*)atom()->body)->elems + offset; default: warn << "Audio data requested from non-audio buffer" << endl; return NULL; @@ -133,7 +133,7 @@ ObjectBuffer::port_data(PortType port_type, SampleCount offset) const case PortType::CONTROL: return (float*)atom()->body; case PortType::AUDIO: - return (float*)((LV2_Vector_Body*)atom()->body)->elems + offset; + return (float*)((LV2_Atom_Vector*)atom()->body)->elems + offset; default: warn << "Audio data requested from non-audio buffer" << endl; return NULL; diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp index 32105dfe..60d2ea26 100644 --- a/src/engine/PortImpl.cpp +++ b/src/engine/PortImpl.cpp @@ -88,7 +88,7 @@ PortImpl::~PortImpl() bool PortImpl::supports(const Raul::URI& value_type) const { - return has_property(_bufs.uris().obj_supports, value_type); + return has_property(_bufs.uris().aport_supports, value_type); } diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp index f6b0ee0e..6a6c2914 100644 --- a/src/gui/Configuration.cpp +++ b/src/gui/Configuration.cpp @@ -24,6 +24,7 @@ #include "client/PortModel.hpp" #include "client/PluginModel.hpp" #include "serialisation/Parser.hpp" +#include "shared/LV2URIMap.hpp" #include "flowcanvas/Port.hpp" #include "App.hpp" #include "Port.hpp" @@ -40,11 +41,11 @@ using namespace Ingen::Client; Configuration::Configuration() // Colours from the Tango palette with modified V and alpha : _name_style(HUMAN) - , _audio_port_color( 0x244678C0) - , _control_port_color(0x4A8A0EC0) - , _event_port_color( 0x960909C0) -// , _osc_port_color( 0x5C3566C0) - , _value_port_color( 0x4A4A4AC0) + , _audio_port_color( 0x244678C0) // Blue + , _control_port_color(0x4A8A0EC0) // Green + , _event_port_color( 0x960909C0) // Red + , _string_port_color( 0x5C3566C0) // Plum + , _value_port_color( 0xBABDB6C0) // Aluminum { } @@ -88,9 +89,11 @@ uint32_t Configuration::get_port_color(const PortModel* p) { assert(p != NULL); - + const Shared::LV2URIMap& uris = App::instance().uris(); if (p->is_a(Shared::PortType::AUDIO)) { return _audio_port_color; + } else if (p->supports(uris.object_class_string)) { + return _string_port_color; } else if (App::instance().can_control(p)) { return _control_port_color; } else if (p->is_a(Shared::PortType::EVENTS) || p->is_a(Shared::PortType::MESSAGE)) { diff --git a/src/gui/Configuration.hpp b/src/gui/Configuration.hpp index 5586a3c0..be13bcc8 100644 --- a/src/gui/Configuration.hpp +++ b/src/gui/Configuration.hpp @@ -68,6 +68,7 @@ private: uint32_t _audio_port_color; uint32_t _control_port_color; uint32_t _event_port_color; + uint32_t _string_port_color; uint32_t _value_port_color; }; diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 0dbb05cf..4102a52c 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -154,8 +154,6 @@ Port::value_changed(const Atom& value) return; else if (value.type() == Atom::FLOAT) FlowCanvas::Port::set_control(value.get_float()); - else - warn << "Unknown port value type " << (unsigned)value.type() << endl; } diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index 157a76b5..1ce4005f 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -30,7 +30,7 @@ namespace Ingen { namespace GUI { -/** Node properties window. +/** Object properties window. * * Loaded by libglade as a derived object. * diff --git a/src/module/World.cpp b/src/module/World.cpp index 2296d928..eddeda73 100644 --- a/src/module/World.cpp +++ b/src/module/World.cpp @@ -126,7 +126,9 @@ struct WorldImpl : public boost::noncopyable { rdf_world->add_prefix("midi", "http://drobilla.net/ns/ext/midi#"); rdf_world->add_prefix("owl", "http://www.w3.org/2002/07/owl#"); rdf_world->add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); - rdf_world->add_prefix("sp", "http://lv2plug.in/ns/ext/string-port#"); + rdf_world->add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); + rdf_world->add_prefix("atom", "http://lv2plug.in/ns/ext/atom#"); + rdf_world->add_prefix("aport", "http://lv2plug.in/ns/ext/atom-port#"); rdf_world->add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); } diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index b563a0d0..d77721d1 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -96,9 +96,9 @@ LV2URIMap::LV2URIMap() , midi_controllerNumber(NS_MIDI "controllerNumber") , midi_event("http://lv2plug.in/ns/ext/midi#MidiEvent") , midi_noteNumber(NS_MIDI "noteNumber") - , obj_MessagePort("http://lv2plug.in/ns/ext/objects#MessagePort") - , obj_ValuePort("http://lv2plug.in/ns/ext/objects#ValuePort") - , obj_supports("http://lv2plug.in/ns/ext/objects#supports") + , aport_MessagePort("http://lv2plug.in/ns/ext/atom-port#MessagePort") + , aport_ValuePort("http://lv2plug.in/ns/ext/atom-port#ValuePort") + , aport_supports("http://lv2plug.in/ns/ext/atom-port#supports") , object_class_bool(LV2_ATOM_URI "#Bool") , object_class_float32(LV2_ATOM_URI "#Float32") , object_class_int32(LV2_ATOM_URI "#Int32") @@ -108,7 +108,6 @@ LV2URIMap::LV2URIMap() , rdf_instanceOf(NS_RDF "instanceOf") , rdf_type(NS_RDF "type") , rdfs_seeAlso(NS_RDFS "seeAlso") - , string_transfer("http://lv2plug.in/ns/ext/string-port#StringTransfer") , ui_format_events("http://lv2plug.in/ns/extensions/ui#Events") , wildcard(NS_INGEN "wildcard") { diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp index d53458fc..7ee732dc 100644 --- a/src/shared/LV2URIMap.hpp +++ b/src/shared/LV2URIMap.hpp @@ -98,9 +98,9 @@ public: const Quark midi_controllerNumber; const Quark midi_event; const Quark midi_noteNumber; - const Quark obj_MessagePort; - const Quark obj_ValuePort; - const Quark obj_supports; + const Quark aport_MessagePort; + const Quark aport_ValuePort; + const Quark aport_supports; const Quark object_class_bool; const Quark object_class_float32; const Quark object_class_int32; @@ -110,7 +110,6 @@ public: const Quark rdf_instanceOf; const Quark rdf_type; const Quark rdfs_seeAlso; - const Quark string_transfer; const Quark ui_format_events; const Quark wildcard; }; diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 50395249..af706e15 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -149,10 +149,10 @@ ResourceImpl::type( } else if (atom == uris.lv2ev_EventPort) { data_type = PortType::EVENTS; port = true; - } else if (atom == uris.obj_ValuePort) { + } else if (atom == uris.aport_ValuePort) { data_type = PortType::VALUE; port = true; - } else if (atom == uris.obj_MessagePort) { + } else if (atom == uris.aport_MessagePort) { data_type = PortType::MESSAGE; port = true; } else { -- cgit v1.2.1