[LV2] Custom value display text for control ports

Hanspeter Portner dev at open-music-kontrollers.ch
Mon Aug 20 01:22:49 PDT 2018

Am 20.08.2018 um 08:13 schrieb Dominique Würtz:
> Am Sonntag, den 19.08.2018, 23:09 +0200 schrieb Hanspeter Portner:
>> Theoretically you could define your own unit and e.g. add your
>> missing zeros
>> into the units:render [1]:
>>     unit:render "%1.0f00 %"
>> But I don't know whether any host uses that property for its generic
>> UIs, most
>> (and not even all) just make use of units:symbol [2].
> Hmm, this still doesn't look like it does what I'm looking for: showing
> a different postfix for positive and negative values ("Left" vs
> "Right").

Well no, it does not. But I think you don't want to do that in the first
place. You're opening a can of worms here, imho. The next thing you'll
want after your custom format string will be to be able to set alignment
and then font face (e.g. fixed-width) and [...] so your labels don't
wiggle around, etc.

>> So, if you can come up with some magic format specifier string (for
>> printf) that
>> does  what you want, you could use units:render (and hope that hosts
>> will
>> implement it some day).
> I don't see how this could work.
> I really wish LV2 made it possible - like in VST2/3 SDK - for the
> plugin to provide a C callback for converting a parameter value to
> text. This allows maximum freedom without introducing significant
> complexity. It is also very easy to support by a host compared to the
> current numerous features for customization of text display.

This would not be enough, some hosts offer the user text input, so you'd
need to implement some kind of a parser for reverse-mapping, too.

Your callback system would go against LV2's separation fo DSP and UI,
I'm afraid. But feel free to create a patch as proposal and put it up
here for discussion.

>> LV2 allows you to use *any* range for control ports (there's no
>> restriction to
>> -1..+1). If your range is -100..100 (whatever unit), it's easiest to
>> just use
>> exactly that range, imho.
> Yes, understood, it would make probably have made sense to use
> -100..100 in my example. But this is unrelated to my actual problem.

It is related. If you would refrain using custom dynamic prefixes and
use the proper range, you'd be fine with LV2 as-is.

>>> For the center value 0.0, I figured I can specify a scalePoint to
>>> have
>>> it displayed as "<C>".
>> Some hosts interpret control ports with scale points as simple enums,
>> e.g. will
>> let user choose from specifically defined points only. So this may
>> not have your
>> desired effect.
> Thanks for letting me know. In my quick test with Ardour and Qtractor,
> it works as I want at least. But this only shows another advantage of
> my proposal above: better compatibility, as the host-side
> implementation is fairly simple without leaving room for interpretation
> of how it should be done.
>> P.s. There's always the possibility to draw your own UI, there you
>> can do
>> whatever exotic thing you want ...
> Sure, but I'm in general a fan of default UIs, as it provides the user
> a uniform interface for all plugins and lets me as a plugin dev
> concentrate on the DSP.

Agreed. But for generic UIs to work across hosts, the infrastructure to
implement should be as minimal as possible and need not support every
exotic use case, imho.

> BTW, here is another use case for custom text display that is not
> currently supported:
> a linear gain control (value range e.g. 0.0 .. 2.0) that displays the
> value in dB (in a range -inf .. +6 dB).

Well, I think this has already been answered in the other thread you've
opened recently.

More information about the Devel mailing list