View Issue Details

IDProjectCategoryView StatusLast Update
0003717ardourbugspublic2014-01-19 05:06
Reporternedko Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version2.8.11 
Target Version2.8.12 
Summary0003717: [PATCH] LV2 state is not properly restored
Descriptionlv2 core spec states "The index can be used as an identifier at run-time, but persistent references to ports (e.g. in a saved preset) MUST use the symbol."

a2 is using port indices when state is loaded. for a3 it looks that this bug is fixed as part of the svn r5055 commit.

The issue can be reproduced by saving state of calf reverb from calf-0.0.18.6 and then restoring it with calf git (3889df5d1448faf5078b0a2bdd4c220823b82bf9 here). One of the parameters that is affected is "dry" with index 12 in newer versions. in 0.0.18.6, 12 is "treble_cut". In my case I got 6622.622559 set as dry gain. This resulted in about +50 dB amplification.
Additional Informationcalf-0.0.18.6 state:

        <lv2>
          <port number="4" symbol="decay_time" value="+0.554272"/>
          <port number="5" symbol="hf_damp" value="+5874.487793"/>
          <port number="6" symbol="room_size" value="+2.000000"/>
          <port number="7" symbol="diffusion" value="+0.580000"/>
          <port number="8" symbol="amount" value="+2.000000"/>
          <port number="9" symbol="dry" value="+0.000000"/>
          <port number="10" symbol="predelay" value="+0.000000"/>
          <port number="11" symbol="bass_cut" value="+150.356171"/>
          <port number="12" symbol="treble_cut" value="+6622.622559"/>
        </lv2>


calf-git params:

Ports:
   0 in_l in_l Audio, Input
   1 in_r in_r Audio, Input
   2 out_l out_l Audio, Output
   3 out_r out_r Audio, Output
   4 clip 0dB Control, Output, minimum=0.0, maximum=1.0, properties=connectionOptional,hasStrictBounds
   5 meter_wet Wet amount Control, Output, minimum=0.0, maximum=1.0, properties=connectionOptional,hasStrictBounds
   6 meter_out Output Control, Output, minimum=0.0, maximum=1.0, properties=connectionOptional,hasStrictBounds
   7 decay_time Decay time Control, Input, defaultValue=1.5, minimum=0.40000000000000002, maximum=15.0, properties=hasStrictBounds,logarithmic
   8 hf_damp High Frq Damp Control, Input, defaultValue=5000.0, minimum=2000.0, maximum=20000.0, properties=hasStrictBounds,logarithmic
   9 room_size Room size Control, Input, defaultValue=2.0, minimum=0.0, maximum=5.0, properties=hasStrictBounds,integer
       Scale point 0: Small
       Scale point 1: Medium
       Scale point 2: Large
       Scale point 3: Tunnel-like
       Scale point 4: Large/smooth
       Scale point 5: Experimental
  10 diffusion Diffusion Control, Input, defaultValue=0.5, minimum=0.0, maximum=1.0, properties=hasStrictBounds
  11 amount Wet Amount Control, Input, defaultValue=0.25, minimum=0.0, maximum=2.0, properties=outputGain
  12 dry Dry Amount Control, Input, defaultValue=1.0, minimum=0.0, maximum=2.0, properties=outputGain
  13 predelay Pre Delay Control, Input, defaultValue=0.0, minimum=0.0, maximum=50.0, properties=hasStrictBounds
  14 bass_cut Bass Cut Control, Input, defaultValue=300.0, minimum=20.0, maximum=20000.0, properties=hasStrictBounds,logarithmic
  15 treble_cut Treble Cut Control, Input, defaultValue=5000.0, minimum=20.0, maximum=20000.0, properties=hasStrictBounds,logarithmic
TagsNo tags attached.

Activities

2011-01-16 19:12

 

ardour2-lv2-load-fix.patch (3,243 bytes)   
From fc258ef102fa101697814478c83a3a2e83ba614a Mon Sep 17 00:00:00 2001
From: Nedko Arnaudov <nedko@arnaudov.name>
Date: Sun, 16 Jan 2011 21:02:57 +0200
Subject: [PATCH] Use port symbols when restoring lv2 plugin state. Bug #3717

Backport from 3.0 branch. The fix itself was commited as part of r5055.
r5055 needs _port_indices member of the class. _port_indices was
introduced in r4547.
---
 libs/ardour/ardour/lv2_plugin.h |    1 +
 libs/ardour/lv2_plugin.cc       |   29 +++++++++++++++++++----------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h
index 8e1536b..7026836 100644
--- a/libs/ardour/ardour/lv2_plugin.h
+++ b/libs/ardour/ardour/lv2_plugin.h
@@ -129,6 +129,7 @@ class LV2Plugin : public ARDOUR::Plugin
 	float*                   _latency_control_port;
 	bool                     _was_activated;
 	vector<bool>             _port_is_input;
+	map<string,uint32_t>     _port_indices;
 
 	typedef struct { const void* (*extension_data)(const char* uri); } LV2_DataAccess;
 	LV2_DataAccess _data_access_extension_data;
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index d46e6e9..b875ef8 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -119,8 +119,10 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, nframes_t rate)
 	uint32_t latency_port = (latent ? slv2_plugin_get_latency_port_index(plugin) : 0);
 
 	for (uint32_t i = 0; i < num_ports; ++i) {
+		SLV2Port port = slv2_plugin_get_port_by_index(plugin, i);
+		SLV2Value sym = slv2_port_get_symbol(_plugin, port);
+		_port_indices.insert(std::make_pair(slv2_value_as_string(sym), i));
 		if (parameter_is_control(i)) {
-			SLV2Port port = slv2_plugin_get_port_by_index(plugin, i);
 			SLV2Value def;
 			slv2_port_get_range(plugin, port, &def, NULL, NULL);
 			_defaults[i] = def ? slv2_value_as_float(def) : 0.0f;
@@ -315,8 +317,8 @@ LV2Plugin::set_state(const XMLNode& node)
 	XMLProperty *prop;
 	XMLNodeConstIterator iter;
 	XMLNode *child;
-	const char *port;
-	const char *data;
+	const char *sym;
+	const char *value;
 	uint32_t port_id;
 	LocaleGuard lg (X_("POSIX"));
 
@@ -331,22 +333,29 @@ LV2Plugin::set_state(const XMLNode& node)
 
 		child = *iter;
 
-		if ((prop = child->property("number")) != 0) {
-			port = prop->value().c_str();
+		if ((prop = child->property("symbol")) != 0) {
+			sym = prop->value().c_str();
 		} else {
-			warning << _("LV2: no lv2 port number") << endmsg;
+			warning << _("LV2: port has no symbol, ignored") << endmsg;
+			continue;
+		}
+
+		map<string,uint32_t>::iterator i = _port_indices.find(sym);
+		if (i != _port_indices.end()) {
+			port_id = i->second;
+		} else {
+			warning << _("LV2: port has unknown index, ignored") << endmsg;
 			continue;
 		}
 
 		if ((prop = child->property("value")) != 0) {
-			data = prop->value().c_str();
+			value = prop->value().c_str();
 		} else {
-			warning << _("LV2: no lv2 port data") << endmsg;
+			warning << _("LV2: port has no value, ignored") << endmsg;
 			continue;
 		}
 
-		sscanf (port, "%" PRIu32, &port_id);
-		set_parameter (port_id, atof(data));
+		set_parameter (port_id, atof(value));
 	}
 	
 	latency_compute_run ();
-- 
1.6.5.GIT

ardour2-lv2-load-fix.patch (3,243 bytes)   

nedko

2011-01-16 19:12

reporter   ~0009940

Patch is also available here: http://nedko.arnaudov.name/soft/ardour2-lv2-load-fix.patch
And through git http://repo.or.cz/w/ardour2.git/commitdiff/fc258ef102fa101697814478c83a3a2e83ba614a

nedko

2013-12-30 23:12

reporter   ~0015528

Updated commit for recent 2.0-ongoing git branch (slv2->lilv): https://github.com/nedko/ardour/commit/8509d8ff5c1cbcc45785fc296f22ccc8afcd7b70

paul

2014-01-19 04:59

administrator   ~0015591

does this bug exist in a3?

nedko

2014-01-19 05:02

reporter   ~0015592

In the summary: for a3 it looks that this bug is fixed as part of the svn r5055 commit.

Issue History

Date Modified Username Field Change
2011-01-16 18:22 nedko New Issue
2011-01-16 19:12 nedko File Added: ardour2-lv2-load-fix.patch
2011-01-16 19:12 nedko Note Added: 0009940
2011-01-20 12:48 cth103 cost => 0.00
2011-01-20 12:48 cth103 Target Version => 2.8.12
2011-01-20 12:48 cth103 Summary lv2 state is not properly restored => [PATCH] LV2 state is not properly restored
2013-12-30 23:12 nedko Note Added: 0015528
2014-01-19 04:59 paul Note Added: 0015591
2014-01-19 04:59 paul Status new => feedback
2014-01-19 05:02 nedko Note Added: 0015592
2014-01-19 05:06 nedko Status feedback => new