From bfca1f3a2739c1c0148b0641d3bdb8f4ea16b431 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 4 Jan 2010 20:59:01 +0000 Subject: Remove redundant LV2EventBuffer class and merge with EventBuffer. Refactor mixing from an in-place Buffer method (which doesn't work with EventBuffer) to a single function that takes an out of place destination and an array of sources. Fix audio buffer mixing for control<->audio. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2333 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ConnectionImpl.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/engine/ConnectionImpl.cpp') diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp index db71df70..b64875c2 100644 --- a/src/engine/ConnectionImpl.cpp +++ b/src/engine/ConnectionImpl.cpp @@ -17,7 +17,6 @@ #include #include "raul/Maid.hpp" -#include "util.hpp" #include "AudioBuffer.hpp" #include "BufferFactory.hpp" #include "ConnectionImpl.hpp" @@ -27,6 +26,8 @@ #include "MessageContext.hpp" #include "PortImpl.hpp" #include "ProcessContext.hpp" +#include "mix.hpp" +#include "util.hpp" namespace Ingen { @@ -52,6 +53,7 @@ ConnectionImpl::ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl if (must_mix() || must_queue()) _local_buffer = bufs.get(dst_port->type(), dst_port->buffer_size()); + if (must_queue()) _queue = new Raul::RingBuffer(src_port->buffer_size() * 2); @@ -118,18 +120,15 @@ ConnectionImpl::process(Context& context) _queue->full_peek(sizeof(LV2_Object), &obj); _queue->full_read(sizeof(LV2_Object) + obj.size, local_buf->object()); } - return; - } - - if (!must_mix()) - return; - // Copy the first voice - _local_buffer->copy(context, src_port()->buffer(0).get()); + } else if (must_mix()) { + const uint32_t num_srcs = src_port()->poly(); + Buffer* srcs[num_srcs]; + for (uint32_t v = 0; v < num_srcs; ++v) + srcs[v] = src_port()->buffer(v).get(); - // Mix in the rest - for (uint32_t v = 0; v < src_port()->poly(); ++v) - _local_buffer->mix(context, src_port()->buffer(v).get()); + mix(context, _local_buffer.get(), srcs, num_srcs); + } } -- cgit v1.2.1