[LV2] LV2 best practices

Gabriel M. Beddingfield gabrbedd at gmail.com
Wed Aug 1 18:07:14 PDT 2012


On 08/01/2012 04:22 PM, Robin Gareus wrote:
>
> 1) "advanced mode" - imagine plugin that has a couple of settings that
[snip]
>
> I thinking about one of the following:
> a) two plugins (one with all controls, one with only common controls)

This sounds like the cleanest solution.

In fact, you can /declare/ two plugins in your manifest, but when you 
instantiate it... you instantiate the same object.

> b) include a custom GUI and hide advanced settings.

You can always do this.  I got the impression that you wanted to present 
a clean auto-generated interface.  Obviously with your own GUI you can 
do whatever you wish.

> c) use http://lv2plug.in/ns/ext/port-props/#displayPriority

I doubt any hosts actually utilise this property.

> Any other alternatives? What is the recommended way?

I think (a) sounds best.

> 2) "static configuration". Assume a plugin has static configuration that
> can only be set on initialization and can not be changed later (e.g. the
> temperament of a synth). I can not see a good way how to deal with that.
>
>    * How can one set up an initial persistent state?
>
> Shall that be avoided? IOW Must a plugin only have parameters that can
> be modified at runtime and must not include persistent configuration?

It depends on how many different static configs you need.  For example, 
if you want to support 16 different static configs... you can provide 16 
different URL's to instantiate.

Otherwise...

> Some thoughts:
> It might be possible to re-init the whole plugin using a port marked as
>    http://lv2plug.in/ns/ext/port-props/#expensive
> but if re-initialization requires memory allocation it must not be done
> from a RT-callback. A dedicated (non-rt) helper thread could be spawned
> to take care of re-init and the plugin remain silent until re-init is
> complete. Dirty hack or what? :)

Worker thread FTW.  With the Composite sampler, I use a worker thread to 
load samples and do misc. non-RT work.  Works pretty good -- you can 
load a new drum kit during playback without missing a beat.

While the object is in an invalid state, your run() process will need to 
still fulfil its run() responsibilities in a safe manner.

> Abusing the state-interface may be another possibility to get the job
> done.. -- can a plugin ask the host to re-initialize a plugin instance?

Not that I'm aware of.

-gabriel




More information about the Devel mailing list