Class LXRangeModulator

All Implemented Interfaces:
LXComponent.Renamable, LXLoopTask, LXPath, LXSerializable, LXNormalizedParameter, LXParameter, LXParameterListener
Direct Known Subclasses:
FunctionalModulator, LXVariablePeriodModulator, QuadraticEnvelope, SawLFO, SinLFO, SquareLFO, TriangleLFO

public abstract class LXRangeModulator extends LXPeriodicModulator implements LXNormalizedParameter
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.
  • Constructor Details

  • Method Details

    • setRange

      public final LXRangeModulator setRange(double startValue, double endValue, double periodMs)
      Updates the range of the modulator.
      Parameters:
      startValue - New start value
      endValue - New final value
      periodMs - New period, in milliseconds
      Returns:
      this
    • setExponent

      public LXRangeModulator setExponent(double exponent)
    • 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 interface LXNormalizedParameter
      Returns:
      scaling exponent
    • setRange

      public final LXRangeModulator setRange(double startValue, double endValue)
      Sets the range of the modulator, maintaining the period.
      Parameters:
      startValue - New start value
      endValue - New end value
      Returns:
      this
    • setStartValue

      public final LXRangeModulator setStartValue(double startValue)
      Updates the initial value
      Parameters:
      startValue - New start value
      Returns:
      this
    • setEndValue

      public final LXRangeModulator setEndValue(double endValue)
      Updates the final value
      Parameters:
      endValue - New final value
      Returns:
      this
    • setRangeFromHereTo

      public final LXRangeModulator setRangeFromHereTo(double endValue)
      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

      public 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. Future oscillations will use the current value as the starting value.
      Parameters:
      endValue - New end value
      periodMs - New period, in milliseconds
      Returns:
      this
    • setStartValue

      public LXRangeModulator setStartValue(LXParameter startValue)
      Assigns a parameter to modulate the start value of this modulator.
      Parameters:
      startValue - A parameter to modify the start value
      Returns:
      this
    • setEndValue

      public LXRangeModulator setEndValue(LXParameter endValue)
      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 class LXPeriodicModulator
      Parameters:
      value - The value to apply
    • setNormalized

      public final LXRangeModulator setNormalized(double normalized)
      Description copied from interface: LXNormalizedParameter
      Sets the value or the parameter in normalized space from 0 to 1
      Specified by:
      setNormalized in interface LXNormalizedParameter
      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 interface LXNormalizedParameter
      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 interface LXNormalizedParameter
      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 class LXPeriodicModulator
      Parameters:
      deltaMs - Milliseconds elapsed
      basis - 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 class LXPeriodicModulator
      Parameters:
      basis - Last basis of modulator
      value - 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 elapsed
      basis - 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 basis
      normalizedValue - A normalize value from 0 to 1
      Returns:
      Computed normalized basis for modulator