summaryrefslogtreecommitdiff
path: root/libs/ardour/lv2_plugin.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-06-30 01:56:49 +0200
committerRobin Gareus <robin@gareus.org>2017-06-30 01:56:49 +0200
commitdd3f922788f34356eb75750bc9474e189820046c (patch)
tree42f4968ce1b72842b1274136e5babe43b51b5478 /libs/ardour/lv2_plugin.cc
parent285ec18aa50ab7dafe1d727d20b1c0359cd9c590 (diff)
Tweak LV2 float parameter printing
Diffstat (limited to 'libs/ardour/lv2_plugin.cc')
-rw-r--r--libs/ardour/lv2_plugin.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index d0fe39301d..4441a58269 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -1804,7 +1804,16 @@ load_parameter_descriptor_units(LilvWorld* lworld, ParameterDescriptor& desc, co
LilvNode* render = get_value(lworld, unit, _world.units_render);
if (render) {
desc.print_fmt = lilv_node_as_string(render);
- replace_all (desc.print_fmt, "%f", "%.2f");
+ /* override lilv's default "%f" format */
+ if (desc.integer_step) {
+ replace_all (desc.print_fmt, "%f", "%d");
+ } else if (desc.upper - desc.lower >= 1000) {
+ replace_all (desc.print_fmt, "%f", "%.1f");
+ } else if (desc.upper - desc.lower >= 100) {
+ replace_all (desc.print_fmt, "%f", "%.2f");
+ } else {
+ replace_all (desc.print_fmt, "%f", "%.3f");
+ }
lilv_node_free(render);
}
}