const std::string
LV2Plugin::state_dir(unsigned num) const
{
- return Glib::build_filename(plugin_dir(), string_compose("state%1", num));
+ return Glib::build_filename(plugin_dir(), string("state") + PBD::to_string (num));
}
/** Implementation of state:makePath for files created at instantiation time.
assert(_insert_id != PBD::ID("0"));
XMLNode* child;
- char buf[32];
LocaleGuard lg;
for (uint32_t i = 0; i < parameter_count(); ++i) {
if (parameter_is_input(i) && parameter_is_control(i)) {
child = new XMLNode("Port");
- child->add_property("symbol", port_symbol(i));
- snprintf(buf, sizeof(buf), "%+f", _shadow_data[i]);
- child->add_property("value", string(buf));
+ child->set_property("symbol", port_symbol(i));
+ child->set_property("value", _shadow_data[i]);
root->add_child_nocopy(*child);
}
}
if (!_plugin_state_dir.empty()) {
- root->add_property("template-dir", _plugin_state_dir);
+ root->set_property("template-dir", _plugin_state_dir);
}
if (_has_state_interface) {
// Provisionally increment state version and create directory
const std::string new_dir = state_dir(++_state_version);
+ // and keep track of it (for templates & archive)
+ unsigned int saved_state = _state_version;;
g_mkdir_with_parents(new_dir.c_str(), 0744);
LilvState* state = lilv_state_new_from_instance(
lilv_state_free(state);
PBD::remove_directory(new_dir);
--_state_version;
+ saved_state = _state_version;
}
- root->add_property("state-dir", string_compose("state%1", _state_version));
+ root->set_property("state-dir", string("state") + PBD::to_string (saved_state));
}
}
const uint32_t port_index = self->port_index(port_symbol);
if (port_index != (uint32_t)-1) {
self->set_parameter(port_index, *(const float*)value);
+ self->PresetPortSetValue (port_index, *(const float*)value); /* EMIT SIGNAL */
}
}
if (_atom_ev_buffers && _atom_ev_buffers[0]) {
bufsiz = lv2_evbuf_get_capacity(_atom_ev_buffers[0]);
}
- rbs = max((size_t) bufsiz * 8, rbs);
+ int fact = ceilf(_session.frame_rate () / 3000.f);
+ rbs = max((size_t) bufsiz * std::max (8, fact), rbs);
_from_ui = new RingBuffer<uint8_t>(rbs);
}
// Serialize patch:Set message to set property
#ifdef HAVE_LV2_1_10_0
- lv2_atom_forge_object(forge, &frame, 1, _uri_map.urids.patch_Set);
+ lv2_atom_forge_object(forge, &frame, 0, _uri_map.urids.patch_Set);
lv2_atom_forge_key(forge, _uri_map.urids.patch_property);
lv2_atom_forge_urid(forge, key);
lv2_atom_forge_key(forge, _uri_map.urids.patch_value);
#else
- lv2_atom_forge_blank(forge, &frame, 1, _uri_map.urids.patch_Set);
+ lv2_atom_forge_blank(forge, &frame, 0, _uri_map.urids.patch_Set);
lv2_atom_forge_property_head(forge, _uri_map.urids.patch_property, 0);
lv2_atom_forge_urid(forge, key);
lv2_atom_forge_property_head(forge, _uri_map.urids.patch_value, 0);
if (label) {
desc.label = lilv_node_as_string(label);
}
- if (def && lilv_node_is_float(def)) {
- desc.normal = lilv_node_as_float(def);
+ if (def) {
+ if (lilv_node_is_float(def)) {
+ desc.normal = lilv_node_as_float(def);
+ } else if (lilv_node_is_int(def)) {
+ desc.normal = lilv_node_as_int(def);
+ }
}
- if (minimum && lilv_node_is_float(minimum)) {
- desc.lower = lilv_node_as_float(minimum);
+ if (minimum) {
+ if (lilv_node_is_float(minimum)) {
+ desc.lower = lilv_node_as_float(minimum);
+ } else if (lilv_node_is_int(minimum)) {
+ desc.lower = lilv_node_as_int(minimum);
+ }
}
- if (maximum && lilv_node_is_float(maximum)) {
- desc.upper = lilv_node_as_float(maximum);
+ if (maximum) {
+ if (lilv_node_is_float(maximum)) {
+ desc.upper = lilv_node_as_float(maximum);
+ } else if (lilv_node_is_int(maximum)) {
+ desc.upper = lilv_node_as_int(maximum);
+ }
}
load_parameter_descriptor_units(lworld, desc, units);
desc.datatype = datatype;
// Serialize patch:Get message with no subject (implicitly plugin instance)
#ifdef HAVE_LV2_1_10_0
- lv2_atom_forge_object(forge, &frame, 1, _uri_map.urids.patch_Get);
+ lv2_atom_forge_object(forge, &frame, 0, _uri_map.urids.patch_Get);
#else
- lv2_atom_forge_blank(forge, &frame, 1, _uri_map.urids.patch_Get);
+ lv2_atom_forge_blank(forge, &frame, 0, _uri_map.urids.patch_Get);
#endif
// Write message to UI=>Plugin ring
LV2Plugin::set_state(const XMLNode& node, int version)
{
XMLNodeList nodes;
- XMLProperty const * prop;
XMLNodeConstIterator iter;
XMLNode* child;
- const char* sym;
- const char* value;
- uint32_t port_id;
LocaleGuard lg;
if (node.name() != state_node_name()) {
child = *iter;
- if ((prop = child->property("symbol")) != 0) {
- sym = prop->value().c_str();
- } else {
+ std::string sym;
+ if (!child->get_property("symbol", sym)) {
warning << _("LV2: port has no symbol, ignored") << endmsg;
continue;
}
map<string, uint32_t>::iterator i = _port_indices.find(sym);
+ uint32_t port_id;
+
if (i != _port_indices.end()) {
port_id = i->second;
} else {
continue;
}
- if ((prop = child->property("value")) != 0) {
- value = prop->value().c_str();
- } else {
+ float val;
+ if (!child->get_property("value", val)) {
warning << _("LV2: port has no value, ignored") << endmsg;
continue;
}
- set_parameter(port_id, atof(value));
+ set_parameter(port_id, val);
}
- if ((prop = node.property("template-dir")) != 0) {
- set_state_dir (prop->value ());
+ std::string template_dir;
+ if (node.get_property("template-dir", template_dir)) {
+ set_state_dir (template_dir);
}
_state_version = 0;
- if ((prop = node.property("state-dir")) != 0) {
- if (sscanf(prop->value().c_str(), "state%u", &_state_version) != 1) {
+ std::string state_dir;
+ if (node.get_property("state-dir", state_dir) != 0) {
+ if (sscanf(state_dir.c_str(), "state%u", &_state_version) != 1) {
error << string_compose(
"LV2: failed to parse state version from \"%1\"",
- prop->value()) << endmsg;
+ state_dir) << endmsg;
}
std::string state_file = Glib::build_filename(
plugin_dir(),
- Glib::build_filename(prop->value(), "state.ttl"));
+ Glib::build_filename(state_dir, "state.ttl"));
LilvState* state = lilv_state_new_from_file(
_world.world, _uri_map.urid_map(), NULL, state_file.c_str());
lv2_atom_forge_set_buffer(forge, pos_buf, sizeof(pos_buf));
LV2_Atom_Forge_Frame frame;
#ifdef HAVE_LV2_1_10_0
- lv2_atom_forge_object(forge, &frame, 1, urids.time_Position);
+ lv2_atom_forge_object(forge, &frame, 0, urids.time_Position);
lv2_atom_forge_key(forge, urids.time_frame);
lv2_atom_forge_long(forge, position);
lv2_atom_forge_key(forge, urids.time_speed);
MetricSection* metric = (metric_i != tmap.metrics_end())
? *metric_i : NULL;
if (m != m_end && (!metric || metric->frame() > (*m).time())) {
- const Evoral::MIDIEvent<framepos_t> ev(*m, false);
+ const Evoral::Event<framepos_t> ev(*m, false);
if (ev.time() < nframes) {
LV2_Evbuf_Iterator eend = lv2_evbuf_end(_ev_buffers[port_index]);
lv2_evbuf_write(&eend, ev.time(), 0, type, ev.size(), ev.buffer());
{
// TODO use untranslated lilv_plugin_get_class()
// match gtk2_ardour/plugin_selector.cc
- if (category == c) {
- return true;
- }
- return false;
+ return category == c;
}
bool