summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/Port.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-08 06:04:32 +0000
committerDavid Robillard <d@drobilla.net>2007-04-08 06:04:32 +0000
commite96c36c1a7abb062e36efc0ac95c35fedcef922e (patch)
tree826d5caa0392201472d12c02a1c3df4cf7b275be /src/libs/engine/Port.cpp
parent7d69e89f22304e37fa325ce4f39a374a02072a69 (diff)
downloadingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.gz
ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.bz2
ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.zip
De-template-ification of port types (req. for LV2 MIDI, but nice code size reduction).
LV2 MIDI patching support (LV2 style MIDI throughout, inc. internal plugins). git-svn-id: http://svn.drobilla.net/lad/ingen@415 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/Port.cpp')
-rw-r--r--src/libs/engine/Port.cpp71
1 files changed, 66 insertions, 5 deletions
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp
index 7ab811b2..4b9a014b 100644
--- a/src/libs/engine/Port.cpp
+++ b/src/libs/engine/Port.cpp
@@ -18,6 +18,8 @@
#include "Port.h"
#include "Node.h"
#include "DataType.h"
+#include "Buffer.h"
+#include "BufferFactory.h"
namespace Ingen {
@@ -27,14 +29,73 @@ const char* const DataType::type_uris[3] = { "UNKNOWN", "FLOAT", "MIDI" };
Port::Port(Node* const node, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size)
-: GraphObject(node, name),
- _index(index),
- _poly(poly),
- _type(type),
- _buffer_size(buffer_size)
+ : GraphObject(node, name)
+ , _index(index)
+ , _poly(poly)
+ , _type(type)
+ , _buffer_size(buffer_size)
+ , _fixed_buffers(false)
{
assert(node != NULL);
assert(_poly > 0);
+
+ allocate_buffers();
+ clear_buffers();
+
+ assert(_buffers.size() > 0);
+}
+
+
+Port::~Port()
+{
+ for (size_t i=0; i < _poly; ++i)
+ delete _buffers.at(i);
+}
+
+
+void
+Port::allocate_buffers()
+{
+ _buffers.alloc(_poly);
+
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i) = BufferFactory::create(_type, _buffer_size);
+}
+
+
+void
+Port::set_buffer_size(size_t size)
+{
+ _buffer_size = size;
+
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->resize(size);
+
+ connect_buffers();
+}
+
+
+void
+Port::connect_buffers()
+{
+ for (size_t i=0; i < _poly; ++i)
+ Port::parent_node()->set_port_buffer(i, _index, _buffers.at(i));
+}
+
+
+void
+Port::clear_buffers()
+{
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->clear();
+}
+
+
+void
+Port::process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare(nframes);
}