-
Notifications
You must be signed in to change notification settings - Fork 4
Tutorial: Global Parameters
The best place to add parameters to your project are as parameters on the custom patterns and effects that you write. However, in some cases it is desirable to have a separate container for project state that is not particular to a given animation component. In this case, you can register your own global component with the LX engine and add custom UI to control it. By registering your component with the engine, its parameter values will be saved and loaded with the project file, and it may be mapped for OSC/MIDI control just like anything else in the LX hierarchy.
Define a class which extends from LXComponent
and register its parameters. You may optionally add the LXOscComponent
interface if you want your component to be able to receive OSC control via the normal LX engine.
public class MyComponent extends LXComponent implements LXOscComponent {
public final BoundedParameter param1 =
new BoundedParameter("p1", 0)
.setDescription("A global parameter that does something");
public final BoundedParameter param2 =
new BoundedParameter("p2", 0)
.setDescription("A global parameter that does something else");
public MyComponent(LX lx) {
super(lx);
addParameter("param1", this.param1); addParameter("param2", this.param2);
}
}
public MyComponent myComponent;
@Override
public void initialize(LX lx) {
// Create an instance of your global component and register it with the LX engine
// so that it can be saved and loaded in project files
this.myComponent = new MyComponent(lx);
lx.engine.registerComponent("myComponent", this.myComponent);
}
public class UIMyComponent extends UICollapsibleSection {
public UIMyComponent(LXStudio.UI ui, MyComponent myComponent) {
super(ui, 0, 0, ui.leftPane.global.getContentWidth(), 80);
setTitle("MY COMPONENT");
new UIKnob(0, 0, myComponent.param1).addToContainer(this);
new UIKnob(40, 0, myComponent.param2).addToContainer(this);
}
}
public void onUIReady(LXStudio lx, LXStudio.UI ui) {
// Instantiate the UI object and add it to the global section
new UIMyComponent(ui, this.myComponent).addToContainer(ui.leftPane.global);
}
© 2020 LX Studio — Heron Arts LLC