From 8e747504412c62f27c599f3f5e001ff3e2e36a82 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 20 Sep 2007 02:43:59 +0000 Subject: Fix voice-specific polyphony controls. Restore patch polyphony correctly on client reattach. Fix crash on multiple polyphony changes w/ LV2 plugins. git-svn-id: http://svn.drobilla.net/lad/ingen@737 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/LV2Node.cpp | 24 ++++++++++++++---------- src/libs/engine/MidiNoteNode.cpp | 2 ++ src/libs/engine/Patch.cpp | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/libs/engine') diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index c8c13f38..146bc4bf 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -43,9 +43,11 @@ LV2Node::LV2Node(const Plugin* plugin, Patch* parent, SampleRate srate, size_t buffer_size) -: NodeBase(plugin, name, poly, parent, srate, buffer_size), - _lv2_plugin(plugin->slv2_plugin()), - _instances(NULL) + : NodeBase(plugin, name, poly, parent, srate, buffer_size) + , _lv2_plugin(plugin->slv2_plugin()) + , _instances(NULL) + , _prepared_instances(NULL) + , _prepared_poly(poly) { assert(_lv2_plugin); } @@ -83,13 +85,15 @@ LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly) NodeBase::apply_poly(maid, poly); - maid.push(_instances); - _instances = _prepared_instances; - - for (uint32_t port=0; port < num_ports(); ++port) - for (uint32_t voice = _polyphony; voice < _prepared_poly; ++voice) - slv2_instance_connect_port((*_instances)[voice], port, - _ports->at(port)->buffer(voice)->raw_data()); + if (_prepared_instances) { + maid.push(_instances); + _instances = _prepared_instances; + + for (uint32_t port=0; port < num_ports(); ++port) + for (uint32_t voice = _polyphony; voice < _prepared_poly; ++voice) + slv2_instance_connect_port((*_instances)[voice], port, + _ports->at(port)->buffer(voice)->raw_data()); + } _polyphony = poly; _prepared_instances = NULL; diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp index 91c9d542..03dc01b3 100644 --- a/src/libs/engine/MidiNoteNode.cpp +++ b/src/libs/engine/MidiNoteNode.cpp @@ -38,6 +38,8 @@ namespace Ingen { MidiNoteNode::MidiNoteNode(const string& path, uint32_t poly, Patch* parent, SampleRate srate, size_t buffer_size) : InternalNode(new Plugin(Plugin::Internal, "ingen:note_node"), path, poly, parent, srate, buffer_size), _voices(new Raul::Array(poly)), + _prepared_voices(NULL), + _prepared_poly(poly), _sustain(false) { _ports = new Raul::Array(5); diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index 77b043eb..3d8e7756 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -129,6 +129,8 @@ Patch::apply_internal_poly(Raul::Maid& maid, uint32_t poly) for (Raul::List::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->apply_poly(maid, poly); + + _internal_poly = poly; return true; } -- cgit v1.2.1