I started working on a UI solution for lv2. So far I have a very early prototype of an amplifier plugin. The UI has a knob to set the gain, a button for enable/bypass and two meters to show input and output levels.
Short demo clip:
The following new crates are involved (none of them on crates.io yet):
- lv2-ui – the lv2 interface
- pugl-sys – a rust wrapper for pugl, the interface to the windowing system
- pugl-ui – a stub for a pugl based GUI toolkit. Handles event propagation and widget layout. Not widgets themselves though.
- ampmeter-rs.lv2 – the Simple Amplifiler demo plugin with some extra ports.
- ampmeter-rs-ui.lv2 – the gui for ampmeter-rs-lv2. It has to be in a separate crate as in a rust crate there can only be one library.
Lots of stuff. A lot in the pugl- crates. lv2 specific stuff:
- Atom ports
- Bidirectional communication between UI and DSP part.
So far everything works without modifying existing crates of rust-lv2. One thing that needs to be modified in lv2-core AFAICS is, that the port communication between DSP and UI is bidirectional. Between host and plugin communication via one port is unidirectional an, e.g.
InputPort is for signaling from the host to the plugin.
Between DSP and UI however, port communication via one port is bidirectional. For example if the plugin has an
InputPort<Control> the DSP sets the current value of the control for example when the UI shows up by calling
port_event() provided by the UI. When a port value is to be changed due to UI action the UI tells it to DSP by calling the
write_function() callback, that the DSP provides. For now I do this with a newly introduced
I plan to further develop this in the upcoming weeks and months. Ideally
lv2-ui will eventually part of
rust-lv2. The two
pugl- crates should remain separate as not everyone will be using pugl to create a UI.
Any thoughts, hints, findings? I would be glad to contribute to rust-lv2 and to Rust Audio in general.