From a9c2f879531def187ff3d542736a429a9536e94c Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 22 Jun 2006 07:38:52 +0000 Subject: [PATCH] LADSPA port default value loading (engine side) git-svn-id: http://svn.drobilla.net/lad@77 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/src/libs/engine/InputPort.h | 4 --- ingen/src/libs/engine/LADSPANode.cpp | 10 +++--- ingen/src/libs/engine/Makefile.am | 1 - ingen/src/libs/engine/ObjectSender.cpp | 20 ++++------- ingen/src/libs/engine/OutputPort.cpp | 49 -------------------------- ingen/src/libs/engine/OutputPort.h | 12 +++---- ingen/src/libs/engine/TypedPort.cpp | 6 ++-- ingen/src/libs/engine/TypedPort.h | 7 +--- 8 files changed, 23 insertions(+), 86 deletions(-) delete mode 100644 ingen/src/libs/engine/OutputPort.cpp diff --git a/ingen/src/libs/engine/InputPort.h b/ingen/src/libs/engine/InputPort.h index d7af9871..e66cf11a 100644 --- a/ingen/src/libs/engine/InputPort.h +++ b/ingen/src/libs/engine/InputPort.h @@ -57,8 +57,6 @@ public: void process(samplecount nframes); - //void tie(OutputPort* const port); - bool is_connected() const { return (m_connections.size() > 0); } bool is_connected_to(const OutputPort* const port) const; @@ -75,8 +73,6 @@ private: List*> m_connections; // This is just stupid... - //using TypedPort::m_is_tied; - //using TypedPort::m_tied_port; using TypedPort::m_buffers; using TypedPort::_poly; using TypedPort::_index; diff --git a/ingen/src/libs/engine/LADSPANode.cpp b/ingen/src/libs/engine/LADSPANode.cpp index da053b35..a143d5fa 100644 --- a/ingen/src/libs/engine/LADSPANode.cpp +++ b/ingen/src/libs/engine/LADSPANode.cpp @@ -114,10 +114,11 @@ LADSPANode::instantiate() sample default_val = default_port_value(j); // Set default control val - if (port->buffer_size() == 1) + if (port->buffer_size() == 1) { ((TypedPort*)port)->set_value(default_val, 0); - else + } else { ((TypedPort*)port)->set_value(0.0f, 0); + } } return true; @@ -144,10 +145,10 @@ LADSPANode::activate() for (unsigned long j=0; j < _descriptor->PortCount; ++j) { port = static_cast*>(_ports->at(j)); set_port_buffer(i, j, ((TypedPort*)_ports->at(j))->buffer(i)->data()); - if (port->type() == DataType::FLOAT && port->buffer_size() == 1) + /* if (port->type() == DataType::FLOAT && port->buffer_size() == 1) port->set_value(0.0f, 0); // FIXME else if (port->type() == DataType::FLOAT && port->buffer_size() > 1) - port->set_value(0.0f, 0); + port->set_value(0.0f, 0);*/ } if (_descriptor->activate != NULL) _descriptor->activate(_instances[i]); @@ -328,6 +329,7 @@ LADSPANode::default_port_value(ulong port_index) } } + cerr << path() << " Port " << port_index << " LADSPA Default value: " << normal << endl; // FIXME: set min/max as metadata return normal; } diff --git a/ingen/src/libs/engine/Makefile.am b/ingen/src/libs/engine/Makefile.am index 889f98fd..a7fd98c1 100644 --- a/ingen/src/libs/engine/Makefile.am +++ b/ingen/src/libs/engine/Makefile.am @@ -46,7 +46,6 @@ libingen_la_SOURCES = \ InputPort.h \ InputPort.cpp \ OutputPort.h \ - OutputPort.cpp \ DuplexPort.h \ DuplexPort.cpp \ MidiMessage.h \ diff --git a/ingen/src/libs/engine/ObjectSender.cpp b/ingen/src/libs/engine/ObjectSender.cpp index 33f261fb..b79a5df0 100644 --- a/ingen/src/libs/engine/ObjectSender.cpp +++ b/ingen/src/libs/engine/ObjectSender.cpp @@ -88,17 +88,6 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch) void ObjectSender::send_node(ClientInterface* client, const Node* node) { - // Don't send node notification for bridge nodes, from the client's - // perspective they don't even exist (just the ports they represent) - // FIXME: hack, these nodes probably shouldn't even exist in the - // engine anymore - /*if (const_cast(node)->as_port()) { // bridge node if as_port() returns non-NULL - // FIXME: remove this whole thing. shouldn't be any bridge nodes anymore - assert(false); - send_port(client, const_cast(node)->as_port()); - return; - }*/ - const Plugin* const plugin = node->plugin(); int polyphonic = @@ -163,9 +152,12 @@ ObjectSender::send_port(ClientInterface* client, const Port* port) client->new_port(port->path(), type, port->is_output()); // Send control value - if (port->type() == DataType::FLOAT && port->buffer_size() == 1) - client->control_change(port->path(), - dynamic_cast*>(port)->buffer(0)->value_at(0)); + if (port->type() == DataType::FLOAT && port->buffer_size() == 1) { + sample default_value = dynamic_cast*>( + port)->buffer(0)->value_at(0); + cerr << port->path() << " sending default value " << default_value << endl; + client->control_change(port->path(), default_value); + } // Send metadata const map& data = port->metadata(); diff --git a/ingen/src/libs/engine/OutputPort.cpp b/ingen/src/libs/engine/OutputPort.cpp deleted file mode 100644 index 31280d49..00000000 --- a/ingen/src/libs/engine/OutputPort.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * Om 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. - * - * Om 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 - */ - -#include "OutputPort.h" -#include "InputPort.h" -#include - -namespace Om { - -template -OutputPort::OutputPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size) -: TypedPort(parent, name, index, poly, type, buffer_size) -{ -} -template OutputPort::OutputPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size); -template OutputPort::OutputPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size); - -#if 0 -template -void -OutputPort::set_tied_port(InputPort* port) -{ - //assert(!m_is_tied); - //assert(m_tied_port == NULL); - assert(static_cast*>(port) != static_cast*>(this)); - assert(port != NULL); - - //m_is_tied = true; - //m_tied_port = (TypedPort*)port; -} -template void OutputPort::set_tied_port(InputPort* port); -template void OutputPort::set_tied_port(InputPort* port); -#endif - -} // namespace Om - diff --git a/ingen/src/libs/engine/OutputPort.h b/ingen/src/libs/engine/OutputPort.h index 89cb3398..23ead848 100644 --- a/ingen/src/libs/engine/OutputPort.h +++ b/ingen/src/libs/engine/OutputPort.h @@ -42,11 +42,14 @@ template class OutputPort : virtual public TypedPort { public: - OutputPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size); + OutputPort(Node* parent, const string& name, + size_t index, size_t poly, + DataType type, size_t buffer_size) + : TypedPort(parent, name, index, poly, type, buffer_size) + {} + virtual ~OutputPort() {} - //void set_tied_port(InputPort* port); - bool is_input() const { return false; } bool is_output() const { return true; } @@ -54,9 +57,6 @@ private: // Prevent copies (undefined) OutputPort(const OutputPort& copy); OutputPort& operator=(const OutputPort&); - - //using TypedPort::m_is_tied; - //using TypedPort::m_tied_port; }; diff --git a/ingen/src/libs/engine/TypedPort.cpp b/ingen/src/libs/engine/TypedPort.cpp index 1dad267b..4112ee20 100644 --- a/ingen/src/libs/engine/TypedPort.cpp +++ b/ingen/src/libs/engine/TypedPort.cpp @@ -33,8 +33,6 @@ template TypedPort::TypedPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size) : Port(parent, name, index, poly, type, buffer_size) , m_fixed_buffers(false) -/*, m_is_tied(false) -, m_tied_port(NULL)*/ { allocate_buffers(); clear_buffers(); @@ -66,6 +64,8 @@ TypedPort::set_value(sample val, size_t offset) if (offset >= _buffer_size) offset = 0; assert(offset < _buffer_size); + + cerr << path() << " setting value " << val << endl; for (size_t v=0; v < _poly; ++v) m_buffers.at(v)->set(val, offset); @@ -80,6 +80,8 @@ TypedPort::set_value(size_t voice, sample val, size_t offset) if (offset >= _buffer_size) offset = 0; assert(offset < _buffer_size); + + cerr << path() << " setting voice value " << val << endl; m_buffers.at(voice)->set(val, offset); } diff --git a/ingen/src/libs/engine/TypedPort.h b/ingen/src/libs/engine/TypedPort.h index 04a9bee9..9d4f2dd5 100644 --- a/ingen/src/libs/engine/TypedPort.h +++ b/ingen/src/libs/engine/TypedPort.h @@ -52,9 +52,6 @@ public: virtual void process(samplecount nframes); virtual void clear_buffers(); - //TypedPort* tied_port() const { return m_tied_port; } - //void untie() { m_is_tied = false; m_tied_port = NULL; } - /** Used by drivers to prevent port from changing buffers */ void fixed_buffers(bool b) { m_fixed_buffers = b; } bool fixed_buffers() { return m_fixed_buffers; } @@ -68,9 +65,7 @@ protected: void allocate_buffers(); - bool m_fixed_buffers; - //bool m_is_tied; - //TypedPort* m_tied_port; + bool m_fixed_buffers; Array*> m_buffers; };