-
Notifications
You must be signed in to change notification settings - Fork 4
Learning LX: Modulators
Mark Slee edited this page Nov 24, 2020
·
1 revision
One layer above the Parameter is LXModulator. A modulator is a specialized type of parameter with a value that automatically changes over time. Modulators are runnable components, which means that their operation can be started and stopped. A modulator may also have registered parameters that control its own operation.
The most basic types of modulators are the LFO family. LFO denotes Low Frequency Oscillation, a common concept in audio synthesis which is also extremely useful in animation.
// A sinusoidal wave that oscillates from 0 to 1 every 2500 milliseconds
SinLFO lfo = new SinLFO("Sin Wave", 0, 1, 2500);
// A triangular wave oscillating from 2 to 5 every 5000 milliseconds
TriangleLFO lfo = new TriangleLFO("Tri Wave", 2, 5, 5000);
// A square wave that switches between -4 and 4 every 1000 milliseconds
SquareLFO lfo = new TriangleLFO("Square Wave", -4, 4, 1000);
// A sawtooth wave that ramps from 5 to 15 every 3000 milliseconds
SawLFO lfo = new SawLFO("Saw Wave", 5, 15, 3000);
Modulators must belong to an LXModulationComponent. They should be registered in the component's constructor.
public class MyPattern extends LXPattern {
public final SinLFO lfo = new SinLFO("Oscillation", 0, 1, 2500);
public MyPattern(LX lx) {
super(lx);
// Register the modulator
addModulator(lfo);
// Start the modulator running
lfo.start();
}
...
}
Modulators have a set of methods that control their operation.
// Starts the modulator
modulator.start();
// Stops the modulator
modulator.stop();
// Stops the modulator and resets to initial condition
modulator.reset();
// Re-starts the modulator from initial condition
modulator.trigger();
© 2020 LX Studio — Heron Arts LLC