Package heronarts.lx.modulator
Class LXRangeModulator
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.LXRunnableComponent
heronarts.lx.modulator.LXModulator
heronarts.lx.modulator.LXPeriodicModulator
heronarts.lx.modulator.LXRangeModulator
- All Implemented Interfaces:
LXComponent.Renamable
,LXLoopTask
,LXPath
,LXSerializable
,LXNormalizedParameter
,LXParameter
,LXParameterListener
- Direct Known Subclasses:
FunctionalModulator
,LXVariablePeriodModulator
,QuadraticEnvelope
,SawLFO
,SinLFO
,SquareLFO
,TriangleLFO
Utility subclass for modulators which oscillate in a range of values between
a minimum and a maximum. Includes a set of common methods to change the
bounds while the modulator is running, keeping values within bounds. All
scaling is done by this class, subclasses can just work in a normalized space
between 0 and 1.
-
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.LXNormalizedParameter
LXNormalizedParameter.OscMode
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.LXPeriodicModulator
looping, tempoDivision, tempoLock, tempoSync
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
ModifierConstructorDescriptionprotected
LXRangeModulator
(String label, LXParameter startValue, LXParameter endValue, LXParameter periodMs) -
Method Summary
Modifier and TypeMethodDescriptionprotected final double
computeBasis
(double basis, double value) Implementation method to compute the appropriate basis for a modulator given its current basis and value.protected abstract double
computeNormalizedBasis
(double basis, double normalizedValue) Subclasses determine the basis based on a normalized value from 0 to 1.protected abstract double
computeNormalizedValue
(double deltaMs, double basis) Subclasses implement this which returns their value from a 0-1 scale.protected final double
computeValue
(double deltaMs, double basis) Implementation method to compute the value of a modulator given its basis.double
Gets the exponent used for scaling this parameter across its normalized range.final double
Gets the value of the parameter in a normalized space from 0 to 1final float
Gets the value of the parameter in a normalized space as a floatvoid
onSetValue
(double value) Set the modulator to a certain value in its cycle.final LXRangeModulator
setEndValue
(double endValue) Updates the final valuesetEndValue
(LXParameter endValue) Assigns a parameter to modulate the end value of this modulator.setExponent
(double exponent) final LXRangeModulator
setNormalized
(double normalized) Sets the value or the parameter in normalized space from 0 to 1final LXRangeModulator
setRange
(double startValue, double endValue) Sets the range of the modulator, maintaining the period.final LXRangeModulator
setRange
(double startValue, double endValue, double periodMs) Updates the range of the modulator.final LXRangeModulator
setRangeFromHereTo
(double endValue) Updates the range to proceed from the current value to a new end value.final LXRangeModulator
setRangeFromHereTo
(double endValue, double periodMs) Updates the range to proceed from the current value to a new end value with a new period.final LXRangeModulator
setStartValue
(double startValue) Updates the initial valuesetStartValue
(LXParameter startValue) Assigns a parameter to modulate the start value of this modulator.Methods inherited from class heronarts.lx.modulator.LXPeriodicModulator
computeValue, disableAutoReset, finished, getBasis, getBasisf, getPeriod, getPeriodf, load, loop, loop, numLoops, onParameterChanged, onReset, randomBasis, save, setBasis, setLooping, setPeriod, setPeriod, updateBasis
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, updateValue
Methods inherited from class heronarts.lx.LXRunnableComponent
isRunning, 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, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, 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.LXNormalizedParameter
getBaseNormalized, getBaseNormalizedf, getOscMode, getValueFromNormalized, isWrappable
Methods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getFormatter, getLabel, getParentParameter, getPolarity, getUnits, getValue, getValuef, isMappable, reset, setComponent, setFormatter, setMappable, setValue
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getDescription, getParent, getPath, isDescendant
-
Constructor Details
-
LXRangeModulator
protected LXRangeModulator(String label, LXParameter startValue, LXParameter endValue, LXParameter periodMs)
-
-
Method Details
-
setRange
Updates the range of the modulator.- Parameters:
startValue
- New start valueendValue
- New final valueperiodMs
- New period, in milliseconds- Returns:
- this
-
setExponent
-
getExponent
public double getExponent()Description copied from interface:LXNormalizedParameter
Gets the exponent used for scaling this parameter across its normalized range. Default is 1 which means linear scaling.- Specified by:
getExponent
in interfaceLXNormalizedParameter
- Returns:
- scaling exponent
-
setRange
Sets the range of the modulator, maintaining the period.- Parameters:
startValue
- New start valueendValue
- New end value- Returns:
- this
-
setStartValue
Updates the initial value- Parameters:
startValue
- New start value- Returns:
- this
-
setEndValue
Updates the final value- Parameters:
endValue
- New final value- Returns:
- this
-
setRangeFromHereTo
Updates the range to proceed from the current value to a new end value. Future oscillations will use the current value as the starting value.- Parameters:
endValue
- New end value- Returns:
- this
-
setRangeFromHereTo
Updates the range to proceed from the current value to a new end value with a new period. Future oscillations will use the current value as the starting value.- Parameters:
endValue
- New end valueperiodMs
- New period, in milliseconds- Returns:
- this
-
setStartValue
Assigns a parameter to modulate the start value of this modulator.- Parameters:
startValue
- A parameter to modify the start value- Returns:
- this
-
setEndValue
Assigns a parameter to modulate the end value of this modulator.- Parameters:
endValue
- A parameter to modify the start value- Returns:
- this
-
onSetValue
public void onSetValue(double value) Description copied from class:LXPeriodicModulator
Set the modulator to a certain value in its cycle.- Overrides:
onSetValue
in classLXPeriodicModulator
- Parameters:
value
- The value to apply
-
setNormalized
Description copied from interface:LXNormalizedParameter
Sets the value or the parameter in normalized space from 0 to 1- Specified by:
setNormalized
in interfaceLXNormalizedParameter
- Parameters:
normalized
- The normalized value, from 0 to 1- Returns:
- this, for method chaining
-
getNormalized
public final double getNormalized()Description copied from interface:LXNormalizedParameter
Gets the value of the parameter in a normalized space from 0 to 1- Specified by:
getNormalized
in interfaceLXNormalizedParameter
- Returns:
- Value of parameter, normalized to range from 0 to 1
-
getNormalizedf
public final float getNormalizedf()Description copied from interface:LXNormalizedParameter
Gets the value of the parameter in a normalized space as a float- Specified by:
getNormalizedf
in interfaceLXNormalizedParameter
- Returns:
- Normalized value of parameter, in range from 0 to 1
-
computeValue
protected final double computeValue(double deltaMs, double basis) Description copied from class:LXPeriodicModulator
Implementation method to compute the value of a modulator given its basis.- Specified by:
computeValue
in classLXPeriodicModulator
- Parameters:
deltaMs
- Milliseconds elapsedbasis
- Basis of the modulator- Returns:
- Value of modulator
-
computeBasis
protected final double computeBasis(double basis, double value) Description copied from class:LXPeriodicModulator
Implementation method to compute the appropriate basis for a modulator given its current basis and value.- Specified by:
computeBasis
in classLXPeriodicModulator
- Parameters:
basis
- Last basis of modulatorvalue
- Current value of modulator- Returns:
- Basis of modulator
-
computeNormalizedValue
protected abstract double computeNormalizedValue(double deltaMs, double basis) Subclasses implement this which returns their value from a 0-1 scale. This class automatically takes care of scaling to the startValue/endValue range.- Parameters:
deltaMs
- Milliseconds elapsedbasis
- Basis of modulator- Returns:
- Modulator value
-
computeNormalizedBasis
protected abstract double computeNormalizedBasis(double basis, double normalizedValue) Subclasses determine the basis based on a normalized value from 0 to 1.- Parameters:
basis
- Modulator basisnormalizedValue
- A normalize value from 0 to 1- Returns:
- Computed normalized basis for modulator
-