summaryrefslogtreecommitdiffstats
path: root/src/server/ArcImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-29 20:34:32 +0000
committerDavid Robillard <d@drobilla.net>2012-12-29 20:34:32 +0000
commit79275fc579c0dbe1ce4ca109edb95f2c1e0802a5 (patch)
tree72bb18ea61f485c47514a511dd3067c57aa2fb4b /src/server/ArcImpl.cpp
parent9bdf223f830d3b430563e96d93efc073b1882e96 (diff)
downloadingen-79275fc579c0dbe1ce4ca109edb95f2c1e0802a5.tar.gz
ingen-79275fc579c0dbe1ce4ca109edb95f2c1e0802a5.tar.bz2
ingen-79275fc579c0dbe1ce4ca109edb95f2c1e0802a5.zip
"edge" => "arc".
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4897 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/ArcImpl.cpp')
-rw-r--r--src/server/ArcImpl.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp
new file mode 100644
index 00000000..debd2c1e
--- /dev/null
+++ b/src/server/ArcImpl.cpp
@@ -0,0 +1,107 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ingen/URIs.hpp"
+#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+
+#include "ArcImpl.hpp"
+#include "BlockImpl.hpp"
+#include "Buffer.hpp"
+#include "BufferFactory.hpp"
+#include "Engine.hpp"
+#include "InputPort.hpp"
+#include "OutputPort.hpp"
+#include "PortImpl.hpp"
+
+namespace Ingen {
+namespace Server {
+
+/** Constructor for an arc from a block's output port.
+ *
+ * This handles both polyphonic and monophonic blocks, transparently to the
+ * user (InputPort).
+ */
+ArcImpl::ArcImpl(PortImpl* tail, PortImpl* head)
+ : _tail(tail)
+ , _head(head)
+{
+ assert(tail != head);
+ assert(tail->path() != head->path());
+}
+
+const Raul::Path&
+ArcImpl::tail_path() const
+{
+ return _tail->path();
+}
+
+const Raul::Path&
+ArcImpl::head_path() const
+{
+ return _head->path();
+}
+
+BufferRef
+ArcImpl::buffer(uint32_t voice) const
+{
+ assert(!must_mix());
+ assert(_tail->poly() == 1 || _tail->poly() > voice);
+ if (_tail->poly() == 1) {
+ return _tail->buffer(0);
+ } else {
+ return _tail->buffer(voice);
+ }
+}
+
+bool
+ArcImpl::must_mix() const
+{
+ return _tail->poly() > _head->poly();
+}
+
+bool
+ArcImpl::can_connect(const OutputPort* src, const InputPort* dst)
+{
+ const Ingen::URIs& uris = src->bufs().uris();
+ return (
+ // (Audio | Control | CV) => (Audio | Control | CV)
+ ( (src->is_a(PortType::CONTROL) ||
+ src->is_a(PortType::AUDIO) ||
+ src->is_a(PortType::CV))
+ && (dst->is_a(PortType::CONTROL)
+ || dst->is_a(PortType::AUDIO)
+ || dst->is_a(PortType::CV)))
+
+ // Equal types
+ || (src->type() == dst->type() &&
+ src->buffer_type() == dst->buffer_type())
+
+ // Control => atom:Float Value
+ || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float))
+
+ // Audio => atom:Sound Value
+ || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound))
+
+ // atom:Float Value => Control
+ || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL))
+
+ // atom:Sound Value => Audio
+ || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO)));
+}
+
+} // namespace Server
+} // namespace Ingen
+