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.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.LXNormalizedParameter
LXNormalizedParameter.OscModeNested 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
Fields inherited from class heronarts.lx.modulator.LXPeriodicModulator
looping, tempoDivision, tempoLock, tempoSyncFields 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
ConstructorsModifierConstructorDescriptionprotectedLXRangeModulator(String label, LXParameter startValue, LXParameter endValue, LXParameter periodMs) -
Method Summary
Modifier and TypeMethodDescriptionprotected final doublecomputeBasis(double basis, double value) Implementation method to compute the appropriate basis for a modulator given its current basis and value.protected abstract doublecomputeNormalizedBasis(double basis, double normalizedValue) Subclasses determine the basis based on a normalized value from 0 to 1.protected abstract doublecomputeNormalizedValue(double deltaMs, double basis) Subclasses implement this which returns their value from a 0-1 scale.protected final doublecomputeValue(double deltaMs, double basis) Implementation method to compute the value of a modulator given its basis.doubleGets the exponent used for scaling this parameter across its normalized range.final doubleGets the value of the parameter in a normalized space from 0 to 1final floatGets the value of the parameter in a normalized space as a floatvoidonSetValue(double value) Set the modulator to a certain value in its cycle.final LXRangeModulatorsetEndValue(double endValue) Updates the final valuesetEndValue(LXParameter endValue) Assigns a parameter to modulate the end value of this modulator.setExponent(double exponent) final LXRangeModulatorsetNormalized(double normalized) Sets the value or the parameter in normalized space from 0 to 1final LXRangeModulatorsetRange(double startValue, double endValue) Sets the range of the modulator, maintaining the period.final LXRangeModulatorsetRange(double startValue, double endValue, double periodMs) Updates the range of the modulator.final LXRangeModulatorsetRangeFromHereTo(double endValue) Updates the range to proceed from the current value to a new end value.final LXRangeModulatorsetRangeFromHereTo(double endValue, double periodMs) Updates the range to proceed from the current value to a new end value with a new period.final LXRangeModulatorsetStartValue(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, updateBasisMethods 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.LXNormalizedParameter
getBaseNormalized, getBaseNormalizedf, getOscMode, getValueFromNormalized, isWrappableMethods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getFormatter, getLabel, getParentParameter, getPolarity, getUnits, getValue, getValuef, isMappable, reset, setComponent, setFormatter, setMappable, setValueMethods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalLabel, 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:LXNormalizedParameterGets the exponent used for scaling this parameter across its normalized range. Default is 1 which means linear scaling.- Specified by:
getExponentin 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:LXPeriodicModulatorSet the modulator to a certain value in its cycle.- Overrides:
onSetValuein classLXPeriodicModulator- Parameters:
value- The value to apply
-
setNormalized
Description copied from interface:LXNormalizedParameterSets the value or the parameter in normalized space from 0 to 1- Specified by:
setNormalizedin interfaceLXNormalizedParameter- Parameters:
normalized- The normalized value, from 0 to 1- Returns:
- this, for method chaining
-
getNormalized
public final double getNormalized()Description copied from interface:LXNormalizedParameterGets the value of the parameter in a normalized space from 0 to 1- Specified by:
getNormalizedin interfaceLXNormalizedParameter- Returns:
- Value of parameter, normalized to range from 0 to 1
-
getNormalizedf
public final float getNormalizedf()Description copied from interface:LXNormalizedParameterGets the value of the parameter in a normalized space as a float- Specified by:
getNormalizedfin 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:LXPeriodicModulatorImplementation method to compute the value of a modulator given its basis.- Specified by:
computeValuein 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:LXPeriodicModulatorImplementation method to compute the appropriate basis for a modulator given its current basis and value.- Specified by:
computeBasisin 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
-