summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-21 18:24:59 +0000
committerDavid Robillard <d@drobilla.net>2008-12-21 18:24:59 +0000
commit7c203c5ddcddd451b0656ee6c9cd0206b17782f0 (patch)
treee33fe36a38c69d8131ebce13a851624ecfd7c188 /src/engine
parent1c97ea40ba7b2affbb14fe2b6a4ab6bffb2ae67d (diff)
downloadingen-7c203c5ddcddd451b0656ee6c9cd0206b17782f0.tar.gz
ingen-7c203c5ddcddd451b0656ee6c9cd0206b17782f0.tar.bz2
ingen-7c203c5ddcddd451b0656ee6c9cd0206b17782f0.zip
Fix mixdown of several connections with varying sizes (i.e. control and audio) (fix ticket #308).
Fix off-by-one error when copying a control buffer to an audio buffer. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1889 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/AudioBuffer.cpp13
-rw-r--r--src/engine/InputPort.cpp2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/engine/AudioBuffer.cpp b/src/engine/AudioBuffer.cpp
index 2fc1b234..4ee42274 100644
--- a/src/engine/AudioBuffer.cpp
+++ b/src/engine/AudioBuffer.cpp
@@ -204,13 +204,13 @@ AudioBuffer::copy(const Buffer* src, size_t start_sample, size_t end_sample)
const Sample* const src_buf = ((AudioBuffer*)src)->data();
assert(src_buf);
- const size_t to_copy = std::min(end_sample, _size);
- for (size_t i=start_sample; i <= to_copy; ++i)
+ const size_t to_copy = std::min(end_sample, _size - 1);
+ for (size_t i = start_sample; i <= to_copy; ++i)
buf[i] = src_buf[i];
}
-/** Accumulate a block of @a src into @a dst.
+/** Accumulate a block of @a src into buffer.
*
* @a start_sample and @a end_sample define the inclusive range to be accumulated.
* This function only adds the same range in one buffer to another.
@@ -219,16 +219,17 @@ void
AudioBuffer::accumulate(const AudioBuffer* const src, size_t start_sample, size_t end_sample)
{
assert(end_sample >= start_sample);
- assert(end_sample < _size);
assert(src);
-
+ assert(src->type() == DataType::CONTROL || DataType::AUDIO);
+
Sample* const buf = data();
assert(buf);
const Sample* const src_buf = src->data();
assert(src_buf);
- for (size_t i=start_sample; i <= end_sample; ++i)
+ const size_t to_copy = std::min(end_sample, _size - 1);
+ for (size_t i = start_sample; i <= to_copy; ++i)
buf[i] += src_buf[i];
}
diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp
index 9282ca22..e2247a45 100644
--- a/src/engine/InputPort.cpp
+++ b/src/engine/InputPort.cpp
@@ -247,9 +247,7 @@ InputPort::pre_process(ProcessContext& context)
// Accumulate the rest
if (_connections.size() > 1) {
-
Connections::iterator c = _connections.begin();
-
for (++c; c != _connections.end(); ++c)
((AudioBuffer*)buffer(voice))->accumulate(
((AudioBuffer*)(*c)->buffer(voice)), 0, _buffer_size-1);