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/AudioBuffer.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/engine/AudioBuffer.cpp') diff --git a/src/engine/AudioBuffer.cpp b/src/engine/AudioBuffer.cpp index 633a004b..b564a3ba 100644 --- a/src/engine/AudioBuffer.cpp +++ b/src/engine/AudioBuffer.cpp @@ -185,16 +185,12 @@ AudioBuffer::copy(Context& context, const Buffer* src) * This function only adds the same range in one buffer to another. */ void -AudioBuffer::mix(Context& context, const Buffer* const src) +AudioBuffer::accumulate(Context& context, const AudioBuffer* const src) { - const AudioBuffer* src_abuf = dynamic_cast(src); - if (!src_abuf) - return; - Sample* const buf = data(); - const Sample* const src_buf = src_abuf->data(); + const Sample* const src_buf = src->data(); - const size_t frames = std::min(nframes(), src_abuf->nframes()); + const size_t frames = std::min(nframes(), src->nframes()); assert(frames != 0); // Mix initial portions @@ -204,8 +200,8 @@ AudioBuffer::mix(Context& context, const Buffer* const src) // Extend/Mix the final sample of src if it is shorter const Sample last = src_buf[i - 1]; - while (i < frames) - buf[i++] = last; + while (i < nframes()) + buf[i++] += last; } -- cgit v1.2.1