diff options
Diffstat (limited to 'src/libs')
94 files changed, 412 insertions, 442 deletions
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index 4913b038..22fe1cda 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -378,22 +378,22 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr if (plugin_type == "Internal") { if (plugin_label == "audio_input") { - _engine->create_port(path, "ingen:audio", false); + _engine->create_port(path, "ingen:AudioPort", false); is_port = true; } else if (plugin_label == "audio_output") { - _engine->create_port(path, "ingen:audio", true); + _engine->create_port(path, "ingen:AudioPort", true); is_port = true; } else if (plugin_label == "control_input") { - _engine->create_port(path, "ingen:control", false); + _engine->create_port(path, "ingen:ControlPort", false); is_port = true; } else if (plugin_label == "control_output" ) { - _engine->create_port(path, "ingen:control", true); + _engine->create_port(path, "ingen:ControlPort", true); is_port = true; } else if (plugin_label == "midi_input") { - _engine->create_port(path, "ingen:midi", false); + _engine->create_port(path, "ingen:MidiPort", false); is_port = true; } else if (plugin_label == "midi_output" ) { - _engine->create_port(path, "ingen:midi", true); + _engine->create_port(path, "ingen:MidiPort", true); is_port = true; } } diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index c3348f89..87b62dd9 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -17,9 +17,10 @@ #include CONFIG_H_PATH +#include <cassert> +#include "interface/Port.hpp" #include "NodeModel.hpp" #include "PatchModel.hpp" -#include <cassert> namespace Ingen { namespace Client { @@ -135,6 +136,13 @@ NodeModel::get_port(const string& port_name) const return (*i); return SharedPtr<PortModel>(); } + + +Shared::Port* +NodeModel::port(uint32_t index) const +{ + return dynamic_cast<Shared::Port*>(_ports[index].get()); +} void @@ -148,14 +156,14 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) // Plugin value first #ifdef HAVE_SLV2 - if (plugin() && plugin()->type() == PluginModel::LV2) { + if (_plugin && _plugin->type() == PluginModel::LV2) { min = slv2_port_get_minimum_value( - plugin()->slv2_plugin(), - slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(), + _plugin->slv2_plugin(), + slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(), port->path().name().c_str())); max = slv2_port_get_maximum_value( - plugin()->slv2_plugin(), - slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(), + _plugin->slv2_plugin(), + slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(), port->path().name().c_str())); //cerr << "SLV2: " << min << " .. " << max << endl; diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp index 1df7f35e..c4f9afe2 100644 --- a/src/libs/client/NodeModel.hpp +++ b/src/libs/client/NodeModel.hpp @@ -51,10 +51,12 @@ public: SharedPtr<PortModel> get_port(const string& port_name) const; - const string& plugin_uri() const { return _plugin_uri; } - SharedPtr<PluginModel> plugin() const { return _plugin; } - uint32_t num_ports() const { return _ports.size(); } - const PortModelList& ports() const { return _ports; } + Shared::Port* port(uint32_t index) const; + + const string& plugin_uri() const { return _plugin_uri; } + const Shared::Plugin* plugin() const { return _plugin.get(); } + uint32_t num_ports() const { return _ports.size(); } + const PortModelList& ports() const { return _ports; } void port_value_range(SharedPtr<PortModel> port, float& min, float& max); diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 15b346e5..ff26abeb 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -102,7 +102,7 @@ lv2_ui_program_save(LV2UI_Controller controller, #ifdef HAVE_SLV2 SLV2UIInstance -PluginModel::ui(EngineInterface* engine, NodeModel* node) +PluginModel::ui(EngineInterface* engine, NodeModel* node) const { if (_type != LV2) return NULL; diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index 67a0295f..b4b0ab96 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -105,7 +105,7 @@ public: _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); } - SLV2UIInstance ui(Ingen::Shared::EngineInterface* engine, NodeModel* node); + SLV2UIInstance ui(Ingen::Shared::EngineInterface* engine, NodeModel* node) const; #endif static void set_rdf_world(Raul::RDF::World& world) { diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp index fd965c2b..d6a766d8 100644 --- a/src/libs/client/PortModel.hpp +++ b/src/libs/client/PortModel.hpp @@ -46,10 +46,10 @@ public: inline bool connected() const { return (_connections > 0); } inline bool is_input() const { return (_direction == INPUT); } inline bool is_output() const { return (_direction == OUTPUT); } - inline bool is_audio() const { return (_type == "ingen:audio"); } - inline bool is_control() const { return (_type == "ingen:control"); } - inline bool is_midi() const { return (_type == "ingen:midi"); } - inline bool is_osc() const { return (_type == "ingen:osc"); } + inline bool is_audio() const { return (_type == "ingen:AudioPort"); } + inline bool is_control() const { return (_type == "ingen:ControlPort"); } + inline bool is_midi() const { return (_type == "ingen:MidiPort"); } + inline bool is_osc() const { return (_type == "ingen:OSCPort"); } bool is_logarithmic() const; bool is_integer() const; diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index e1b3805d..d367733d 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -35,6 +35,7 @@ #include <raul/RDFWorld.hpp> #include <raul/TableImpl.hpp> #include "interface/EngineInterface.hpp" +#include "interface/Port.hpp" #include "ConnectionModel.hpp" #include "NodeModel.hpp" #include "PatchModel.hpp" @@ -46,6 +47,7 @@ using namespace std; using namespace Raul; using namespace Raul::RDF; +using namespace Ingen; using namespace Ingen::Shared; namespace Ingen { @@ -225,15 +227,15 @@ Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error) return; } - SharedPtr<NodeModel> node = PtrCast<NodeModel>(object); + SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(object); if (node) { serialize_node(node, path_to_node_id(node->path())); return; } - SharedPtr<PortModel> port = PtrCast<PortModel>(object); + SharedPtr<Port> port = PtrCast<Port>(object); if (port) { - serialize_port(port, path_to_node_id(port->path())); + serialize_port(port.get(), path_to_node_id(port->path())); return; } @@ -306,10 +308,11 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) } } - for (PortModelList::const_iterator p = patch->ports().begin(); p != patch->ports().end(); ++p) { - const RDF::Node port_id = path_to_node_id((*p)->path()); + for (uint32_t i=0; i < patch->num_ports(); ++i) { + Port* p = patch->port(i); + const RDF::Node port_id = path_to_node_id(p->path()); _model->add_statement(patch_id, "ingen:port", port_id); - serialize_port(*p, port_id); + serialize_port(p, port_id); } for (ConnectionList::const_iterator c = patch->connections().begin(); c != patch->connections().end(); ++c) { @@ -333,7 +336,7 @@ Serializer::serialize_plugin(SharedPtr<PluginModel> plugin) void -Serializer::serialize_node(SharedPtr<NodeModel> node, const RDF::Node& node_id) +Serializer::serialize_node(SharedPtr<Shared::Node> node, const RDF::Node& node_id) { const RDF::Node plugin_id = RDF::Node(_model->world(), RDF::Node::RESOURCE, node->plugin()->uri()); @@ -365,9 +368,10 @@ Serializer::serialize_node(SharedPtr<NodeModel> node, const RDF::Node& node_id) "ingen:name", Atom(node->path().name()));*/ - for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) { - const RDF::Node port_id = path_to_node_id((*p)->path()); - serialize_port(*p, port_id); + for (uint32_t i=0; i < node->num_ports(); ++i) { + Port* p = node->port(i); + const RDF::Node port_id = path_to_node_id(p->path()); + serialize_port(p, port_id); _model->add_statement(node_id, "ingen:port", port_id); } @@ -387,7 +391,7 @@ Serializer::serialize_node(SharedPtr<NodeModel> node, const RDF::Node& node_id) * Audio output ports with no metadata will not be written, for example. */ void -Serializer::serialize_port(SharedPtr<PortModel> port, const RDF::Node& port_id) +Serializer::serialize_port(const Port* port, const RDF::Node& port_id) { if (port->is_input()) _model->add_statement(port_id, "rdf:type", @@ -398,10 +402,10 @@ Serializer::serialize_port(SharedPtr<PortModel> port, const RDF::Node& port_id) _model->add_statement(port_id, "ingen:name", Atom(port->path().name().c_str())); - _model->add_statement(port_id, "ingen:dataType", Atom(port->type())); + _model->add_statement(port_id, "rdf:type", Atom(port->type().uri())); - if (port->is_control() && port->is_input()) - _model->add_statement(port_id, "ingen:value", Atom(port->value())); + if (port->type() == DataType::CONTROL && port->is_input()) + _model->add_statement(port_id, "ingen:value", port->value()); if (port->metadata().size() > 0) { for (GraphObject::MetadataMap::const_iterator m = port->metadata().begin(); diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp index 4a6cfa6a..d40e77ae 100644 --- a/src/libs/client/Serializer.hpp +++ b/src/libs/client/Serializer.hpp @@ -30,7 +30,12 @@ #include <raul/RDFModel.hpp> #include "ObjectModel.hpp" +using namespace Ingen::Shared; + namespace Ingen { + +namespace Shared { class Node; class Port; } + namespace Client { class PluginModel; @@ -68,8 +73,8 @@ private: void serialize_plugin(SharedPtr<PluginModel> p); void serialize_patch(SharedPtr<PatchModel> p); - void serialize_node(SharedPtr<NodeModel> n, const Raul::RDF::Node& id); - void serialize_port(SharedPtr<PortModel> p, const Raul::RDF::Node& id); + void serialize_node(SharedPtr<Shared::Node> n, const Raul::RDF::Node& id); + void serialize_port(const Shared::Port* p, const Raul::RDF::Node& id); Raul::RDF::Node path_to_node_id(const Path& path); Raul::RDF::Node patch_path_to_rdf_id(const Path& path); diff --git a/src/libs/engine/AudioBuffer.cpp b/src/libs/engine/AudioBuffer.cpp index 53fe6bb8..c302480a 100644 --- a/src/libs/engine/AudioBuffer.cpp +++ b/src/libs/engine/AudioBuffer.cpp @@ -29,7 +29,7 @@ namespace Ingen { AudioBuffer::AudioBuffer(size_t size) - : Buffer(DataType::FLOAT, size) + : Buffer((size == 1) ? DataType::CONTROL : DataType::AUDIO, size) , _data(NULL) , _local_data(NULL) , _joined_buf(NULL) @@ -187,7 +187,7 @@ AudioBuffer::copy(const Buffer* src, size_t start_sample, size_t end_sample) assert(end_sample >= start_sample); assert(end_sample < _size); assert(src); - assert(src->type() == DataType::FLOAT); + assert(src->type() == DataType::CONTROL || DataType::AUDIO); Sample* const buf = data(); assert(buf); diff --git a/src/libs/engine/AudioDriver.hpp b/src/libs/engine/AudioDriver.hpp index 8b4c0831..cb4c4150 100644 --- a/src/libs/engine/AudioDriver.hpp +++ b/src/libs/engine/AudioDriver.hpp @@ -22,13 +22,13 @@ #include <raul/Path.hpp> #include "Driver.hpp" #include "types.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" namespace Ingen { class Patch; class AudioDriver; -class Port; +class PortImpl; class ProcessContext; @@ -39,7 +39,7 @@ class ProcessContext; class AudioDriver : public Driver { public: - AudioDriver() : Driver(DataType::FLOAT) {} + AudioDriver() : Driver(DataType::AUDIO) {} virtual void set_root_patch(Patch* patch) = 0; virtual Patch* root_patch() = 0; diff --git a/src/libs/engine/Buffer.hpp b/src/libs/engine/Buffer.hpp index 44b69cbe..cb8f09d4 100644 --- a/src/libs/engine/Buffer.hpp +++ b/src/libs/engine/Buffer.hpp @@ -23,7 +23,7 @@ #include <boost/utility.hpp> #include <raul/Deletable.hpp> #include "types.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" namespace Ingen { diff --git a/src/libs/engine/BufferFactory.cpp b/src/libs/engine/BufferFactory.cpp index 8c84fb81..882e1805 100644 --- a/src/libs/engine/BufferFactory.cpp +++ b/src/libs/engine/BufferFactory.cpp @@ -27,7 +27,7 @@ namespace BufferFactory { Buffer* create(DataType type, size_t size) { - if (type == DataType::FLOAT) + if (type == DataType::CONTROL || type == DataType::AUDIO) return new AudioBuffer(size); else if (type == DataType::MIDI) return new MidiBuffer(size); diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 363b9f09..3c275e4a 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -26,7 +26,7 @@ #include "Patch.hpp" #include "NodeImpl.hpp" #include "PluginImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "Connection.hpp" #include "AudioDriver.hpp" #include "ObjectSender.hpp" @@ -130,7 +130,7 @@ ClientBroadcaster::send_node(const NodeImpl* node, bool recursive) void -ClientBroadcaster::send_port(const Port* port) +ClientBroadcaster::send_port(const PortImpl* port) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) ObjectSender::send_port((*i).second, port); diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp index 50589005..e9e74b3a 100644 --- a/src/libs/engine/ClientBroadcaster.hpp +++ b/src/libs/engine/ClientBroadcaster.hpp @@ -31,7 +31,7 @@ using std::string; namespace Ingen { class NodeImpl; -class Port; +class PortImpl; class PluginImpl; class Patch; class Connection; @@ -64,7 +64,7 @@ public: void send_plugins(const std::list<PluginImpl*>& plugin_list); void send_patch(const Patch* const p, bool recursive); void send_node(const NodeImpl* const node, bool recursive); - void send_port(const Port* port); + void send_port(const PortImpl* port); void send_destroyed(const string& path); void send_polyphonic(const string& path, bool polyphonic); void send_patch_cleared(const string& patch_path); diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp index 5b45f6fc..0d54fe9f 100644 --- a/src/libs/engine/Connection.cpp +++ b/src/libs/engine/Connection.cpp @@ -20,7 +20,7 @@ #include "util.hpp" #include "Connection.hpp" #include "NodeImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "BufferFactory.hpp" #include "AudioBuffer.hpp" #include "ProcessContext.hpp" @@ -33,7 +33,7 @@ namespace Ingen { * This handles both polyphonic and monophonic nodes, transparently to the * user (InputPort). */ -Connection::Connection(Port* src_port, Port* dst_port) +Connection::Connection(PortImpl* src_port, PortImpl* dst_port) : _src_port(src_port) , _dst_port(dst_port) , _local_buffer(NULL) @@ -85,7 +85,7 @@ Connection::set_buffer_size(size_t size) void Connection::prepare_poly(uint32_t poly) { - if (type() == DataType::FLOAT) + if (type() == DataType::CONTROL || type() == DataType::AUDIO) _must_mix = (poly > 1) && ( (_src_port->poly() != _dst_port->poly()) || (_src_port->polyphonic() && !_dst_port->polyphonic()) @@ -123,7 +123,7 @@ Connection::process(ProcessContext& context) * would avoid having to mix multiple times. Probably not a very common * case, but it would be faster anyway. */ - if (_must_mix && type() == DataType::FLOAT) { + if (_must_mix && type() == DataType::CONTROL || type() == DataType::AUDIO) { const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0); AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer; diff --git a/src/libs/engine/Connection.hpp b/src/libs/engine/Connection.hpp index 4a077a87..36dc0ee2 100644 --- a/src/libs/engine/Connection.hpp +++ b/src/libs/engine/Connection.hpp @@ -21,13 +21,13 @@ #include <cstdlib> #include <boost/utility.hpp> #include <raul/Deletable.hpp> -#include "DataType.hpp" -#include "Port.hpp" +#include "interface/DataType.hpp" +#include "PortImpl.hpp" #include "types.hpp" namespace Ingen { -class Port; +class PortImpl; class Buffer; @@ -44,11 +44,11 @@ class Buffer; class Connection : public Raul::Deletable { public: - Connection(Port* src_port, Port* dst_port); + Connection(PortImpl* src_port, PortImpl* dst_port); virtual ~Connection(); - Port* src_port() const { return _src_port; } - Port* dst_port() const { return _dst_port; } + PortImpl* src_port() const { return _src_port; } + PortImpl* dst_port() const { return _dst_port; } /** Used by some (recursive) events to prevent double disconnections */ bool pending_disconnection() { return _pending_disconnection; } @@ -70,12 +70,12 @@ public: DataType type() const { return _src_port->type(); } protected: - Port* const _src_port; - Port* const _dst_port; - Buffer* _local_buffer; - size_t _buffer_size; - bool _must_mix; - bool _pending_disconnection; + PortImpl* const _src_port; + PortImpl* const _dst_port; + Buffer* _local_buffer; + size_t _buffer_size; + bool _must_mix; + bool _pending_disconnection; }; diff --git a/src/libs/engine/DataType.hpp b/src/libs/engine/DataType.hpp deleted file mode 100644 index d883e95b..00000000 --- a/src/libs/engine/DataType.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef DATATYPE_H -#define DATATYPE_H - -namespace Ingen -{ - - -/** A data type that can be stored in a Port. - * - * This type refers to the type of the entire buffer, mirroring LV2, - * e.g. :AudioPort and :ControlPort both are really 32-bit floating point, - * but they are different port types. - */ -class DataType { -public: - - enum Symbol { - UNKNOWN = 0, - AUDIO = 1, - CONTROL = 2, - MIDI = 3, - OSC = 4 - }; - - DataType(const std::string& uri) - : _symbol(UNKNOWN) - { - if (uri == type_uri(AUDIO)) { - _symbol = AUDIO; - } else if (uri == type_uri(CONTROL)) { - _symbol = CONTROL; - } else if (uri == type_uri(MIDI)) { - _symbol = MIDI; - } else if (uri == type_uri(OSC)) { - _symbol = OSC; - } - } - - DataType(Symbol symbol) - : _symbol(symbol) - {} - - const char* uri() const { return type_uri(_symbol); } - const Symbol& symbol() const { return _symbol; } - - inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } - inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } - inline bool operator==(const DataType& type) const { return (_symbol == type._symbol); } - inline bool operator!=(const DataType& type) const { return (_symbol != type._symbol); } - -private: - Symbol _symbol; - - static inline const char* type_uri(unsigned symbol_num) { - switch (symbol_num) { - case 0: return "ingen:AudioPort"; - case 1: return "ingen:ControlPort"; - case 2: return "ingen:MidiPort"; - case 3: return "ingen:OSCPort"; - default: return ""; - } - } -}; - - - -} // namespace Ingen - -#endif // DATATYPE_H diff --git a/src/libs/engine/Driver.hpp b/src/libs/engine/Driver.hpp index 13a5a432..590b66b5 100644 --- a/src/libs/engine/Driver.hpp +++ b/src/libs/engine/Driver.hpp @@ -21,7 +21,7 @@ #include <string> #include <boost/utility.hpp> #include <raul/Path.hpp> -#include "DataType.hpp" +#include "interface/DataType.hpp" #include "DuplexPort.hpp" namespace Ingen { diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp index b349a7d6..83ba0e5a 100644 --- a/src/libs/engine/DuplexPort.cpp +++ b/src/libs/engine/DuplexPort.cpp @@ -30,12 +30,12 @@ namespace Ingen { DuplexPort::DuplexPort(NodeImpl* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size, bool is_output) - : Port(parent, name, index, poly, type, buffer_size) + : PortImpl(parent, name, index, poly, type, buffer_size) , InputPort(parent, name, index, poly, type, buffer_size) , OutputPort(parent, name, index, poly, type, buffer_size) , _is_output(is_output) { - assert(Port::_parent == parent); + assert(PortImpl::_parent == parent); } diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index 382e2b8d..b5e14eb0 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -98,7 +98,7 @@ Engine::~Engine() Driver* Engine::driver(DataType type) { - if (type == DataType::FLOAT) + if (type == DataType::AUDIO) return _audio_driver.get(); else if (type == DataType::MIDI) return _midi_driver; diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp index eb1f014b..f7e82c06 100644 --- a/src/libs/engine/Engine.hpp +++ b/src/libs/engine/Engine.hpp @@ -24,7 +24,7 @@ #include <boost/utility.hpp> #include <raul/SharedPtr.hpp> #include "module/module.h" -#include "DataType.hpp" +#include "interface/DataType.hpp" template<typename T> class Queue; diff --git a/src/libs/engine/EventSink.cpp b/src/libs/engine/EventSink.cpp index 7fc7b157..6c775d4c 100644 --- a/src/libs/engine/EventSink.cpp +++ b/src/libs/engine/EventSink.cpp @@ -18,7 +18,7 @@ #include <iostream> #include "events/SendPortValueEvent.hpp" #include "EventSink.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" using namespace std; diff --git a/src/libs/engine/EventSink.hpp b/src/libs/engine/EventSink.hpp index 4816a069..9e937d1a 100644 --- a/src/libs/engine/EventSink.hpp +++ b/src/libs/engine/EventSink.hpp @@ -26,7 +26,7 @@ namespace Ingen { -class Port; +class PortImpl; class Engine; class SendPortValueEvent; diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 678e3d8d..6a4de550 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -32,7 +32,7 @@ namespace Ingen { InputPort::InputPort(NodeImpl* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size) - : Port(parent, name, index, poly, type, buffer_size) + : PortImpl(parent, name, index, poly, type, buffer_size) { } @@ -40,7 +40,7 @@ InputPort::InputPort(NodeImpl* parent, const string& name, uint32_t index, uint3 void InputPort::set_buffer_size(size_t size) { - Port::set_buffer_size(size); + PortImpl::set_buffer_size(size); assert(_buffer_size = size); for (Raul::List<Connection*>::iterator c = _connections.begin(); c != _connections.end(); ++c) @@ -74,11 +74,11 @@ InputPort::add_connection(Raul::ListNode<Connection*>* const c) _buffers->at(i)->unjoin(); } } - Port::connect_buffers(); + PortImpl::connect_buffers(); } // Automatically broadcast connected control inputs - if (_type == DataType::FLOAT && _buffer_size == 1) + if (_type == DataType::CONTROL) _broadcast = true; } @@ -119,10 +119,10 @@ InputPort::remove_connection(const OutputPort* src_port) } if (modify_buffers) - Port::connect_buffers(); + PortImpl::connect_buffers(); // Turn off broadcasting if we're not connected any more (FIXME: not quite right..) - if (_type == DataType::FLOAT && _buffer_size == 1 && _connections.size() == 0) + if (_type == DataType::CONTROL && _connections.size() == 0) _broadcast = false; return connection; @@ -184,7 +184,7 @@ InputPort::pre_process(ProcessContext& context) return; } - if (_type == DataType::FLOAT) { + if (_type == DataType::CONTROL || _type == DataType::AUDIO) { for (uint32_t voice=0; voice < _poly; ++voice) { // Copy first connection _buffers->at(voice)->copy( diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp index ffba62e6..228371f8 100644 --- a/src/libs/engine/InputPort.hpp +++ b/src/libs/engine/InputPort.hpp @@ -22,7 +22,7 @@ #include <cstdlib> #include <cassert> #include <raul/List.hpp> -#include "Port.hpp" +#include "PortImpl.hpp" #include "MidiBuffer.hpp" using std::string; @@ -44,7 +44,7 @@ class NodeImpl; * * \ingroup engine */ -class InputPort : virtual public Port +class InputPort : virtual public PortImpl { public: InputPort(NodeImpl* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size); diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp index c8350b5c..d1cde5ca 100644 --- a/src/libs/engine/JackAudioDriver.cpp +++ b/src/libs/engine/JackAudioDriver.cpp @@ -30,7 +30,7 @@ #include "PostProcessor.hpp" #include "NodeImpl.hpp" #include "Patch.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "MidiDriver.hpp" #include "DuplexPort.hpp" #include "EventSource.hpp" diff --git a/src/libs/engine/JackAudioDriver.hpp b/src/libs/engine/JackAudioDriver.hpp index 07877e6f..cc19a8e8 100644 --- a/src/libs/engine/JackAudioDriver.hpp +++ b/src/libs/engine/JackAudioDriver.hpp @@ -31,7 +31,7 @@ namespace Ingen { class Engine; class Patch; -class Port; +class PortImpl; class DuplexPort; class JackAudioDriver; typedef jack_default_audio_sample_t jack_sample_t; diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index f7b32072..9c2da41e 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -57,7 +57,7 @@ bool LADSPANode::instantiate() { if (!_ports) - _ports = new Raul::Array<Port*>(_descriptor->PortCount); + _ports = new Raul::Array<PortImpl*>(_descriptor->PortCount); _instances = new LADSPA_Handle[_polyphony]; @@ -74,7 +74,7 @@ LADSPANode::instantiate() string port_name; string port_path; - Port* port = NULL; + PortImpl* port = NULL; for (size_t j=0; j < _descriptor->PortCount; ++j) { port_name = Path::nameify(_descriptor->PortNames[j]); @@ -101,19 +101,23 @@ LADSPANode::instantiate() port_path = path() + "/" + port_name; - if (LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j])) + DataType type = DataType::AUDIO; + port_buffer_size = _buffer_size; + + if (LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j])) { + type = DataType::CONTROL; port_buffer_size = 1; - else if (LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[j])) - port_buffer_size = _buffer_size; - + } else { + assert(LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[j])); + } assert (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j]) || LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j])); if (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j])) { - port = new InputPort(this, port_name, j, _polyphony, DataType::FLOAT, port_buffer_size); + port = new InputPort(this, port_name, j, _polyphony, type, port_buffer_size); _ports->at(j) = port; } else if (LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j])) { - port = new OutputPort(this, port_name, j, _polyphony, DataType::FLOAT, port_buffer_size); + port = new OutputPort(this, port_name, j, _polyphony, type, port_buffer_size); _ports->at(j) = port; } diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index c37a2665..ed330d6d 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -126,7 +126,7 @@ LV2Node::instantiate() uint32_t num_ports = slv2_plugin_get_num_ports(_lv2_plugin); assert(num_ports > 0); - _ports = new Raul::Array<Port*>(num_ports, NULL); + _ports = new Raul::Array<PortImpl*>(num_ports, NULL); _instances = new Raul::Array<SLV2Instance>(_polyphony, NULL); @@ -143,7 +143,7 @@ LV2Node::instantiate() string port_name; string port_path; - Port* port = NULL; + PortImpl* port = NULL; for (uint32_t j=0; j < num_ports; ++j) { SLV2Port id = slv2_plugin_get_port_by_index(_lv2_plugin, j); @@ -167,12 +167,13 @@ LV2Node::instantiate() DataType data_type = DataType::UNKNOWN; switch (port_type) { case SLV2_PORT_DATA_TYPE_CONTROL: + data_type = DataType::CONTROL; break; case SLV2_PORT_DATA_TYPE_AUDIO: - data_type = DataType::FLOAT; break; + data_type = DataType::AUDIO; break; case SLV2_PORT_DATA_TYPE_MIDI: data_type = DataType::MIDI; break; case SLV2_PORT_DATA_TYPE_OSC: - data_type = DataType::OSC; + data_type = DataType::OSC; break; default: break; } @@ -217,14 +218,14 @@ LV2Node::activate() for (uint32_t i=0; i < _polyphony; ++i) { for (unsigned long j=0; j < num_ports(); ++j) { - Port* const port = _ports->at(j); + PortImpl* const port = _ports->at(j); set_port_buffer(i, j, port->buffer(i)); - if (port->type() == DataType::FLOAT && port->buffer_size() == 1) { + if (port->type() == DataType::CONTROL) { ((AudioBuffer*)port->buffer(i))->set( slv2_port_get_default_value(_lv2_plugin, slv2_plugin_get_port_by_index(_lv2_plugin, j)), 0); - } else if (port->type() == DataType::FLOAT) { + } else if (port->type() == DataType::AUDIO) { ((AudioBuffer*)port->buffer(i))->set(0.0f, 0); } } diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 91d48fd7..8b037fb9 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -31,7 +31,6 @@ libingen_engine_la_SOURCES = \ Connection.cpp \ Connection.hpp \ CompiledPatch.hpp \ - DataType.hpp \ Driver.hpp \ DuplexPort.cpp \ DuplexPort.hpp \ @@ -82,8 +81,8 @@ libingen_engine_la_SOURCES = \ Patch.hpp \ PluginImpl.cpp \ PluginImpl.hpp \ - Port.cpp \ - Port.hpp \ + PortImpl.cpp \ + PortImpl.hpp \ PostProcessor.cpp \ PostProcessor.hpp \ ProcessContext.hpp \ diff --git a/src/libs/engine/MidiBuffer.hpp b/src/libs/engine/MidiBuffer.hpp index f1948666..fe3d36bb 100644 --- a/src/libs/engine/MidiBuffer.hpp +++ b/src/libs/engine/MidiBuffer.hpp @@ -20,7 +20,7 @@ #include <lv2ext/lv2-midiport.h> #include "Buffer.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" namespace Ingen { diff --git a/src/libs/engine/MidiControlNode.cpp b/src/libs/engine/MidiControlNode.cpp index bf2564d0..5bc14182 100644 --- a/src/libs/engine/MidiControlNode.cpp +++ b/src/libs/engine/MidiControlNode.cpp @@ -34,34 +34,34 @@ MidiControlNode::MidiControlNode(const string& path, bool polyphonic, Patch* par : NodeBase(new PluginImpl(Plugin::Internal, "ingen:control_node"), path, false, parent, srate, buffer_size), _learning(false) { - _ports = new Raul::Array<Port*>(7); + _ports = new Raul::Array<PortImpl*>(7); _midi_in_port = new InputPort(this, "MIDIIn", 0, 1, DataType::MIDI, _buffer_size); _ports->at(0) = _midi_in_port; - _param_port = new InputPort(this, "ControllerNumber", 1, 1, DataType::FLOAT, 1); + _param_port = new InputPort(this, "ControllerNumber", 1, 1, DataType::CONTROL, 1); _param_port->set_metadata("ingen:minimum", 0.0f); _param_port->set_metadata("ingen:maximum", 127.0f); _param_port->set_metadata("ingen:default", 0.0f); _param_port->set_metadata("ingen:integer", 1); _ports->at(1) = _param_port; - _log_port = new InputPort(this, "Logarithmic", 2, 1, DataType::FLOAT, 1); + _log_port = new InputPort(this, "Logarithmic", 2, 1, DataType::CONTROL, 1); _log_port->set_metadata("ingen:toggled", 1); _log_port->set_metadata("ingen:default", 0.0f); _ports->at(2) = _log_port; - _min_port = new InputPort(this, "Min", 3, 1, DataType::FLOAT, 1); + _min_port = new InputPort(this, "Min", 3, 1, DataType::CONTROL, 1); _min_port->set_metadata("ingen:default", 0.0f); _ports->at(3) = _min_port; - _max_port = new InputPort(this, "Max", 4, 1, DataType::FLOAT, 1); + _max_port = new InputPort(this, "Max", 4, 1, DataType::CONTROL, 1); _ports->at(4) = _max_port; - _audio_port = new OutputPort(this, "Out(AR)", 5, 1, DataType::FLOAT, _buffer_size); + _audio_port = new OutputPort(this, "Out(AR)", 5, 1, DataType::AUDIO, _buffer_size); _ports->at(5) = _audio_port; - _control_port = new OutputPort(this, "Out(CR)", 6, 1, DataType::FLOAT, 1); + _control_port = new OutputPort(this, "Out(CR)", 6, 1, DataType::CONTROL, 1); _ports->at(6) = _control_port; PluginImpl* p = const_cast<PluginImpl*>(_plugin); diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp index b3d69ac2..146a0978 100644 --- a/src/libs/engine/MidiNoteNode.cpp +++ b/src/libs/engine/MidiNoteNode.cpp @@ -44,25 +44,25 @@ MidiNoteNode::MidiNoteNode(const string& path, bool polyphonic, Patch* parent, S _sustain(false) { - _ports = new Raul::Array<Port*>(5); + _ports = new Raul::Array<PortImpl*>(5); _midi_in_port = new InputPort(this, "MIDIIn", 0, 1, DataType::MIDI, _buffer_size); _ports->at(0) = _midi_in_port; - _freq_port = new OutputPort(this, "Frequency", 1, _polyphony, DataType::FLOAT, _buffer_size); + _freq_port = new OutputPort(this, "Frequency", 1, _polyphony, DataType::AUDIO, _buffer_size); _ports->at(1) = _freq_port; - _vel_port = new OutputPort(this, "Velocity", 2, _polyphony, DataType::FLOAT, _buffer_size); + _vel_port = new OutputPort(this, "Velocity", 2, _polyphony, DataType::AUDIO, _buffer_size); _vel_port->set_metadata("ingen:minimum", 0.0f); _vel_port->set_metadata("ingen:maximum", 1.0f); _ports->at(2) = _vel_port; - _gate_port = new OutputPort(this, "Gate", 3, _polyphony, DataType::FLOAT, _buffer_size); + _gate_port = new OutputPort(this, "Gate", 3, _polyphony, DataType::AUDIO, _buffer_size); _gate_port->set_metadata("ingen:toggled", 1); _gate_port->set_metadata("ingen:default", 0.0f); _ports->at(3) = _gate_port; - _trig_port = new OutputPort(this, "Trigger", 4, _polyphony, DataType::FLOAT, _buffer_size); + _trig_port = new OutputPort(this, "Trigger", 4, _polyphony, DataType::AUDIO, _buffer_size); _trig_port->set_metadata("ingen:toggled", 1); _trig_port->set_metadata("ingen:default", 0.0f); _ports->at(4) = _trig_port; diff --git a/src/libs/engine/MidiTriggerNode.cpp b/src/libs/engine/MidiTriggerNode.cpp index 7490fcc0..6d7da38a 100644 --- a/src/libs/engine/MidiTriggerNode.cpp +++ b/src/libs/engine/MidiTriggerNode.cpp @@ -31,25 +31,25 @@ namespace Ingen { MidiTriggerNode::MidiTriggerNode(const string& path, bool polyphonic, Patch* parent, SampleRate srate, size_t buffer_size) : NodeBase(new PluginImpl(Plugin::Internal, "ingen:trigger_node"), path, false, parent, srate, buffer_size) { - _ports = new Raul::Array<Port*>(5); + _ports = new Raul::Array<PortImpl*>(5); _midi_in_port = new InputPort(this, "MIDIIn", 0, 1, DataType::MIDI, _buffer_size); _ports->at(0) = _midi_in_port; - _note_port = new InputPort(this, "NoteNumber", 1, 1, DataType::FLOAT, 1); + _note_port = new InputPort(this, "NoteNumber", 1, 1, DataType::CONTROL, 1); _note_port->set_metadata("ingen:minimum", 0.0f); _note_port->set_metadata("ingen:maximum", 127.0f); _note_port->set_metadata("ingen:default", 60.0f); _note_port->set_metadata("ingen:integer", 1); _ports->at(1) = _note_port; - _gate_port = new OutputPort(this, "Gate", 2, 1, DataType::FLOAT, _buffer_size); + _gate_port = new OutputPort(this, "Gate", 2, 1, DataType::AUDIO, _buffer_size); _ports->at(2) = _gate_port; - _trig_port = new OutputPort(this, "Trigger", 3, 1, DataType::FLOAT, _buffer_size); + _trig_port = new OutputPort(this, "Trigger", 3, 1, DataType::AUDIO, _buffer_size); _ports->at(3) = _trig_port; - _vel_port = new OutputPort(this, "Velocity", 4, 1, DataType::FLOAT, _buffer_size); + _vel_port = new OutputPort(this, "Velocity", 4, 1, DataType::AUDIO, _buffer_size); _ports->at(4) = _vel_port; PluginImpl* p = const_cast<PluginImpl*>(_plugin); diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp index d5400cdf..d5e75970 100644 --- a/src/libs/engine/NodeBase.cpp +++ b/src/libs/engine/NodeBase.cpp @@ -24,7 +24,7 @@ #include "util.hpp" #include "PluginImpl.hpp" #include "ClientBroadcaster.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "Patch.hpp" #include "ObjectStore.hpp" @@ -66,6 +66,20 @@ NodeBase::~NodeBase() delete _ports->at(i); } + +Port* +NodeBase::port(uint32_t index) const +{ + return (*_ports)[index]; +} + + +const Plugin* +NodeBase::plugin() const +{ + return _plugin; +} + void NodeBase::activate() diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp index 2e4480b8..9aa26310 100644 --- a/src/libs/engine/NodeBase.hpp +++ b/src/libs/engine/NodeBase.hpp @@ -23,6 +23,7 @@ #include <cstdlib> #include <raul/Semaphore.hpp> #include <raul/AtomicInt.hpp> +#include "interface/Port.hpp" #include "NodeImpl.hpp" using std::string; @@ -84,7 +85,8 @@ public: bool traversed() const { return _traversed; } void traversed(bool b) { _traversed = b; } - const Raul::Array<Port*>& ports() const { return *_ports; } + virtual Port* port(uint32_t index) const; + virtual PortImpl* port_impl(uint32_t index) const { return (*_ports)[index]; } /* These are NOT to be used in the audio thread! * The providers and dependants in CompiledNode are for that @@ -96,8 +98,9 @@ public: Raul::List<NodeImpl*>* dependants() { return _dependants; } void dependants(Raul::List<NodeImpl*>* l) { _dependants = l; } - virtual const PluginImpl* plugin() const { return _plugin; } - virtual void plugin(const PluginImpl* const pi) { _plugin = pi; } + virtual const Plugin* plugin() const; + virtual const PluginImpl* plugin_impl() const { return _plugin; } + virtual void plugin(const PluginImpl* pi) { _plugin = pi; } /** A node's parent is always a patch, so static cast should be safe */ inline Patch* parent_patch() const { return (Patch*)_parent; } @@ -112,13 +115,13 @@ protected: size_t _buffer_size; bool _activated; - bool _traversed; ///< Flag for process order algorithm - Raul::Semaphore _input_ready; ///< Parallelism: input ready signal - Raul::AtomicInt _process_lock; ///< Parallelism: Waiting on inputs 'lock' - Raul::AtomicInt _n_inputs_ready; ///< Parallelism: # input ready signals this cycle - Raul::Array<Port*>* _ports; ///< Access in audio thread only - Raul::List<NodeImpl*>* _providers; ///< Nodes connected to this one's input ports - Raul::List<NodeImpl*>* _dependants; ///< Nodes this one's output ports are connected to + bool _traversed; ///< Flag for process order algorithm + Raul::Semaphore _input_ready; ///< Parallelism: input ready signal + Raul::AtomicInt _process_lock; ///< Parallelism: Waiting on inputs 'lock' + Raul::AtomicInt _n_inputs_ready; ///< Parallelism: # input ready signals this cycle + Raul::Array<PortImpl*>* _ports; ///< Access in audio thread only + Raul::List<NodeImpl*>* _providers; ///< Nodes connected to this one's input ports + Raul::List<NodeImpl*>* _dependants; ///< Nodes this one's output ports are connected to }; diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp index 1e05b923..cef8e9a4 100644 --- a/src/libs/engine/NodeFactory.cpp +++ b/src/libs/engine/NodeFactory.cpp @@ -59,16 +59,16 @@ NodeFactory::NodeFactory(Ingen::Shared::World* world) NodeImpl* n = NULL; n = new MidiNoteNode("foo", 1, parent, 1, 1); - _internal_plugins.push_back(new PluginImpl(n->plugin())); + _internal_plugins.push_back(new PluginImpl(n->plugin_impl())); delete n; n = new MidiTriggerNode("foo", 1, parent, 1, 1); - _internal_plugins.push_back(new PluginImpl(n->plugin())); + _internal_plugins.push_back(new PluginImpl(n->plugin_impl())); delete n; n = new MidiControlNode("foo", 1, parent, 1, 1); - _internal_plugins.push_back(new PluginImpl(n->plugin())); + _internal_plugins.push_back(new PluginImpl(n->plugin_impl())); delete n; n = new TransportNode("foo", 1, parent, 1, 1); - _internal_plugins.push_back(new PluginImpl(n->plugin())); + _internal_plugins.push_back(new PluginImpl(n->plugin_impl())); delete n; delete parent; diff --git a/src/libs/engine/NodeImpl.hpp b/src/libs/engine/NodeImpl.hpp index 70a09c33..f139cde0 100644 --- a/src/libs/engine/NodeImpl.hpp +++ b/src/libs/engine/NodeImpl.hpp @@ -28,10 +28,14 @@ namespace Raul { template <typename T> class List; class Maid; } namespace Ingen { +namespace Shared { class Plugin; class Node; class Port; } + +using namespace Shared; + class Buffer; class PluginImpl; class Patch; -class Port; +class PortImpl; /** A Node (or "module") in a Patch (which is also a Node). @@ -118,10 +122,10 @@ public: virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) = 0; - // FIXME: Only used by client senders. Remove? - virtual const Raul::Array<Port*>& ports() const = 0; - virtual uint32_t num_ports() const = 0; + + virtual Port* port(uint32_t index) const = 0; + virtual PortImpl* port_impl(uint32_t index) const = 0; /** Used by the process order finding algorithm (ie during connections) */ virtual bool traversed() const = 0; @@ -145,7 +149,12 @@ public: /** Information about the Plugin this Node is an instance of. * Not the best name - not all nodes come from plugins (ie Patch) */ - virtual const PluginImpl* plugin() const = 0; + virtual const PluginImpl* plugin_impl() const = 0; + + /** Information about the Plugin this Node is an instance of. + * Not the best name - not all nodes come from plugins (ie Patch) + */ + virtual const Shared::Plugin* plugin() const = 0; virtual void set_buffer_size(size_t size) = 0; }; diff --git a/src/libs/engine/OSCBuffer.cpp b/src/libs/engine/OSCBuffer.cpp index 44cf3235..d3d1c952 100644 --- a/src/libs/engine/OSCBuffer.cpp +++ b/src/libs/engine/OSCBuffer.cpp @@ -54,7 +54,7 @@ OSCBuffer::join(Buffer* buf) _joined_buf = obuf; - cerr << "OSC buffer joined" << endl; + //cerr << "OSC buffer joined" << endl; //_state = mbuf->_state; diff --git a/src/libs/engine/OSCBuffer.hpp b/src/libs/engine/OSCBuffer.hpp index 1d3758e5..d70474a2 100644 --- a/src/libs/engine/OSCBuffer.hpp +++ b/src/libs/engine/OSCBuffer.hpp @@ -19,7 +19,7 @@ #define OSCBUFFER_H #include "Buffer.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" #include "../../../../lv2/extensions/osc/lv2_osc.h" namespace Ingen { diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp index 1d1a9323..ff0b2037 100644 --- a/src/libs/engine/OSCClientSender.cpp +++ b/src/libs/engine/OSCClientSender.cpp @@ -26,7 +26,7 @@ #include "Patch.hpp" #include "NodeImpl.hpp" #include "PluginImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "Connection.hpp" #include "AudioDriver.hpp" #include "interface/ClientInterface.hpp" diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp index 7cbf028a..fb1039c7 100644 --- a/src/libs/engine/ObjectSender.cpp +++ b/src/libs/engine/ObjectSender.cpp @@ -20,11 +20,11 @@ #include "ObjectStore.hpp" #include "Patch.hpp" #include "NodeImpl.hpp" -#include "Port.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" +#include "PortImpl.hpp" #include "Connection.hpp" #include "NodeFactory.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" #include "AudioBuffer.hpp" namespace Ingen { @@ -48,7 +48,7 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch, bool recur // Send ports for (uint32_t i=0; i < patch->num_ports(); ++i) { - Port* const port = patch->ports().at(i); + PortImpl* const port = patch->port_impl(i); send_port(client, port); } @@ -77,7 +77,7 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch, bool recur void ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recursive) { - const PluginImpl* const plugin = node->plugin(); + const PluginImpl* const plugin = node->plugin_impl(); assert(node->path().length() > 0); @@ -93,7 +93,7 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu client->bundle_begin(); - client->new_node(node->plugin()->uri(), node->path(), node->polyphonic(), node->ports().size()); + client->new_node(node->plugin()->uri(), node->path(), node->polyphonic(), node->num_ports()); // Send metadata const GraphObjectImpl::MetadataMap& data = node->metadata(); @@ -104,37 +104,20 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu if (recursive) { // Send ports - for (size_t j=0; j < node->ports().size(); ++j) - send_port(client, node->ports().at(j)); + for (size_t j=0; j < node->num_ports(); ++j) + send_port(client, node->port_impl(j)); } } void -ObjectSender::send_port(ClientInterface* client, const Port* port) +ObjectSender::send_port(ClientInterface* client, const PortImpl* port) { assert(port); - //cerr << "Sending port " << port->path(); - - // FIXME: temporary compatibility hack - string type = port->type().uri(); - if (port->type() == DataType::FLOAT) { - if (port->buffer_size() == 1) - type = "ingen:control"; - else - type = "ingen:audio"; - } else if (port->type() == DataType::MIDI) { - type = "ingen:midi"; - } else if (port->type() == DataType::OSC) { - type = "ingen:osc"; - } - - //cerr << ", type = " << type << endl; - client->bundle_begin(); - client->new_port(port->path(), type, port->is_output()); + client->new_port(port->path(), port->type().uri(), port->is_output()); // Send metadata const GraphObjectImpl::MetadataMap& data = port->metadata(); @@ -142,7 +125,7 @@ ObjectSender::send_port(ClientInterface* client, const Port* port) client->metadata_update(port->path(), (*j).first, (*j).second); // Send control value - if (port->type() == DataType::FLOAT && port->buffer_size() == 1) { + if (port->type() == DataType::CONTROL) { const Sample value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0); //cerr << port->path() << " sending default value " << default_value << endl; client->control_change(port->path(), value); diff --git a/src/libs/engine/ObjectSender.hpp b/src/libs/engine/ObjectSender.hpp index c93804ba..e1274708 100644 --- a/src/libs/engine/ObjectSender.hpp +++ b/src/libs/engine/ObjectSender.hpp @@ -28,7 +28,7 @@ namespace Shared { class Patch; class NodeImpl; -class Port; +class PortImpl; class PluginImpl; @@ -48,7 +48,7 @@ public: static void send_patch(ClientInterface* client, const Patch* patch, bool recursive); static void send_node(ClientInterface* client, const NodeImpl* node, bool recursive); - static void send_port(ClientInterface* client, const Port* port); + static void send_port(ClientInterface* client, const PortImpl* port); }; } // namespace Ingen diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp index b321e51c..719770ed 100644 --- a/src/libs/engine/ObjectStore.cpp +++ b/src/libs/engine/ObjectStore.cpp @@ -23,7 +23,7 @@ #include "ObjectStore.hpp" #include "Patch.hpp" #include "NodeImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ThreadManager.hpp" using namespace std; @@ -54,11 +54,11 @@ ObjectStore::find_node(const Path& path) /** Find the Port at the given path. */ -Port* +PortImpl* ObjectStore::find_port(const Path& path) { GraphObjectImpl* const object = find_object(path); - return dynamic_cast<Port*>(object); + return dynamic_cast<PortImpl*>(object); } @@ -85,7 +85,7 @@ ObjectStore::add(GraphObjectImpl* o) NodeImpl* node = dynamic_cast<NodeImpl*>(o); if (node) { for (uint32_t i=0; i < node->num_ports(); ++i) { - add(node->ports().at(i)); + add(node->port_impl(i)); } } } diff --git a/src/libs/engine/ObjectStore.hpp b/src/libs/engine/ObjectStore.hpp index e99450ab..66d182ba 100644 --- a/src/libs/engine/ObjectStore.hpp +++ b/src/libs/engine/ObjectStore.hpp @@ -28,7 +28,7 @@ namespace Ingen { class Patch; class NodeImpl; -class Port; +class PortImpl; class GraphObjectImpl; @@ -48,7 +48,7 @@ public: Patch* find_patch(const Path& path); NodeImpl* find_node(const Path& path); - Port* find_port(const Path& path); + PortImpl* find_port(const Path& path); GraphObjectImpl* find_object(const Path& path); Objects::iterator find(const Path& path) { return _objects.find(path); } diff --git a/src/libs/engine/OutputPort.hpp b/src/libs/engine/OutputPort.hpp index 54f4f2bc..1db9e4d9 100644 --- a/src/libs/engine/OutputPort.hpp +++ b/src/libs/engine/OutputPort.hpp @@ -20,7 +20,7 @@ #include <string> #include <cstdlib> -#include "Port.hpp" +#include "PortImpl.hpp" #include "types.hpp" namespace Ingen { @@ -37,7 +37,7 @@ namespace Ingen { * * \ingroup engine */ -class OutputPort : virtual public Port +class OutputPort : virtual public PortImpl { public: OutputPort(NodeImpl* parent, @@ -46,7 +46,7 @@ public: uint32_t poly, DataType type, size_t buffer_size) - : Port(parent, name, index, poly, type, buffer_size) + : PortImpl(parent, name, index, poly, type, buffer_size) {} void pre_process(ProcessContext& context); diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index 0619c743..6f3b0a48 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -22,7 +22,7 @@ #include "NodeImpl.hpp" #include "Patch.hpp" #include "PluginImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "Connection.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" @@ -103,7 +103,7 @@ Patch::disable() { _process = false; - for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) + for (Raul::List<PortImpl*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) (*i)->clear_buffers(); } @@ -285,7 +285,7 @@ Patch::remove_node(const string& name) /** Remove a connection. Realtime safe. */ Raul::ListNode<Connection*>* -Patch::remove_connection(const Port* src_port, const Port* dst_port) +Patch::remove_connection(const PortImpl* src_port, const PortImpl* dst_port) { bool found = false; Raul::ListNode<Connection*>* connection = NULL; @@ -317,7 +317,7 @@ Patch::num_ports() const /** Create a port. Not realtime safe. */ -Port* +PortImpl* Patch::create_port(const string& name, DataType type, size_t buffer_size, bool is_output) { if (type == DataType::UNKNOWN) { @@ -338,14 +338,14 @@ Patch::create_port(const string& name, DataType type, size_t buffer_size, bool i * * Realtime safe. Preprocessing thread only. */ -Raul::ListNode<Port*>* +Raul::ListNode<PortImpl*>* Patch::remove_port(const string& name) { assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); bool found = false; - Raul::ListNode<Port*>* ret = NULL; - for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) { + Raul::ListNode<PortImpl*>* ret = NULL; + for (Raul::List<PortImpl*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) { if ((*i)->name() == name) { ret = _input_ports.erase(i); found = true; @@ -353,7 +353,7 @@ Patch::remove_port(const string& name) } if (!found) - for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) { + for (Raul::List<PortImpl*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) { if ((*i)->name() == name) { ret = _output_ports.erase(i); found = true; @@ -367,19 +367,19 @@ Patch::remove_port(const string& name) } -Raul::Array<Port*>* +Raul::Array<PortImpl*>* Patch::build_ports_array() const { assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); - Raul::Array<Port*>* const result = new Raul::Array<Port*>(_input_ports.size() + _output_ports.size()); + Raul::Array<PortImpl*>* const result = new Raul::Array<PortImpl*>(_input_ports.size() + _output_ports.size()); size_t i = 0; - for (Raul::List<Port*>::const_iterator p = _input_ports.begin(); p != _input_ports.end(); ++p,++i) + for (Raul::List<PortImpl*>::const_iterator p = _input_ports.begin(); p != _input_ports.end(); ++p,++i) result->at(i) = *p; - for (Raul::List<Port*>::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p,++i) + for (Raul::List<PortImpl*>::const_iterator p = _output_ports.begin(); p != _output_ports.end(); ++p,++i) result->at(i) = *p; return result; diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp index ddcc1c93..66372c3c 100644 --- a/src/libs/engine/Patch.hpp +++ b/src/libs/engine/Patch.hpp @@ -23,7 +23,7 @@ #include <raul/List.hpp> #include "NodeBase.hpp" #include "PluginImpl.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" #include "CompiledPatch.hpp" using std::string; @@ -94,22 +94,22 @@ public: uint32_t num_ports() const; - Port* create_port(const string& name, DataType type, size_t buffer_size, bool is_output); - void add_input(Raul::ListNode<Port*>* port) { _input_ports.push_back(port); } ///< Preprocesser thread - void add_output(Raul::ListNode<Port*>* port) { _output_ports.push_back(port); } ///< Preprocessor thread - Raul::ListNode<Port*>* remove_port(const string& name); + PortImpl* create_port(const string& name, DataType type, size_t buffer_size, bool is_output); + void add_input(Raul::ListNode<PortImpl*>* port) { _input_ports.push_back(port); } ///< Preprocesser thread + void add_output(Raul::ListNode<PortImpl*>* port) { _output_ports.push_back(port); } ///< Preprocessor thread + Raul::ListNode<PortImpl*>* remove_port(const string& name); void add_connection(Raul::ListNode<Connection*>* c) { _connections.push_back(c); } - Raul::ListNode<Connection*>* remove_connection(const Port* src_port, const Port* dst_port); + Raul::ListNode<Connection*>* remove_connection(const PortImpl* src_port, const PortImpl* dst_port); CompiledPatch* compiled_patch() { return _compiled_patch; } void compiled_patch(CompiledPatch* cp) { _compiled_patch = cp; } - Raul::Array<Port*>* external_ports() { return _ports; } - void external_ports(Raul::Array<Port*>* pa) { _ports = pa; } + Raul::Array<PortImpl*>* external_ports() { return _ports; } + void external_ports(Raul::Array<PortImpl*>* pa) { _ports = pa; } - CompiledPatch* compile() const; - Raul::Array<Port*>* build_ports_array() const; + CompiledPatch* compile() const; + Raul::Array<PortImpl*>* build_ports_array() const; /** Whether to run this patch's DSP bits in the audio thread */ bool enabled() const { return _process; } @@ -127,8 +127,8 @@ private: uint32_t _internal_poly; CompiledPatch* _compiled_patch; ///< Accessed in audio thread only Raul::List<Connection*> _connections; ///< Accessed in audio thread only - Raul::List<Port*> _input_ports; ///< Accessed in preprocessing thread only - Raul::List<Port*> _output_ports; ///< Accessed in preprocessing thread only + Raul::List<PortImpl*> _input_ports; ///< Accessed in preprocessing thread only + Raul::List<PortImpl*> _output_ports; ///< Accessed in preprocessing thread only Raul::List<NodeImpl*> _nodes; ///< Accessed in preprocessing thread only bool _process; }; diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/PortImpl.cpp index 2e0c362e..a6911154 100644 --- a/src/libs/engine/Port.cpp +++ b/src/libs/engine/PortImpl.cpp @@ -18,9 +18,9 @@ #include <iostream> #include <raul/Array.hpp> #include <raul/Maid.hpp> -#include "Port.hpp" +#include "PortImpl.hpp" #include "NodeImpl.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" #include "AudioBuffer.hpp" #include "MidiBuffer.hpp" #include "BufferFactory.hpp" @@ -32,11 +32,12 @@ using namespace std; namespace Ingen { -// FIXME: Make these actually URIs.. -const char* const DataType::type_uris[4] = { "UNKNOWN", "FLOAT", "MIDI", "OSC" }; - - -Port::Port(NodeImpl* const node, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size) +PortImpl::PortImpl(NodeImpl* const node, + const string& name, + uint32_t index, + uint32_t poly, + DataType type, + size_t buffer_size) : GraphObjectImpl(node, name, true) , _index(index) , _poly(poly) @@ -63,7 +64,7 @@ Port::Port(NodeImpl* const node, const string& name, uint32_t index, uint32_t po } -Port::~Port() +PortImpl::~PortImpl() { for (uint32_t i=0; i < _poly; ++i) delete _buffers->at(i); @@ -73,7 +74,7 @@ Port::~Port() bool -Port::prepare_poly(uint32_t poly) +PortImpl::prepare_poly(uint32_t poly) { if (!_polyphonic || !_parent->polyphonic()) return true; @@ -90,7 +91,7 @@ Port::prepare_poly(uint32_t poly) bool -Port::apply_poly(Raul::Maid& maid, uint32_t poly) +PortImpl::apply_poly(Raul::Maid& maid, uint32_t poly) { if (!_polyphonic || !_parent->polyphonic()) return true; @@ -109,10 +110,18 @@ Port::apply_poly(Raul::Maid& maid, uint32_t poly) return true; } + + +Raul::Atom +PortImpl::value() const +{ + // FIXME: will need this for ingen-side serialization + throw; +} void -Port::allocate_buffers() +PortImpl::allocate_buffers() { _buffers->alloc(_poly); @@ -122,7 +131,7 @@ Port::allocate_buffers() void -Port::set_buffer_size(size_t size) +PortImpl::set_buffer_size(size_t size) { _buffer_size = size; @@ -134,15 +143,15 @@ Port::set_buffer_size(size_t size) void -Port::connect_buffers() +PortImpl::connect_buffers() { for (uint32_t i=0; i < _poly; ++i) - Port::parent_node()->set_port_buffer(i, _index, _buffers->at(i)); + PortImpl::parent_node()->set_port_buffer(i, _index, _buffers->at(i)); } void -Port::clear_buffers() +PortImpl::clear_buffers() { for (uint32_t i=0; i < _poly; ++i) _buffers->at(i)->clear(); @@ -150,10 +159,10 @@ Port::clear_buffers() void -Port::broadcast(ProcessContext& context) +PortImpl::broadcast(ProcessContext& context) { if (_broadcast) { - if (_type == DataType::FLOAT && _buffer_size == 1) { + if (_type == DataType::CONTROL) { const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0); if (value != _last_broadcasted_value) { const SendPortValueEvent ev(context.engine(), context.start(), this, false, 0, value); diff --git a/src/libs/engine/Port.hpp b/src/libs/engine/PortImpl.hpp index 2484ea1f..c43a79b0 100644 --- a/src/libs/engine/Port.hpp +++ b/src/libs/engine/PortImpl.hpp @@ -15,15 +15,16 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PORT_H -#define PORT_H +#ifndef PORTIMPL_H +#define PORTIMPL_H #include <cstdlib> #include <string> #include <raul/Array.hpp> +#include "interface/Port.hpp" #include "types.hpp" #include "GraphObjectImpl.hpp" -#include "DataType.hpp" +#include "interface/DataType.hpp" namespace Raul { class Maid; } @@ -42,10 +43,10 @@ class ProcessContext; * * \ingroup engine */ -class Port : public GraphObjectImpl +class PortImpl : public GraphObjectImpl, public Ingen::Shared::Port { public: - virtual ~Port(); + virtual ~PortImpl(); /** A port's parent is always a node, so static cast should be safe */ NodeImpl* parent_node() const { return (NodeImpl*)_parent; } @@ -63,6 +64,8 @@ public: * \param poly Must be < the most recent value passed to prepare_poly. */ virtual bool apply_poly(Raul::Maid& maid, uint32_t poly); + + virtual Raul::Atom value() const; Buffer* buffer(uint32_t voice) const { return _buffers->at(voice); } @@ -77,10 +80,10 @@ public: virtual bool is_input() const = 0; virtual bool is_output() const = 0; - uint32_t num() const { return _index; } - uint32_t poly() const { return _poly; } - DataType type() const { return _type; } - size_t buffer_size() const { return _buffer_size; } + uint32_t num() const { return _index; } + uint32_t poly() const { return _poly; } + DataType type() const { return _type; } + size_t buffer_size() const { return _buffer_size; } virtual void set_buffer_size(size_t size); @@ -91,7 +94,12 @@ public: bool broadcast() { return _broadcast; } protected: - Port(NodeImpl* node, const std::string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size); + PortImpl(NodeImpl* node, + const std::string& name, + uint32_t index, + uint32_t poly, + DataType type, + size_t buffer_size); virtual void allocate_buffers(); virtual void connect_buffers(); @@ -114,4 +122,4 @@ protected: } // namespace Ingen -#endif // PORT_H +#endif // PORTIMPL_H diff --git a/src/libs/engine/TransportNode.cpp b/src/libs/engine/TransportNode.cpp index 4322f371..dca8eecb 100644 --- a/src/libs/engine/TransportNode.cpp +++ b/src/libs/engine/TransportNode.cpp @@ -20,7 +20,7 @@ #include "OutputPort.hpp" #include "PluginImpl.hpp" #include "JackAudioDriver.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "util.hpp" //#include "Engine.hpp" diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp index 891ca53b..1e6c0748 100644 --- a/src/libs/engine/events/ClearPatchEvent.cpp +++ b/src/libs/engine/events/ClearPatchEvent.cpp @@ -23,7 +23,7 @@ #include "ClientBroadcaster.hpp" #include "util.hpp" #include "ObjectStore.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "NodeImpl.hpp" #include "Connection.hpp" #include "QueuedEventSource.hpp" diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index d1ec1a89..7f8fa18e 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -27,7 +27,7 @@ #include "OutputPort.hpp" #include "Patch.hpp" #include "ClientBroadcaster.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" using std::string; diff --git a/src/libs/engine/events/ConnectionEvent.hpp b/src/libs/engine/events/ConnectionEvent.hpp index eb128660..8fa8c489 100644 --- a/src/libs/engine/events/ConnectionEvent.hpp +++ b/src/libs/engine/events/ConnectionEvent.hpp @@ -35,7 +35,7 @@ class Patch; class NodeImpl; class Connection; class MidiMessage; -class Port; +class PortImpl; class Connection; class InputPort; class OutputPort; @@ -71,8 +71,8 @@ private: Raul::Path _dst_port_path; Patch* _patch; - Port* _src_port; - Port* _dst_port; + PortImpl* _src_port; + PortImpl* _dst_port; OutputPort* _src_output_port; InputPort* _dst_input_port; diff --git a/src/libs/engine/events/CreateNodeEvent.cpp b/src/libs/engine/events/CreateNodeEvent.cpp index df891cd3..3a2715e0 100644 --- a/src/libs/engine/events/CreateNodeEvent.cpp +++ b/src/libs/engine/events/CreateNodeEvent.cpp @@ -28,7 +28,7 @@ #include "NodeFactory.hpp" #include "ClientBroadcaster.hpp" #include "ObjectStore.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" namespace Ingen { diff --git a/src/libs/engine/events/CreateNodeEvent.hpp b/src/libs/engine/events/CreateNodeEvent.hpp index 1452df05..75dfe3d7 100644 --- a/src/libs/engine/events/CreateNodeEvent.hpp +++ b/src/libs/engine/events/CreateNodeEvent.hpp @@ -30,7 +30,6 @@ namespace Ingen { class Patch; class NodeImpl; -class Plugin; class CompiledPatch; diff --git a/src/libs/engine/events/CreatePatchEvent.hpp b/src/libs/engine/events/CreatePatchEvent.hpp index 0b614013..15b67ffb 100644 --- a/src/libs/engine/events/CreatePatchEvent.hpp +++ b/src/libs/engine/events/CreatePatchEvent.hpp @@ -30,8 +30,6 @@ template<typename T> class TreeNode; namespace Ingen { class Patch; -class NodeImpl; -class Plugin; class CompiledPatch; diff --git a/src/libs/engine/events/CreatePortEvent.cpp b/src/libs/engine/events/CreatePortEvent.cpp index 065ca4a3..21875290 100644 --- a/src/libs/engine/events/CreatePortEvent.cpp +++ b/src/libs/engine/events/CreatePortEvent.cpp @@ -28,7 +28,7 @@ #include "QueuedEventSource.hpp" #include "ObjectStore.hpp" #include "ClientBroadcaster.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "AudioDriver.hpp" #include "MidiDriver.hpp" #include "OSCDriver.hpp" @@ -45,10 +45,11 @@ CreatePortEvent::CreatePortEvent(Engine& engine, bool is_output, QueuedEventSource* source) : QueuedEvent(engine, responder, timestamp, true, source), + _error(NO_ERROR), _path(path), _type(type), _is_output(is_output), - _data_type(DataType::UNKNOWN), + _data_type(type), _patch(NULL), _patch_port(NULL), _driver_port(NULL) @@ -61,20 +62,17 @@ CreatePortEvent::CreatePortEvent(Engine& engine, * FIXME: fix this using RCU */ - string type_str; - if (type == "ingen:control" || type == "ingen:audio") - _data_type = DataType::FLOAT; - else if (type == "ingen:midi") - _data_type = DataType::MIDI; - else if (type == "ingen:osc") - _data_type = DataType::OSC; + if (_data_type == DataType::UNKNOWN) { + cerr << "[CreatePortEvent] Unknown port type " << type << endl; + _error = UNKNOWN_TYPE; + } } void CreatePortEvent::pre_process() { - if (_engine.object_store()->find_object(_path) != NULL) { + if (_error == UNKNOWN_TYPE || _engine.object_store()->find_object(_path)) { QueuedEvent::pre_process(); return; } @@ -97,14 +95,14 @@ CreatePortEvent::pre_process() if (_patch_port) { if (_is_output) - _patch->add_output(new Raul::ListNode<Port*>(_patch_port)); + _patch->add_output(new Raul::ListNode<PortImpl*>(_patch_port)); else - _patch->add_input(new Raul::ListNode<Port*>(_patch_port)); + _patch->add_input(new Raul::ListNode<PortImpl*>(_patch_port)); if (_patch->external_ports()) - _ports_array = new Raul::Array<Port*>(old_num_ports + 1, *_patch->external_ports()); + _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, *_patch->external_ports()); else - _ports_array = new Raul::Array<Port*>(old_num_ports + 1, NULL); + _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, NULL); _ports_array->at(_patch->num_ports()-1) = _patch_port; @@ -160,7 +158,7 @@ CreatePortEvent::execute(ProcessContext& context) void CreatePortEvent::post_process() { - if (!_patch_port) { + if (_error != NO_ERROR || !_patch_port) { const string msg = string("Could not create port - ").append(_path); _responder->respond_error(msg); } else { diff --git a/src/libs/engine/events/CreatePortEvent.hpp b/src/libs/engine/events/CreatePortEvent.hpp index adae4892..d7835a25 100644 --- a/src/libs/engine/events/CreatePortEvent.hpp +++ b/src/libs/engine/events/CreatePortEvent.hpp @@ -21,7 +21,7 @@ #include "QueuedEvent.hpp" #include <raul/Path.hpp> #include <raul/Array.hpp> -#include "DataType.hpp" +#include "interface/DataType.hpp" #include <string> using std::string; @@ -30,8 +30,7 @@ template <typename T> class Array; namespace Ingen { class Patch; -class Port; -class Plugin; +class PortImpl; class DriverPort; @@ -49,15 +48,22 @@ public: void post_process(); private: - Raul::Path _path; - string _type; - bool _is_output; - DataType _data_type; - Patch* _patch; - Port* _patch_port; - Raul::Array<Port*>* _ports_array; ///< New (external) ports array for Patch - DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port - bool _succeeded; + + enum ErrorType { + NO_ERROR, + UNKNOWN_TYPE + }; + + ErrorType _error; + Raul::Path _path; + string _type; + bool _is_output; + DataType _data_type; + Patch* _patch; + PortImpl* _patch_port; + Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch + DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port + bool _succeeded; }; diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp index 575b1973..7fdda39f 100644 --- a/src/libs/engine/events/DestroyEvent.cpp +++ b/src/libs/engine/events/DestroyEvent.cpp @@ -30,7 +30,7 @@ #include "ClientBroadcaster.hpp" #include "ObjectStore.hpp" #include "QueuedEventSource.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" namespace Ingen { @@ -70,7 +70,7 @@ DestroyEvent::pre_process() _node = dynamic_cast<NodeImpl*>(_store_iterator->second); if (!_node) - _port = dynamic_cast<Port*>(_store_iterator->second); + _port = dynamic_cast<PortImpl*>(_store_iterator->second); } if (_store_iterator != _engine.object_store()->objects().end()) { @@ -155,7 +155,7 @@ DestroyEvent::execute(ProcessContext& context) _port->parent_patch()->external_ports(_ports_array); if ( ! _port->parent_patch()->parent()) { - if (_port->type() == DataType::FLOAT) + if (_port->type() == DataType::AUDIO) _driver_port = _engine.audio_driver()->remove_port(_port->path()); else if (_port->type() == DataType::MIDI) _driver_port = _engine.midi_driver()->remove_port(_port->path()); diff --git a/src/libs/engine/events/DestroyEvent.hpp b/src/libs/engine/events/DestroyEvent.hpp index 78ff3d7b..59a932b3 100644 --- a/src/libs/engine/events/DestroyEvent.hpp +++ b/src/libs/engine/events/DestroyEvent.hpp @@ -36,9 +36,8 @@ namespace Ingen { class GraphObjectImpl; class Patch; class NodeImpl; -class Port; +class PortImpl; class DriverPort; -class Plugin; class DisconnectNodeEvent; class DisconnectPortEvent; class CompiledPatch; @@ -63,11 +62,11 @@ private: ObjectStore::Objects::iterator _store_iterator; Table<Path,GraphObjectImpl*> _removed_table; NodeImpl* _node; ///< Same as _object if it is a Node, otherwise NULL - Port* _port; ///< Same as _object if it is a Port, otherwise NULL + PortImpl* _port; ///< Same as _object if it is a Port, otherwise NULL DriverPort* _driver_port; Raul::ListNode<NodeImpl*>* _patch_node_listnode; - Raul::ListNode<Port*>* _patch_port_listnode; - Raul::Array<Port*>* _ports_array; ///< New (external) ports array for Patch + Raul::ListNode<PortImpl*>* _patch_port_listnode; + Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch CompiledPatch* _compiled_patch; ///< Patch's new process order DisconnectNodeEvent* _disconnect_node_event; DisconnectPortEvent* _disconnect_port_event; diff --git a/src/libs/engine/events/DisablePortMonitoringEvent.cpp b/src/libs/engine/events/DisablePortMonitoringEvent.cpp index 3b5950ee..d5b99618 100644 --- a/src/libs/engine/events/DisablePortMonitoringEvent.cpp +++ b/src/libs/engine/events/DisablePortMonitoringEvent.cpp @@ -20,7 +20,7 @@ #include "events/DisablePortMonitoringEvent.hpp" #include "Responder.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" #include "ClientBroadcaster.hpp" #include "AudioBuffer.hpp" diff --git a/src/libs/engine/events/DisablePortMonitoringEvent.hpp b/src/libs/engine/events/DisablePortMonitoringEvent.hpp index b2fac41b..7a8e23f7 100644 --- a/src/libs/engine/events/DisablePortMonitoringEvent.hpp +++ b/src/libs/engine/events/DisablePortMonitoringEvent.hpp @@ -26,7 +26,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; namespace Shared { class ClientInterface; } using Shared::ClientInterface; diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp index 3ee93b81..8612d012 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.cpp +++ b/src/libs/engine/events/DisconnectNodeEvent.cpp @@ -29,7 +29,7 @@ #include "ObjectStore.hpp" #include "OutputPort.hpp" #include "Patch.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "Responder.hpp" #include "util.hpp" diff --git a/src/libs/engine/events/DisconnectNodeEvent.hpp b/src/libs/engine/events/DisconnectNodeEvent.hpp index 5decb923..cefe5a25 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.hpp +++ b/src/libs/engine/events/DisconnectNodeEvent.hpp @@ -31,7 +31,7 @@ class DisconnectionEvent; class Patch; class NodeImpl; class Connection; -class Port; +class PortImpl; class InputPort; class OutputPort; diff --git a/src/libs/engine/events/DisconnectPortEvent.cpp b/src/libs/engine/events/DisconnectPortEvent.cpp index 6ed328cf..f7ad9925 100644 --- a/src/libs/engine/events/DisconnectPortEvent.cpp +++ b/src/libs/engine/events/DisconnectPortEvent.cpp @@ -25,7 +25,7 @@ #include "NodeImpl.hpp" #include "Connection.hpp" #include "DisconnectionEvent.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "InputPort.hpp" #include "OutputPort.hpp" #include "Patch.hpp" diff --git a/src/libs/engine/events/DisconnectPortEvent.hpp b/src/libs/engine/events/DisconnectPortEvent.hpp index 85c37ed3..b30151ed 100644 --- a/src/libs/engine/events/DisconnectPortEvent.hpp +++ b/src/libs/engine/events/DisconnectPortEvent.hpp @@ -31,7 +31,7 @@ namespace Ingen { class Patch; class NodeImpl; class Connection; -class Port; +class PortImpl; class DisconnectionEvent; using std::string; diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp index 33dbdeeb..215e0202 100644 --- a/src/libs/engine/events/DisconnectionEvent.cpp +++ b/src/libs/engine/events/DisconnectionEvent.cpp @@ -26,7 +26,7 @@ #include "OutputPort.hpp" #include "Patch.hpp" #include "ClientBroadcaster.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" using std::string; @@ -50,7 +50,7 @@ DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr<Responder> resp } -DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Port* const src_port, Port* const dst_port) +DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, PortImpl* const src_port, PortImpl* const dst_port) : QueuedEvent(engine, responder, timestamp), _src_port_path(src_port->path()), _dst_port_path(dst_port->path()), diff --git a/src/libs/engine/events/DisconnectionEvent.hpp b/src/libs/engine/events/DisconnectionEvent.hpp index 46b2c015..aacb5082 100644 --- a/src/libs/engine/events/DisconnectionEvent.hpp +++ b/src/libs/engine/events/DisconnectionEvent.hpp @@ -35,7 +35,7 @@ class Patch; class NodeImpl; class Connection; class MidiMessage; -class Port; +class PortImpl; class Connection; class InputPort; class OutputPort; @@ -50,7 +50,7 @@ class DisconnectionEvent : public QueuedEvent { public: DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path); - DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Port* const src_port, Port* const dst_port); + DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, PortImpl* const src_port, PortImpl* const dst_port); void pre_process(); void execute(ProcessContext& context); @@ -72,8 +72,8 @@ private: Raul::Path _dst_port_path; Patch* _patch; - Port* _src_port; - Port* _dst_port; + PortImpl* _src_port; + PortImpl* _dst_port; OutputPort* _src_output_port; InputPort* _dst_input_port; diff --git a/src/libs/engine/events/EnablePortBroadcastingEvent.cpp b/src/libs/engine/events/EnablePortBroadcastingEvent.cpp index 018fd3cf..dcc09ac4 100644 --- a/src/libs/engine/events/EnablePortBroadcastingEvent.cpp +++ b/src/libs/engine/events/EnablePortBroadcastingEvent.cpp @@ -20,7 +20,7 @@ #include "events/EnablePortBroadcastingEvent.hpp" #include "Responder.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" #include "ClientBroadcaster.hpp" #include "AudioBuffer.hpp" diff --git a/src/libs/engine/events/EnablePortBroadcastingEvent.hpp b/src/libs/engine/events/EnablePortBroadcastingEvent.hpp index e24389cb..f9bc4e98 100644 --- a/src/libs/engine/events/EnablePortBroadcastingEvent.hpp +++ b/src/libs/engine/events/EnablePortBroadcastingEvent.hpp @@ -26,7 +26,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; namespace Shared { class ClientInterface; } using Shared::ClientInterface; @@ -50,7 +50,7 @@ public: private: const std::string _port_path; - Port* _port; + PortImpl* _port; bool _enable; }; diff --git a/src/libs/engine/events/LoadPluginsEvent.hpp b/src/libs/engine/events/LoadPluginsEvent.hpp index 966e3275..cd9a2884 100644 --- a/src/libs/engine/events/LoadPluginsEvent.hpp +++ b/src/libs/engine/events/LoadPluginsEvent.hpp @@ -23,8 +23,6 @@ namespace Ingen { -class Plugin; - /** Loads all plugins into the internal plugin database (in NodeFactory). * diff --git a/src/libs/engine/events/MidiLearnEvent.cpp b/src/libs/engine/events/MidiLearnEvent.cpp index 2cb39c0e..c2f2c4e5 100644 --- a/src/libs/engine/events/MidiLearnEvent.cpp +++ b/src/libs/engine/events/MidiLearnEvent.cpp @@ -64,8 +64,8 @@ MidiLearnEvent::execute(ProcessContext& context) QueuedEvent::execute(context); // FIXME: this isn't very good at all. - if (_node != NULL && _node->plugin()->type() == Plugin::Internal - && _node->plugin()->plug_label() == "midi_control_in") { + if (_node != NULL && _node->plugin_impl()->type() == Plugin::Internal + && _node->plugin_impl()->plug_label() == "midi_control_in") { ((MidiControlNode*)_node)->learn(_response_event); } } diff --git a/src/libs/engine/events/NoteEvent.cpp b/src/libs/engine/events/NoteEvent.cpp index 9c69b9df..fb0347af 100644 --- a/src/libs/engine/events/NoteEvent.cpp +++ b/src/libs/engine/events/NoteEvent.cpp @@ -71,14 +71,14 @@ NoteEvent::execute(ProcessContext& context) if (_node != NULL && _node->plugin()->type() == Plugin::Internal) { if (_on) { - if (_node->plugin()->plug_label() == "note_in") + if (_node->plugin_impl()->plug_label() == "note_in") ((MidiNoteNode*)_node)->note_on(_note_num, _velocity, _time, context); - else if (_node->plugin()->plug_label() == "trigger_in") + else if (_node->plugin_impl()->plug_label() == "trigger_in") ((MidiTriggerNode*)_node)->note_on(_note_num, _velocity, _time, context); } else { - if (_node->plugin()->plug_label() == "note_in") + if (_node->plugin_impl()->plug_label() == "note_in") ((MidiNoteNode*)_node)->note_off(_note_num, _time, context); - else if (_node->plugin()->plug_label() == "trigger_in") + else if (_node->plugin_impl()->plug_label() == "trigger_in") ((MidiTriggerNode*)_node)->note_off(_note_num, _time, context); } } diff --git a/src/libs/engine/events/PingQueuedEvent.hpp b/src/libs/engine/events/PingQueuedEvent.hpp index 88c03aaa..08897bfe 100644 --- a/src/libs/engine/events/PingQueuedEvent.hpp +++ b/src/libs/engine/events/PingQueuedEvent.hpp @@ -24,7 +24,7 @@ namespace Ingen { -class Port; +class PortImpl; /** A ping that travels through the pre-processed event queue before responding diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp index edd67fad..72e27ec9 100644 --- a/src/libs/engine/events/RenameEvent.cpp +++ b/src/libs/engine/events/RenameEvent.cpp @@ -105,11 +105,11 @@ RenameEvent::execute(ProcessContext& context) { QueuedEvent::execute(context); - Port* port = dynamic_cast<Port*>(_store_iterator->second); + PortImpl* port = dynamic_cast<PortImpl*>(_store_iterator->second); if (port && port->parent()->parent() == NULL) { DriverPort* driver_port = NULL; - if (port->type() == DataType::FLOAT) + if (port->type() == DataType::AUDIO) driver_port = _engine.audio_driver()->driver_port(_new_path); else if (port->type() == DataType::MIDI) driver_port = _engine.midi_driver()->driver_port(_new_path); diff --git a/src/libs/engine/events/RequestObjectEvent.cpp b/src/libs/engine/events/RequestObjectEvent.cpp index 0c46546f..13ad936e 100644 --- a/src/libs/engine/events/RequestObjectEvent.cpp +++ b/src/libs/engine/events/RequestObjectEvent.cpp @@ -24,7 +24,7 @@ #include "ClientBroadcaster.hpp" #include "Patch.hpp" #include "NodeImpl.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectSender.hpp" #include "ProcessContext.hpp" @@ -79,7 +79,7 @@ RequestObjectEvent::post_process() return; } - Port* const port = dynamic_cast<Port*>(_object); + PortImpl* const port = dynamic_cast<PortImpl*>(_object); if (port) { _responder->respond_ok(); ObjectSender::send_port(_responder->client(), port); diff --git a/src/libs/engine/events/RequestPluginEvent.cpp b/src/libs/engine/events/RequestPluginEvent.cpp index f2886902..21ad97d4 100644 --- a/src/libs/engine/events/RequestPluginEvent.cpp +++ b/src/libs/engine/events/RequestPluginEvent.cpp @@ -20,7 +20,7 @@ #include "RequestPluginEvent.hpp" #include "Responder.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" #include "ClientBroadcaster.hpp" #include "NodeFactory.hpp" diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp index 224c3045..e26b1036 100644 --- a/src/libs/engine/events/RequestPortValueEvent.cpp +++ b/src/libs/engine/events/RequestPortValueEvent.cpp @@ -20,7 +20,7 @@ #include "interface/ClientInterface.hpp" #include "Responder.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ObjectStore.hpp" #include "ClientBroadcaster.hpp" #include "AudioBuffer.hpp" @@ -55,7 +55,7 @@ RequestPortValueEvent::execute(ProcessContext& context) QueuedEvent::execute(context); assert(_time >= context.start() && _time <= context.end()); - if (_port != NULL && _port->type() == DataType::FLOAT) + if (_port != NULL && (_port->type() == DataType::CONTROL || _port->type() == DataType::AUDIO)) _value = ((AudioBuffer*)_port->buffer(0))->value_at(0/*_time - start*/); else _port = NULL; // triggers error response diff --git a/src/libs/engine/events/RequestPortValueEvent.hpp b/src/libs/engine/events/RequestPortValueEvent.hpp index d3bccfdc..dd52c535 100644 --- a/src/libs/engine/events/RequestPortValueEvent.hpp +++ b/src/libs/engine/events/RequestPortValueEvent.hpp @@ -26,7 +26,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; namespace Shared { class ClientInterface; } using Shared::ClientInterface; @@ -45,9 +45,9 @@ public: void post_process(); private: - string _port_path; - Port* _port; - Sample _value; + const string _port_path; + PortImpl* _port; + Sample _value; }; diff --git a/src/libs/engine/events/SendPortActivityEvent.cpp b/src/libs/engine/events/SendPortActivityEvent.cpp index 9d8f786d..0ab3abdd 100644 --- a/src/libs/engine/events/SendPortActivityEvent.cpp +++ b/src/libs/engine/events/SendPortActivityEvent.cpp @@ -17,7 +17,7 @@ #include "SendPortActivityEvent.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ClientBroadcaster.hpp" namespace Ingen { diff --git a/src/libs/engine/events/SendPortActivityEvent.hpp b/src/libs/engine/events/SendPortActivityEvent.hpp index 565167d3..dfbb8a10 100644 --- a/src/libs/engine/events/SendPortActivityEvent.hpp +++ b/src/libs/engine/events/SendPortActivityEvent.hpp @@ -25,7 +25,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; /** A special event used internally to send port activity notification (e.g. @@ -45,7 +45,7 @@ class SendPortActivityEvent : public Event public: inline SendPortActivityEvent(Engine& engine, SampleCount timestamp, - Port* port) + PortImpl* port) : Event(engine, SharedPtr<Responder>(), timestamp) , _port(port) { @@ -58,7 +58,7 @@ public: void post_process(); private: - Port* _port; + PortImpl* _port; }; diff --git a/src/libs/engine/events/SendPortValueEvent.cpp b/src/libs/engine/events/SendPortValueEvent.cpp index f663f85c..89e8c9e0 100644 --- a/src/libs/engine/events/SendPortValueEvent.cpp +++ b/src/libs/engine/events/SendPortValueEvent.cpp @@ -18,7 +18,7 @@ #include <sstream> #include "SendPortValueEvent.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ClientBroadcaster.hpp" using namespace std; diff --git a/src/libs/engine/events/SendPortValueEvent.hpp b/src/libs/engine/events/SendPortValueEvent.hpp index 407f0119..e8505914 100644 --- a/src/libs/engine/events/SendPortValueEvent.hpp +++ b/src/libs/engine/events/SendPortValueEvent.hpp @@ -25,7 +25,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; /** A special event used internally to send port values from the audio thread. @@ -44,7 +44,7 @@ class SendPortValueEvent : public Event public: inline SendPortValueEvent(Engine& engine, SampleCount timestamp, - Port* port, + PortImpl* port, bool omni, uint32_t voice_num, Sample value) @@ -66,10 +66,10 @@ public: void post_process(); private: - Port* _port; - bool _omni; - uint32_t _voice_num; - Sample _value; + PortImpl* _port; + bool _omni; + uint32_t _voice_num; + Sample _value; }; diff --git a/src/libs/engine/events/SetPolyphonicEvent.cpp b/src/libs/engine/events/SetPolyphonicEvent.cpp index 04bdc6aa..8cca2373 100644 --- a/src/libs/engine/events/SetPolyphonicEvent.cpp +++ b/src/libs/engine/events/SetPolyphonicEvent.cpp @@ -23,7 +23,7 @@ #include "ClientBroadcaster.hpp" #include "util.hpp" #include "ObjectStore.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "NodeImpl.hpp" #include "Connection.hpp" #include "QueuedEventSource.hpp" diff --git a/src/libs/engine/events/SetPolyphonyEvent.cpp b/src/libs/engine/events/SetPolyphonyEvent.cpp index a1f03add..8e0d12cd 100644 --- a/src/libs/engine/events/SetPolyphonyEvent.cpp +++ b/src/libs/engine/events/SetPolyphonyEvent.cpp @@ -23,7 +23,7 @@ #include "ClientBroadcaster.hpp" #include "util.hpp" #include "ObjectStore.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "NodeImpl.hpp" #include "Connection.hpp" #include "QueuedEventSource.hpp" diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index cc7a79e3..f278c083 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -19,7 +19,7 @@ #include "Responder.hpp" #include "SetPortValueEvent.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ClientBroadcaster.hpp" #include "NodeImpl.hpp" #include "ObjectStore.hpp" @@ -34,11 +34,11 @@ namespace Ingen { /** Omni (all voices) control setting */ SetPortValueEvent::SetPortValueEvent(Engine& engine, - SharedPtr<Responder> responder, - SampleCount timestamp, - const string& port_path, - uint32_t data_size, - const void* data) + SharedPtr<Responder> responder, + SampleCount timestamp, + const string& port_path, + uint32_t data_size, + const void* data) : Event(engine, responder, timestamp), _omni(true), _voice_num(0), diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp index 0761ed39..c9d46a8e 100644 --- a/src/libs/engine/events/SetPortValueEvent.hpp +++ b/src/libs/engine/events/SetPortValueEvent.hpp @@ -25,7 +25,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; /** An event to change the value of a port. @@ -63,7 +63,7 @@ private: string _port_path; uint32_t _data_size; void* _data; - Port* _port; + PortImpl* _port; ErrorType _error; }; diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp index 026f22b6..7d11b1ae 100644 --- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp +++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp @@ -19,7 +19,7 @@ #include "SetPortValueQueuedEvent.hpp" #include "Responder.hpp" #include "Engine.hpp" -#include "Port.hpp" +#include "PortImpl.hpp" #include "ClientBroadcaster.hpp" #include "PluginImpl.hpp" #include "NodeImpl.hpp" diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.hpp b/src/libs/engine/events/SetPortValueQueuedEvent.hpp index c6a3c0ee..382a574e 100644 --- a/src/libs/engine/events/SetPortValueQueuedEvent.hpp +++ b/src/libs/engine/events/SetPortValueQueuedEvent.hpp @@ -25,7 +25,7 @@ using std::string; namespace Ingen { -class Port; +class PortImpl; /** An event to change the value of a port. @@ -62,7 +62,7 @@ private: string _port_path; uint32_t _data_size; void* _data; - Port* _port; + PortImpl* _port; ErrorType _error; }; diff --git a/src/libs/gui/Configuration.cpp b/src/libs/gui/Configuration.cpp index ffef8137..f4c00545 100644 --- a/src/libs/gui/Configuration.cpp +++ b/src/libs/gui/Configuration.cpp @@ -83,21 +83,21 @@ Configuration::apply_settings() uint32_t -Configuration::get_port_color(const PortModel* pi) +Configuration::get_port_color(const PortModel* p) { - assert(pi != NULL); - - if (pi->is_control()) { + assert(p != NULL); + + if (p->is_control()) { return _control_port_color; - } else if (pi->is_audio()) { + } else if (p->is_audio()) { return _audio_port_color; - } else if (pi->is_midi()) { + } else if (p->is_midi()) { return _midi_port_color; - } else if (pi->is_osc()) { + } else if (p->is_osc()) { return _osc_port_color; } - cerr << "[Configuration] Unknown port type " << pi->type() << ", port will appear bright red." + cerr << "[Configuration] Unknown port type " << p->type() << ", port will appear bright red." << endl; return 0xFF0000B0; diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index d7cf0154..875a6d8c 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -128,7 +128,11 @@ NodeModule::embed_gui(bool embed) if (!_gui_item) { cerr << "Embedding LV2 GUI" << endl; - _slv2_ui = _node->plugin()->ui(App::instance().engine().get(), _node.get()); + const PluginModel* const plugin = dynamic_cast<const PluginModel*>(_node->plugin()); + assert(plugin); + + _slv2_ui = plugin->ui(App::instance().engine().get(), _node.get()); + if (_slv2_ui) { cerr << "Found UI" << endl; c_widget = (GtkWidget*)slv2_ui_instance_get_widget(_slv2_ui); @@ -276,7 +280,11 @@ NodeModule::popup_gui() return false; } - _slv2_ui = _node->plugin()->ui(App::instance().engine().get(), _node.get()); + const PluginModel* const plugin = dynamic_cast<const PluginModel*>(_node->plugin()); + assert(plugin); + + _slv2_ui = plugin->ui(App::instance().engine().get(), _node.get()); + if (_slv2_ui) { cerr << "Popping up LV2 GUI" << endl; diff --git a/src/libs/gui/NodePropertiesWindow.cpp b/src/libs/gui/NodePropertiesWindow.cpp index a6fb46ee..9848d872 100644 --- a/src/libs/gui/NodePropertiesWindow.cpp +++ b/src/libs/gui/NodePropertiesWindow.cpp @@ -52,7 +52,8 @@ NodePropertiesWindow::set_node(SharedPtr<NodeModel> node_model) _node_path_label->set_text(node_model->path()); _node_polyphonic_toggle->set_active(node_model->polyphonic()); - SharedPtr<PluginModel> pm = node_model->plugin(); + const PluginModel* pm = dynamic_cast<const PluginModel*>(node_model->plugin()); + assert(pm); if (pm) { _plugin_type_label->set_text(pm->type_uri()); diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index 236ed0d3..5e3c7f78 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -74,28 +74,28 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) // Add port menu items _menu_add_audio_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "audio_input", "ingen:audio", false)); + "audio_input", "ingen:AudioPort", false)); _menu_add_audio_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "audio_output", "ingen:audio", true)); + "audio_output", "ingen:AudioPort", true)); _menu_add_control_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "control_input", "ingen:control", false)); + "control_input", "ingen:ControlPort", false)); _menu_add_control_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "control_output", "ingen:control", true)); + "control_output", "ingen:ControlPort", true)); _menu_add_midi_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "midi_input", "ingen:midi", false)); + "midi_input", "ingen:MidiPort", false)); _menu_add_midi_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "midi_output", "ingen:midi", true)); + "midi_output", "ingen:MidiPort", true)); _menu_add_osc_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "osc_input", "ingen:osc", false)); + "osc_input", "ingen:OSCPort", false)); _menu_add_osc_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "osc_output", "ingen:osc", true)); + "osc_output", "ingen:OSCPort", true)); // Add control menu items /*_menu_add_number_control->signal_activate().connect( |