summaryrefslogtreecommitdiffstats
path: root/src/engine/PortImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-23 05:14:20 +0000
committerDavid Robillard <d@drobilla.net>2010-02-23 05:14:20 +0000
commitca809494991686b253679ecf0c0b8b4bf48aa22d (patch)
treec51e4e764c12e9fe899f20830b08bebaa82f784e /src/engine/PortImpl.cpp
parent3893203399c1b67fb70729558e51f014b863b307 (diff)
downloadingen-ca809494991686b253679ecf0c0b8b4bf48aa22d.tar.gz
ingen-ca809494991686b253679ecf0c0b8b4bf48aa22d.tar.bz2
ingen-ca809494991686b253679ecf0c0b8b4bf48aa22d.zip
Working dynamic polyphony in the root patch.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2483 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/PortImpl.cpp')
-rw-r--r--src/engine/PortImpl.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp
index 7bb81bbe..dac3fef0 100644
--- a/src/engine/PortImpl.cpp
+++ b/src/engine/PortImpl.cpp
@@ -108,7 +108,10 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
if (_type != PortType::CONTROL && _type != PortType::AUDIO)
return false;
- if (_prepared_buffers && _prepared_buffers->size() < poly) {
+ if (_poly == poly)
+ return true;
+
+ if (_prepared_buffers && _prepared_buffers->size() != poly) {
delete _prepared_buffers;
_prepared_buffers = NULL;
}
@@ -130,7 +133,10 @@ PortImpl::apply_poly(Maid& maid, uint32_t poly)
if (_type != PortType::CONTROL && _type != PortType::AUDIO)
return false;
- assert(poly <= _prepared_buffers->size());
+ if (!_prepared_buffers)
+ return true;
+
+ assert(poly == _prepared_buffers->size());
_poly = poly;
@@ -139,6 +145,12 @@ PortImpl::apply_poly(Maid& maid, uint32_t poly)
assert(_buffers == _prepared_buffers);
_prepared_buffers = NULL;
+ if (_type == PortType::CONTROL)
+ for (uint32_t v = 0; v < _poly; ++v)
+ if (_buffers->at(v))
+ boost::static_pointer_cast<AudioBuffer>(_buffers->at(v))->set_value(
+ _value.get_float(), 0, 0);
+
assert(_buffers->size() >= poly);
assert(this->poly() == poly);
assert(!_prepared_buffers);