public abstract class LXPeriodicModulator extends LXModulator
LXComponent.Placeholder, LXComponent.Renamable
LXParameter.Formatter, LXParameter.Polarity, LXParameter.Units
LXSerializable.Utils
Modifier and Type | Field and Description |
---|---|
BooleanParameter |
looping
Whether this modulator runs continuously looping.
|
EnumParameter<Tempo.Division> |
tempoDivision |
BooleanParameter |
tempoLock |
BooleanParameter |
tempoSync |
runMs, running, trigger
controlSurfaceSemaphore, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_PARAMETER_PATH, KEY_PATH, label, lx, modulationColor
Modifier | Constructor and Description |
---|---|
protected |
LXPeriodicModulator(String label,
LXParameter period)
Utility constructor with period
|
Modifier and Type | Method and Description |
---|---|
protected abstract double |
computeBasis(double basis,
double value)
Implementation method to compute the appropriate basis for a modulator
given its current basis and value.
|
protected double |
computeValue(double deltaMs)
Implementation method to advance the modulator's internal state.
|
protected abstract double |
computeValue(double deltaMs,
double basis)
Implementation method to compute the value of a modulator given its basis.
|
boolean |
finished()
For envelope modulators, which are not looping, this returns true if they
finished on this frame.
|
double |
getBasis()
Accessor for the current basis
|
float |
getBasisf()
Accessor for basis as a float
|
double |
getPeriod() |
float |
getPeriodf() |
void |
load(LX lx,
JsonObject object)
Loads the LX component.
|
boolean |
loop()
Returns true once each time this modulator loops through its starting position.
|
void |
loop(double deltaMs) |
void |
onParameterChanged(LXParameter p)
Subclasses are free to override this if desired.
|
protected void |
onReset()
Optional subclass method when reset happens.
|
void |
onSetValue(double value)
Set the modulator to a certain value in its cycle.
|
LXPeriodicModulator |
randomBasis()
Sets the basis to a random position
|
void |
save(LX lx,
JsonObject object)
Serializes the LX component.
|
LXPeriodicModulator |
setBasis(double basis)
Set the modulator to a certain basis position in its cycle.
|
LXPeriodicModulator |
setLooping(boolean looping)
Sets whether the modulator should loop after it completes a cycle or halt
at the end position.
|
LXPeriodicModulator |
setPeriod(double periodMs)
Modify the period of this modulator
|
LXPeriodicModulator |
setPeriod(LXParameter period)
Sets a parameter to the period of this modulator
|
protected void |
updateBasis(double value)
Updates the basis of the modulator based on present values.
|
getDescription, getFormatter, getIndex, getOscAddress, getOscPath, getPath, getPolarity, getUnits, getValue, getValuef, run, setComponent, setDescription, setFormatter, setIndex, setPolarity, setUnits, setValue, setValue, updateValue
isRunning, onStart, onStop, reset, start, stop, toggle, trigger
addArray, addChild, addInternalParameter, addParameter, addParameter, contains, copyParameters, dispose, getChild, getComponentName, getComponentName, getComponentName, getId, getLabel, getLX, getOscLabel, getParameter, getParameters, getParent, handleOscMessage, loadParameters, removeParameter, removeParameter, saveParameters, setParent, toString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dispose, getLabel, isMappable, reset, setMappable
get, get, getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getComponent, getComponent, getParameter, getParameter, getParent
public final BooleanParameter looping
public final BooleanParameter tempoSync
public final EnumParameter<Tempo.Division> tempoDivision
public final BooleanParameter tempoLock
protected LXPeriodicModulator(String label, LXParameter period)
label
- Labelperiod
- Parameter for periodpublic void onParameterChanged(LXParameter p)
LXComponent
onParameterChanged
in interface LXParameterListener
onParameterChanged
in class LXRunnableComponent
p
- Parameter that has a value changepublic LXPeriodicModulator setLooping(boolean looping)
looping
- Whether to looppublic final double getBasis()
public final float getBasisf()
protected void onReset()
LXRunnableComponent
onReset
in class LXRunnableComponent
public final LXPeriodicModulator randomBasis()
public final LXPeriodicModulator setBasis(double basis)
basis
- Basis of modulator, from 0-1public void onSetValue(double value)
onSetValue
in class LXModulator
value
- The value to applyprotected final void updateBasis(double value)
value
- New value of the modulatorpublic final LXPeriodicModulator setPeriod(double periodMs)
periodMs
- New period, in millisecondspublic final double getPeriod()
public final float getPeriodf()
public final LXPeriodicModulator setPeriod(LXParameter period)
period
- Parameter for period valuepublic void loop(double deltaMs)
loop
in interface LXLoopTask
loop
in class LXRunnableComponent
protected final double computeValue(double deltaMs)
LXModulator
computeValue
in class LXModulator
deltaMs
- Number of milliseconds to advance bypublic final boolean loop()
public final boolean finished()
protected abstract double computeValue(double deltaMs, double basis)
deltaMs
- Milliseconds elapsedbasis
- Basis of the modulatorprotected abstract double computeBasis(double basis, double value)
basis
- Last basis of modulatorvalue
- Current value of modulatorpublic void save(LX lx, JsonObject object)
LXComponent
super.save(lx, obj)
at the appropriate time.save
in interface LXSerializable
save
in class LXComponent
lx
- LX instanceobject
- Object to serialize intopublic void load(LX lx, JsonObject object)
LXComponent
load
in interface LXSerializable
load
in class LXComponent
lx
- LX instanceobject
- Object to deserializeLX library by Mark C. Slee. © 2012-2020