From 4f3671892be72cdd39b1a9e76f7cd4d9962f40c0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Jun 2007 04:45:00 +0000 Subject: Just use automake instead of automake-1.9, etc. Set default value for LV2 plugin controls. Set GUI control range to always include value. git-svn-id: http://svn.drobilla.net/lad/ingen@538 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/LV2Node.cpp | 35 ++++++++++++++--------------------- src/libs/engine/ObjectSender.cpp | 5 ++--- src/libs/gui/ControlGroups.cpp | 6 ++++++ 3 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index f45af62c..4aef8d69 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -100,30 +100,21 @@ LV2Node::instantiate() else port_buffer_size = 1; - if (port_class == SLV2_CONTROL_INPUT || port_class == SLV2_AUDIO_INPUT) { + if (port_class == SLV2_CONTROL_INPUT || port_class == SLV2_AUDIO_INPUT) port = new InputPort(this, port_name, j, _poly, DataType::FLOAT, port_buffer_size); - _ports->at(j) = port; - } else if (port_class == SLV2_CONTROL_OUTPUT || port_class == SLV2_AUDIO_OUTPUT) { + else if (port_class == SLV2_CONTROL_OUTPUT || port_class == SLV2_AUDIO_OUTPUT) port = new OutputPort(this, port_name, j, _poly, DataType::FLOAT, port_buffer_size); - _ports->at(j) = port; - } else if (port_class == SLV2_MIDI_INPUT) { + else if (port_class == SLV2_MIDI_INPUT) port = new InputPort(this, port_name, j, _poly, DataType::MIDI, port_buffer_size); - _ports->at(j) = port; - } else if (port_class == SLV2_MIDI_OUTPUT) { + else if (port_class == SLV2_MIDI_OUTPUT) port = new OutputPort(this, port_name, j, _poly, DataType::MIDI, port_buffer_size); - _ports->at(j) = port; - } - - assert(_ports->at(j) != NULL); - //PortInfo* pi = port->port_info(); - //get_port_vals(j, pi); + assert(port); + + if (port_class == SLV2_CONTROL_INPUT) + ((AudioBuffer*)port->buffer(0))->set(slv2_port_get_default_value(_lv2_plugin, id), 0); - // Set default control val - /*if (pi->is_control()) - ((TypedPort*)port)->set_value(pi->default_val(), 0); - else - ((TypedPort*)port)->set_value(0.0f, 0);*/ + _ports->at(j) = port; } return true; } @@ -148,9 +139,11 @@ LV2Node::activate() Port* const port = _ports->at(j); set_port_buffer(i, j, port->buffer(i)); if (port->type() == DataType::FLOAT && port->buffer_size() == 1) { - cerr << "FIXME: LV2 default value\n"; - ((AudioBuffer*)port->buffer(i))->set(0.0f, 0); // FIXME - } else if (port->type() == DataType::FLOAT && port->buffer_size() > 1) { + ((AudioBuffer*)port->buffer(i))->set( + slv2_port_get_default_value(_lv2_plugin, + slv2_plugin_get_port_by_index(_lv2_plugin, j)), + 0); + } else if (port->type() == DataType::FLOAT) { ((AudioBuffer*)port->buffer(i))->set(0.0f, 0); } } diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp index 50e47c48..db573afc 100644 --- a/src/libs/engine/ObjectSender.cpp +++ b/src/libs/engine/ObjectSender.cpp @@ -146,10 +146,9 @@ ObjectSender::send_port(ClientInterface* client, const Port* port) // Send control value if (port->type() == DataType::FLOAT && port->buffer_size() == 1) { - Sample default_value = dynamic_cast( - port->buffer(0))->value_at(0); + const Sample value = dynamic_cast(port->buffer(0))->value_at(0); //cerr << port->path() << " sending default value " << default_value << endl; - client->control_change(port->path(), default_value); + client->control_change(port->path(), value); } // Send metadata diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp index 7af9011b..4de4e0c6 100644 --- a/src/libs/gui/ControlGroups.cpp +++ b/src/libs/gui/ControlGroups.cpp @@ -129,6 +129,12 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr pm) pm->path().name().c_str())); } + if (min > pm->value()) + min = pm->value(); + + if (max < pm->value()) + max = pm->value(); + if (max <= min) max = min + 1.0f; -- cgit v1.2.1