Package heronarts.lx.modulator
Class Accelerator
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.LXRunnableComponent
heronarts.lx.modulator.LXModulator
heronarts.lx.modulator.Accelerator
- All Implemented Interfaces:
LXComponent.Renamable
,LXLoopTask
,LXPath
,LXSerializable
,LXParameter
,LXParameterListener
An accelerator is a free-running modulator that changes its value based on
velocity and acceleration, measured in units/second and units/second^2,
respectively.
-
Nested Class Summary
Nested classes/interfaces inherited from class heronarts.lx.modulator.LXModulator
LXModulator.Device, LXModulator.Global, LXModulator.Placeholder
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Hidden, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.parameter.LXParameter
LXParameter.Collection, LXParameter.Formatter, LXParameter.Monitor, LXParameter.MultiMonitor, LXParameter.Polarity, LXParameter.Units
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
Fields inherited from class heronarts.lx.modulator.LXModulator
crashed, midiFilter
Fields inherited from class heronarts.lx.LXRunnableComponent
runMs, running, trigger
Fields inherited from class heronarts.lx.LXComponent
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, presetFile
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
ConstructorDescriptionAccelerator
(double initValue, double initVelocity, double acceleration) Accelerator
(double initValue, double initVelocity, LXParameter acceleration) Accelerator
(double initValue, LXParameter initVelocity, LXParameter acceleration) Accelerator
(String label, double initValue, double initVelocity, double acceleration) Accelerator
(String label, double initValue, double initVelocity, LXParameter acceleration) Accelerator
(String label, double initValue, LXParameter initVelocity, LXParameter acceleration) -
Method Summary
Modifier and TypeMethodDescriptionprotected double
computeValue
(double deltaMs) Implementation method to advance the modulator's internal state.double
float
double
float
protected void
onReset()
Optional subclass method when reset happens.setAcceleration
(double acceleration) setAcceleration
(LXParameter acceleration) Updates the acceleration.setInitVelocity
(double initVelocity) Sets the initial velocity to a fixed valuesetInitVelocity
(LXParameter initVelocity) Sets initial velocity of the AcceleratorsetSpeed
(double initVelocity, double acceleration) setSpeed
(LXParameter initVelocity, LXParameter acceleration) Sets both the velocity and acceleration of the modulator.setVelocity
(double velocity) Updates the current velocity.Methods inherited from class heronarts.lx.modulator.LXModulator
autostart, disableAutoStart, getCrash, getCrashStackTrace, getFormatter, getIndex, getOscAddress, getOscPath, getPath, getPolarity, getUnits, getValue, isMappingSource, loop, onSetValue, run, setComponent, setFormatter, setIndex, setMappingSource, setPolarity, setUnits, setValue, setValue, updateValue
Methods inherited from class heronarts.lx.LXRunnableComponent
isRunning, onParameterChanged, onStart, onStop, onTrigger, postRun, reset, start, stop, toggle, trigger
Methods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, contains, copyParameters, dispose, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscLabel, getParameter, getParameters, getParent, handleOscMessage, hasParameter, isValidOscParameter, load, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, save, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getLabel, getParentParameter, getValuef, isMappable, reset, setMappable
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getDescription, getParent, isDescendant
-
Constructor Details
-
Accelerator
public Accelerator(double initValue, double initVelocity, double acceleration) -
Accelerator
-
Accelerator
-
Accelerator
-
Accelerator
-
Accelerator
public Accelerator(String label, double initValue, LXParameter initVelocity, LXParameter acceleration)
-
-
Method Details
-
onReset
protected void onReset()Description copied from class:LXRunnableComponent
Optional subclass method when reset happens.- Overrides:
onReset
in classLXRunnableComponent
-
getVelocity
public double getVelocity()- Returns:
- the current velocity
-
getVelocityf
public float getVelocityf()- Returns:
- the current velocity as a floating point
-
getAcceleration
public double getAcceleration()- Returns:
- The current acceleration
-
getAccelerationf
public float getAccelerationf()- Returns:
- The current acceleration, as a float
-
setSpeed
-
setSpeed
Sets both the velocity and acceleration of the modulator. Updates the default values so that a future call to trigger() will reset to this velocity.- Parameters:
initVelocity
- New velocityacceleration
- Acceleration- Returns:
- this
-
setVelocity
Updates the current velocity. Does not reset the default.- Parameters:
velocity
- New velocity- Returns:
- this
-
setInitVelocity
Sets the initial velocity to a fixed value- Parameters:
initVelocity
- Fixed initial velocity value- Returns:
- this
-
setInitVelocity
Sets initial velocity of the Accelerator- Parameters:
initVelocity
- Initial velocity parameter- Returns:
- this
-
setAcceleration
-
setAcceleration
Updates the acceleration.- Parameters:
acceleration
- New acceleration- Returns:
- this
-
computeValue
protected double computeValue(double deltaMs) Description copied from class:LXModulator
Implementation method to advance the modulator's internal state. Subclasses must provide and update value appropriately.- Specified by:
computeValue
in classLXModulator
- Parameters:
deltaMs
- Number of milliseconds to advance by- Returns:
- Computed value
-