Package heronarts.lx.modulator
Class LXPeriodicModulator
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.LXRunnableComponent
heronarts.lx.modulator.LXModulator
heronarts.lx.modulator.LXPeriodicModulator
- All Implemented Interfaces:
LXComponent.Renamable,LXLoopTask,LXPath,LXSerializable,LXParameter,LXParameterListener
- Direct Known Subclasses:
Click,Interval,LXRangeModulator,Randomizer,StepModulator
An LXPeriodicModulator is a modulator that moves through a cycle in a given
amount of time. It may then repeat the cycle, or perform it once. The values
are computed based upon a position in the cycle, internally referred to as a
basis, which moves from 0 to 1. This can be thought of as equivalent to an
angle moving from 0 to two times pi. The period itself is a parameter which
may be a modulator or otherwise.
-
Nested Class Summary
Nested classes/interfaces inherited from class heronarts.lx.modulator.LXModulator
LXModulator.Device, LXModulator.Global, LXModulator.PlaceholderNested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Description, LXComponent.Hidden, LXComponent.Name, LXComponent.PluginRequired, LXComponent.RenamableNested classes/interfaces inherited from interface heronarts.lx.parameter.LXParameter
LXParameter.Collection, LXParameter.Formatter, LXParameter.Monitor, LXParameter.MultiMonitor, LXParameter.Polarity, LXParameter.UnitsNested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BooleanParameterWhether this modulator runs continuously looping.final EnumParameter<Tempo.Division> final BooleanParameterfinal BooleanParameterFields inherited from class heronarts.lx.modulator.LXModulator
crashed, midiFilter, midiSourceFields inherited from class heronarts.lx.LXRunnableComponent
runMs, running, triggerFields inherited from class heronarts.lx.LXComponent
childArrays, children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFileFields inherited from interface heronarts.lx.LXPath
DEFAULT_SEPARATOR, ROOT, ROOT_PREFIX, ROOT_SLASH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLXPeriodicModulator(String label, LXParameter period) Utility constructor with period -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract doublecomputeBasis(double basis, double value) Implementation method to compute the appropriate basis for a modulator given its current basis and value.protected final doublecomputeValue(double deltaMs) Implementation method to advance the modulator's internal state.protected abstract doublecomputeValue(double deltaMs, double basis) Implementation method to compute the value of a modulator given its basis.final booleanfinished()For envelope modulators, which are not looping, this returns true if they finished on this frame.final doublegetBasis()Accessor for the current basisfinal floatAccessor for basis as a floatfinal doublefinal floatvoidload(LX lx, JsonObject object) Loads the LX component.final booleanloop()Returns true once each time this modulator loops through its starting position.voidloop(double deltaMs) final intnumLoops()Returns the number of times the modulator looped on the last cycle; should be 0 or 1 unless the period's extremely short and/or the machine is overworked.voidSubclasses are free to override this if desired.protected voidonReset()Optional subclass method when reset happens.voidonSetValue(double value) Set the modulator to a certain value in its cycle.final LXPeriodicModulatorSets the basis to a random positionvoidsave(LX lx, JsonObject object) Serializes the LX component.final LXPeriodicModulatorsetBasis(double basis) Set the modulator to a certain basis position in its cycle.setLooping(boolean looping) Sets whether the modulator should loop after it completes a cycle or halt at the end position.final LXPeriodicModulatorsetPeriod(double periodMs) Modify the period of this modulatorfinal LXPeriodicModulatorsetPeriod(LXParameter period) Sets a parameter to the period of this modulatorprotected final voidupdateBasis(double value) Updates the basis of the modulator based on present values.Methods inherited from class heronarts.lx.modulator.LXModulator
autostart, disableAutoStart, getCrash, getCrashStackTrace, getFormatter, getIndex, getOscAddress, getOscPath, getPath, getPolarity, getUnits, getValue, isMappingSource, run, setComponent, setFormatter, setIndex, setMappingSource, setPolarity, setUnits, setValue, setValue, updateValueMethods inherited from class heronarts.lx.LXRunnableComponent
isRunning, onStart, onStop, onTrigger, postRun, reset, start, stop, toggle, triggerMethods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, assertDisposed, contains, copyParameters, dispose, getCategory, getChild, getComponentDescription, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscLabel, getParameter, getParameters, getParent, handleOscMessage, hasParameter, isValidOscParameter, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getLabel, getParentParameter, getValuef, isMappable, reset, setMappableMethods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getDescription, getParent, isDescendant
-
Field Details
-
looping
Whether this modulator runs continuously looping. -
tempoSync
-
tempoDivision
-
tempoLock
-
-
Constructor Details
-
LXPeriodicModulator
Utility constructor with period- Parameters:
label- Labelperiod- Parameter for period
-
-
Method Details
-
onParameterChanged
Description copied from class:LXComponentSubclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.- Specified by:
onParameterChangedin interfaceLXParameterListener- Overrides:
onParameterChangedin classLXRunnableComponent- Parameters:
p- Parameter that has a value change
-
setLooping
Sets whether the modulator should loop after it completes a cycle or halt at the end position.- Parameters:
looping- Whether to loop- Returns:
- this, for method chaining
-
disableAutoReset
-
getBasis
public final double getBasis()Accessor for the current basis- Returns:
- The basis of the modulator
-
getBasisf
public final float getBasisf()Accessor for basis as a float- Returns:
- basis as float
-
onReset
protected void onReset()Description copied from class:LXRunnableComponentOptional subclass method when reset happens.- Overrides:
onResetin classLXRunnableComponent
-
randomBasis
Sets the basis to a random position- Returns:
- this
-
setBasis
Set the modulator to a certain basis position in its cycle.- Parameters:
basis- Basis of modulator, from 0-1- Returns:
- this
-
onSetValue
public void onSetValue(double value) Set the modulator to a certain value in its cycle.- Overrides:
onSetValuein classLXModulator- Parameters:
value- The value to apply
-
updateBasis
protected final void updateBasis(double value) Updates the basis of the modulator based on present values.- Parameters:
value- New value of the modulator
-
setPeriod
Modify the period of this modulator- Parameters:
periodMs- New period, in milliseconds- Returns:
- Modulator, for method chaining;
-
getPeriod
public final double getPeriod()- Returns:
- The period of this modulator
-
getPeriodf
public final float getPeriodf()- Returns:
- The period of this modulator as a floating point
-
setPeriod
Sets a parameter to the period of this modulator- Parameters:
period- Parameter for period value- Returns:
- This modulator, for method chaining
-
loop
public void loop(double deltaMs) - Specified by:
loopin interfaceLXLoopTask- Overrides:
loopin classLXModulator
-
computeValue
protected final double computeValue(double deltaMs) Description copied from class:LXModulatorImplementation method to advance the modulator's internal state. Subclasses must provide and update value appropriately.- Specified by:
computeValuein classLXModulator- Parameters:
deltaMs- Number of milliseconds to advance by- Returns:
- Computed value
-
loop
public final boolean loop()Returns true once each time this modulator loops through its starting position.- Returns:
- true if the modulator just looped
-
numLoops
public final int numLoops()Returns the number of times the modulator looped on the last cycle; should be 0 or 1 unless the period's extremely short and/or the machine is overworked.- Returns:
- number of loops on the last cycle
-
finished
public final boolean finished()For envelope modulators, which are not looping, this returns true if they finished on this frame.- Returns:
- true if the modulator just finished its operation on this frame
-
computeValue
protected abstract double computeValue(double deltaMs, double basis) Implementation method to compute the value of a modulator given its basis.- Parameters:
deltaMs- Milliseconds elapsedbasis- Basis of the modulator- Returns:
- Value of modulator
-
computeBasis
protected abstract double computeBasis(double basis, double value) Implementation method to compute the appropriate basis for a modulator given its current basis and value.- Parameters:
basis- Last basis of modulatorvalue- Current value of modulator- Returns:
- Basis of modulator
-
save
Description copied from class:LXComponentSerializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to callsuper.save(lx, obj)at the appropriate time.- Specified by:
savein interfaceLXSerializable- Overrides:
savein classLXComponent- Parameters:
lx- LX instanceobject- Object to serialize into
-
load
Description copied from class:LXComponentLoads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.- Specified by:
loadin interfaceLXSerializable- Overrides:
loadin classLXComponent- Parameters:
lx- LX instanceobject- Object to deserialize
-