summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/Connection.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-21 00:46:21 +0000
committerDavid Robillard <d@drobilla.net>2007-09-21 00:46:21 +0000
commit2fd281a285e4b0bc31e0a0dc6f970359440612c8 (patch)
treeb4537d5196d13608cacb32f4c96bdb24ff180b3d /src/libs/engine/Connection.cpp
parentc4faafc0d3b9c68d41706ad40edde1ecfb7f4338 (diff)
downloadingen-2fd281a285e4b0bc31e0a0dc6f970359440612c8.tar.gz
ingen-2fd281a285e4b0bc31e0a0dc6f970359440612c8.tar.bz2
ingen-2fd281a285e4b0bc31e0a0dc6f970359440612c8.zip
Somewhat functional dynamic polyphony (LV2 and internal nodes only).
git-svn-id: http://svn.drobilla.net/lad/ingen@744 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/Connection.cpp')
-rw-r--r--src/libs/engine/Connection.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp
index bae72412..c2ecb2ec 100644
--- a/src/libs/engine/Connection.cpp
+++ b/src/libs/engine/Connection.cpp
@@ -16,6 +16,7 @@
*/
#include <algorithm>
+#include <raul/Maid.hpp>
#include "util.hpp"
#include "Connection.hpp"
#include "Node.hpp"
@@ -36,7 +37,10 @@ Connection::Connection(Port* src_port, Port* dst_port)
, _dst_port(dst_port)
, _local_buffer(NULL)
, _buffer_size(dst_port->buffer_size())
- , _must_mix( (src_port->poly() != dst_port->poly())
+ /*, _must_mix( (src_port->poly() != dst_port->poly())
+ || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )*/
+ , _must_mix( (src_port->polyphonic() && (! dst_port->polyphonic()))
+ || (src_port->poly() != dst_port->poly() )
|| (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )
, _pending_disconnection(false)
{
@@ -75,6 +79,33 @@ Connection::set_buffer_size(size_t size)
void
+Connection::prepare_poly(uint32_t poly)
+{
+ _must_mix = (type() == DataType::FLOAT) && (poly > 1) && (
+ (_src_port->poly() != _dst_port->poly())
+ || (_src_port->polyphonic() && !_dst_port->polyphonic())
+ || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) );
+
+ /*cerr << src_port()->path() << " * " << src_port()->poly()
+ << " -> " << dst_port()->path() << " * " << dst_port()->poly()
+ << "\t\tmust mix: " << _must_mix << " at poly " << poly << endl;*/
+
+ if (_must_mix && ! _local_buffer)
+ _local_buffer = BufferFactory::create(_dst_port->type(), _dst_port->buffer(0)->size());
+}
+
+
+void
+Connection::apply_poly(Raul::Maid& maid, uint32_t poly)
+{
+ if (poly == 1 && _local_buffer && !_must_mix) {
+ maid.push(_local_buffer);
+ _local_buffer = NULL;
+ }
+}
+
+
+void
Connection::process(SampleCount nframes, FrameTime start, FrameTime end)
{
// FIXME: nframes parameter not used
@@ -97,8 +128,8 @@ Connection::process(SampleCount nframes, FrameTime start, FrameTime end)
const size_t copy_size = std::min(src_buffer->size(), mix_buf->size());
- //cerr << "Mixing " << src_port()->buffer(0)->data()
- // << " -> " << _local_buffer->data() << endl;
+ /*cerr << "[Connection] Mixing " << src_port()->path() << " * " << src_port()->poly()
+ << " -> " << dst_port()->path() << " * " << dst_port()->poly() << endl;*/
// Copy src buffer to start of mix buffer
mix_buf->copy((AudioBuffer*)src_port()->buffer(0), 0, copy_size-1);