#include <cmath>
#include <cstring>
+#include <glibmm.h>
+
#include "pbd/compose.h"
#include "pbd/error.h"
#include "pbd/pathscanner.h"
#include "i18n.h"
#include <locale.h>
+#include "lv2ext/lv2_persist.h"
+
using namespace std;
using namespace ARDOUR;
using namespace PBD;
_latency_control_port = 0;
_was_activated = false;
+ SLV2Value persist_uri = slv2_value_new_uri(_world.world, "http://lv2plug.in/ns/ext/persist");
+ _supports_persist = slv2_plugin_has_feature(plugin, persist_uri);
+ slv2_value_free(persist_uri);
+
+ _instance_access_feature.URI = "http://lv2plug.in/ns/ext/instance-access";
+ _data_access_feature.URI = "http://lv2plug.in/ns/ext/data-access";
+ _persist_feature.URI = "http://lv2plug.in/ns/ext/persist";
+ _persist_feature.data = NULL;
+
+ _features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 5);
+ _features[0] = &_instance_access_feature;
+ _features[1] = &_data_access_feature;
+ _features[2] = &_persist_feature;
+ _features[3] = _uri_map.feature();
+ _features[4] = NULL;
+
_instance = slv2_plugin_instantiate(plugin, rate, _features);
_name = slv2_plugin_get_name(plugin);
assert(_name);
throw failed_constructor();
}
+ _instance_access_feature.data = (void*)_instance->lv2_handle;
+ _data_access_extension_data.extension_data = _instance->lv2_descriptor->extension_data;
+ _data_access_feature.data = &_data_access_extension_data;
+
if (slv2_plugin_has_feature(plugin, world.in_place_broken)) {
error << string_compose(
_("LV2: \"%1\" cannot be used, since it cannot do inplace processing"),
throw failed_constructor();
}
- _instance_access_feature.URI = "http://lv2plug.in/ns/ext/instance-access";
- _instance_access_feature.data = (void*)_instance->lv2_handle;
-
- _data_access_extension_data.extension_data = _instance->lv2_descriptor->extension_data;
- _data_access_feature.URI = "http://lv2plug.in/ns/ext/data-access";
- _data_access_feature.data = &_data_access_extension_data;
-
- _features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * 4);
- _features[0] = &_instance_access_feature;
- _features[1] = &_data_access_feature;
- _features[2] = _uri_map.feature();
- _features[3] = NULL;
-
_sample_rate = rate;
const uint32_t num_ports = slv2_plugin_get_num_ports(plugin);
{
if (which < slv2_plugin_get_num_ports(_plugin)) {
_shadow_data[which] = val;
-#if 0
ParameterChanged (which, val); /* EMIT SIGNAL */
+#if 0
if (which < parameter_count() && controls[which]) {
controls[which]->Changed ();
}
-#endif
+#endif
} else {
warning << string_compose (_("Illegal parameter number used with plugin \"%1\"."
- "This is a bug in either Ardour or the LV2 plugin (%2)"),
- name(), unique_id()) << endmsg;
+ "This is a bug in either %2 or the LV2 plugin (%3)"),
+ name(), PROGRAM_NAME, unique_id()) << endmsg;
}
}
return 0;
}
+struct LV2Value { void* value; uint32_t type; };
+typedef std::map< std::string, LV2Value > LV2State;
+
+static void
+lv2_persist_store_callback(void* callback_data,
+ const char* key,
+ const void* value,
+ size_t size,
+ uint32_t type)
+{
+ cout << "LV2 PERSIST STORE " << key << " = " << value << " :: " << type << endl;
+}
+
XMLNode&
LV2Plugin::get_state()
{
}
}
+ if (_supports_persist) {
+ // Create state directory for this plugin instance
+ const std::string state_path = Glib::build_filename(_session.plugins_dir(), _id.to_s());
+ cout << "LV2 plugin state path " << state_path << endl;
+
+ // Get LV2 Persist extension data from plugin instance
+ LV2_Persist* persist = (LV2_Persist*)slv2_instance_get_extension_data(
+ _instance, "http://lv2plug.in/ns/ext/persist");
+ if (!persist) {
+ warning << string_compose(
+ _("Plugin \"%1\% failed to return LV2 persist data"),
+ unique_id());
+ return *root; // FIXME: Possibly inconsistent state
+ }
+
+ LV2State state;
+ persist->save(_instance, lv2_persist_store_callback, &state);
+ }
+
return *root;
}
}
int
-LV2Plugin::set_state(const XMLNode& node, int /*version*/)
+LV2Plugin::set_state(const XMLNode& node, int version)
{
XMLNodeList nodes;
XMLProperty *prop;
return -1;
}
- nodes = node.children ("Port");
-
+ if (version < 3000){
+ nodes = node.children ("port");
+ } else {
+ nodes = node.children ("Port");
+ }
+
for (iter = nodes.begin(); iter != nodes.end(); ++iter){
child = *iter;
}
map<string,uint32_t>::iterator i = _port_indices.find(sym);
+
if (i != _port_indices.end()) {
port_id = i->second;
} else {
{
if (which.type() == PluginAutomation && which.id() < parameter_count()) {
SLV2Value name = slv2_port_get_name(_plugin,
- slv2_plugin_get_port_by_index(_plugin, which));
+ slv2_plugin_get_port_by_index(_plugin, which.id()));
string ret(slv2_value_as_string(name));
slv2_value_free(name);
return ret;
: _lv2_world(lv2_world)
, _slv2_plugin(slv2_plugin)
{
+ type = ARDOUR::LV2;
}
LV2PluginInfo::~LV2PluginInfo()