Fix destroying connected nodes;
Partial fix for port default values. git-svn-id: http://svn.drobilla.net/lad@76 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
parent
b7a45c7510
commit
e689045616
|
@ -111,11 +111,7 @@ LADSPANode::instantiate()
|
|||
}
|
||||
|
||||
assert(_ports->at(j) != NULL);
|
||||
|
||||
/*PortInfo* pi = port->port_info();
|
||||
get_port_vals(j, pi);
|
||||
*/
|
||||
float default_val = 0.; // FIXME
|
||||
sample default_val = default_port_value(j);
|
||||
|
||||
// Set default control val
|
||||
if (port->buffer_size() == 1)
|
||||
|
@ -264,5 +260,78 @@ LADSPANode::get_port_vals(ulong port_index, PortInfo* info)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
sample
|
||||
LADSPANode::default_port_value(ulong port_index)
|
||||
{
|
||||
LADSPA_Data normal = 0.0f;
|
||||
LADSPA_Data upper = 0.0f;
|
||||
LADSPA_Data lower = 0.0f;
|
||||
LADSPA_PortRangeHintDescriptor hint_descriptor = _descriptor->PortRangeHints[port_index].HintDescriptor;
|
||||
|
||||
/* set upper and lower, possibly adjusted to the sample rate */
|
||||
if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
|
||||
upper = _descriptor->PortRangeHints[port_index].UpperBound * _srate;
|
||||
lower = _descriptor->PortRangeHints[port_index].LowerBound * _srate;
|
||||
} else {
|
||||
upper = _descriptor->PortRangeHints[port_index].UpperBound;
|
||||
lower = _descriptor->PortRangeHints[port_index].LowerBound;
|
||||
}
|
||||
|
||||
if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
|
||||
/* FLT_EPSILON is defined as the different between 1.0 and the minimum
|
||||
* float greater than 1.0. So, if lower is < FLT_EPSILON, it will be 1.0
|
||||
* and the logarithmic control will have a base of 1 and thus not change
|
||||
*/
|
||||
if (lower < FLT_EPSILON) lower = FLT_EPSILON;
|
||||
}
|
||||
|
||||
|
||||
if (LADSPA_IS_HINT_HAS_DEFAULT(hint_descriptor)) {
|
||||
|
||||
if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_descriptor)) {
|
||||
normal = lower;
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_LOW(hint_descriptor)) {
|
||||
if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
|
||||
normal = exp(log(lower) * 0.75 + log(upper) * 0.25);
|
||||
} else {
|
||||
normal = lower * 0.75 + upper * 0.25;
|
||||
}
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_descriptor)) {
|
||||
if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
|
||||
normal = exp(log(lower) * 0.5 + log(upper) * 0.5);
|
||||
} else {
|
||||
normal = lower * 0.5 + upper * 0.5;
|
||||
}
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint_descriptor)) {
|
||||
if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
|
||||
normal = exp(log(lower) * 0.25 + log(upper) * 0.75);
|
||||
} else {
|
||||
normal = lower * 0.25 + upper * 0.75;
|
||||
}
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_descriptor)) {
|
||||
normal = upper;
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_0(hint_descriptor)) {
|
||||
normal = 0.0;
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_1(hint_descriptor)) {
|
||||
normal = 1.0;
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_100(hint_descriptor)) {
|
||||
normal = 100.0;
|
||||
} else if (LADSPA_IS_HINT_DEFAULT_440(hint_descriptor)) {
|
||||
normal = 440.0;
|
||||
}
|
||||
} else { // No default hint
|
||||
if (LADSPA_IS_HINT_BOUNDED_BELOW(hint_descriptor)) {
|
||||
normal = lower;
|
||||
} else if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint_descriptor)) {
|
||||
normal = upper;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: set min/max as metadata
|
||||
return normal;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Om
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
LADSPANode& operator=(const LADSPANode&);
|
||||
|
||||
//void get_port_vals(ulong port_index, PortInfo* info);
|
||||
sample default_port_value(ulong port_index);
|
||||
|
||||
const LADSPA_Descriptor* _descriptor;
|
||||
LADSPA_Handle* _instances;
|
||||
|
|
|
@ -59,7 +59,8 @@ LV2Node::instantiate()
|
|||
{
|
||||
size_t num_ports = slv2_plugin_get_num_ports(_lv2_plugin);
|
||||
assert(num_ports > 0);
|
||||
_ports->alloc(num_ports);
|
||||
|
||||
_ports = new Array<Port*>(num_ports);
|
||||
|
||||
_instances = new SLV2Instance*[_poly];
|
||||
|
||||
|
|
|
@ -72,7 +72,8 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch)
|
|||
|
||||
// Control port, send value
|
||||
if (port->type() == DataType::FLOAT && port->buffer_size() == 1)
|
||||
client->control_change(port->path(), dynamic_cast<TypedPort<sample>*>(port)->buffer(0)->value_at(0));
|
||||
client->control_change(port->path(),
|
||||
dynamic_cast<TypedPort<sample>*>(port)->buffer(0)->value_at(0));
|
||||
}
|
||||
|
||||
// Send metadata
|
||||
|
@ -161,6 +162,11 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
|
|||
|
||||
client->new_port(port->path(), type, port->is_output());
|
||||
|
||||
// Send control value
|
||||
if (port->type() == DataType::FLOAT && port->buffer_size() == 1)
|
||||
client->control_change(port->path(),
|
||||
dynamic_cast<const TypedPort<sample>*>(port)->buffer(0)->value_at(0));
|
||||
|
||||
// Send metadata
|
||||
const map<string, string>& data = port->metadata();
|
||||
for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j)
|
||||
|
|
|
@ -96,48 +96,49 @@ DisconnectionEvent::pre_process()
|
|||
|
||||
m_src_port = om->object_store()->find_port(m_src_port_path);
|
||||
m_dst_port = om->object_store()->find_port(m_dst_port_path);
|
||||
|
||||
if (m_src_port == NULL || m_dst_port == NULL) {
|
||||
m_error = PORT_NOT_FOUND;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_src_port->type() != m_dst_port->type() || m_src_port->buffer_size() != m_dst_port->buffer_size()) {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (port1->is_output() && port2->is_input()) {
|
||||
m_src_port = port1;
|
||||
m_dst_port = port2;
|
||||
} else if (port2->is_output() && port1->is_input()) {
|
||||
m_src_port = port2;
|
||||
m_dst_port = port1;
|
||||
} else {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}*/
|
||||
|
||||
// Create the typed event to actually do the work
|
||||
const DataType type = m_src_port->type();
|
||||
if (type == DataType::FLOAT) {
|
||||
m_typed_event = new TypedDisconnectionEvent<sample>(m_responder,
|
||||
dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
|
||||
} else if (type == DataType::MIDI) {
|
||||
m_typed_event = new TypedDisconnectionEvent<MidiMessage>(m_responder,
|
||||
dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
|
||||
} else {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_src_port == NULL || m_dst_port == NULL) {
|
||||
m_error = PORT_NOT_FOUND;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_src_port->type() != m_dst_port->type() || m_src_port->buffer_size() != m_dst_port->buffer_size()) {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (port1->is_output() && port2->is_input()) {
|
||||
m_src_port = port1;
|
||||
m_dst_port = port2;
|
||||
} else if (port2->is_output() && port1->is_input()) {
|
||||
m_src_port = port2;
|
||||
m_dst_port = port1;
|
||||
} else {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}*/
|
||||
|
||||
// Create the typed event to actually do the work
|
||||
const DataType type = m_src_port->type();
|
||||
if (type == DataType::FLOAT) {
|
||||
m_typed_event = new TypedDisconnectionEvent<sample>(m_responder,
|
||||
dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
|
||||
} else if (type == DataType::MIDI) {
|
||||
m_typed_event = new TypedDisconnectionEvent<MidiMessage>(m_responder,
|
||||
dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
|
||||
} else {
|
||||
m_error = TYPE_MISMATCH;
|
||||
QueuedEvent::pre_process();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(m_typed_event);
|
||||
m_typed_event->pre_process();
|
||||
|
||||
|
||||
QueuedEvent::pre_process();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ NodeControlWindow::NodeControlWindow(NodeController* node, size_t poly)
|
|||
resize();
|
||||
|
||||
// FIXME: not working
|
||||
set_icon_from_file(string(PKGDATADIR) + "/om-icon.png");
|
||||
//set_icon_from_file(string(PKGDATADIR) + "/om-icon.png");
|
||||
|
||||
m_callback_enabled = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue