From ca809494991686b253679ecf0c0b8b4bf48aa22d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 23 Feb 2010 05:14:20 +0000 Subject: Working dynamic polyphony in the root patch. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2483 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ConnectionImpl.cpp | 1 - src/engine/NodeBase.cpp | 1 - src/engine/PatchImpl.cpp | 4 ++++ src/engine/PortImpl.cpp | 16 ++++++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp index 4a154809..e555509d 100644 --- a/src/engine/ConnectionImpl.cpp +++ b/src/engine/ConnectionImpl.cpp @@ -146,7 +146,6 @@ ConnectionImpl::process(Context& context) for (uint32_t v = 0; v < num_srcs; ++v) srcs[v] = src_port()->buffer(v).get(); - _local_buffer->clear(); mix(context, _local_buffer.get(), srcs, num_srcs); } } diff --git a/src/engine/NodeBase.cpp b/src/engine/NodeBase.cpp index 3881ebe0..ca9103da 100644 --- a/src/engine/NodeBase.cpp +++ b/src/engine/NodeBase.cpp @@ -270,7 +270,6 @@ NodeBase::set_port_buffer(uint32_t voice, uint32_t port_num, BufferFactory::Ref { /*debug << path() << " set port " << port_num << " voice " << voice << " buffer " << buf << endl;*/ - assert(voice < _polyphony); } diff --git a/src/engine/PatchImpl.cpp b/src/engine/PatchImpl.cpp index 165f708f..77408275 100644 --- a/src/engine/PatchImpl.cpp +++ b/src/engine/PatchImpl.cpp @@ -140,6 +140,10 @@ PatchImpl::apply_internal_poly(BufferFactory& bufs, Raul::Maid& maid, uint32_t p } } + const bool polyphonic = parent_patch() && (_internal_poly == parent_patch()->internal_poly()); + for (List::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) + (*i)->setup_buffers(bufs, polyphonic ? poly : 1); + _internal_poly = poly; return true; 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(_buffers->at(v))->set_value( + _value.get_float(), 0, 0); + assert(_buffers->size() >= poly); assert(this->poly() == poly); assert(!_prepared_buffers); -- cgit v1.2.1