Class Accelerator

All Implemented Interfaces:
LXComponent.Renamable, LXLoopTask, LXPath, LXSerializable, LXParameter, LXParameterListener

public class Accelerator extends LXModulator
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.
  • Constructor Details

    • Accelerator

      public Accelerator(double initValue, double initVelocity, double acceleration)
    • Accelerator

      public Accelerator(double initValue, double initVelocity, LXParameter acceleration)
    • Accelerator

      public Accelerator(double initValue, LXParameter initVelocity, LXParameter acceleration)
    • Accelerator

      public Accelerator(String label, double initValue, double initVelocity, double acceleration)
    • Accelerator

      public Accelerator(String label, double initValue, double initVelocity, LXParameter acceleration)
    • 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 class LXRunnableComponent
    • 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

      public Accelerator setSpeed(double initVelocity, double acceleration)
    • setSpeed

      public Accelerator setSpeed(LXParameter initVelocity, LXParameter acceleration)
      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 velocity
      acceleration - Acceleration
      Returns:
      this
    • setVelocity

      public Accelerator setVelocity(double velocity)
      Updates the current velocity. Does not reset the default.
      Parameters:
      velocity - New velocity
      Returns:
      this
    • setInitVelocity

      public Accelerator setInitVelocity(double initVelocity)
      Sets the initial velocity to a fixed value
      Parameters:
      initVelocity - Fixed initial velocity value
      Returns:
      this
    • setInitVelocity

      public Accelerator setInitVelocity(LXParameter initVelocity)
      Sets initial velocity of the Accelerator
      Parameters:
      initVelocity - Initial velocity parameter
      Returns:
      this
    • setAcceleration

      public Accelerator setAcceleration(double acceleration)
    • setAcceleration

      public Accelerator setAcceleration(LXParameter acceleration)
      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 class LXModulator
      Parameters:
      deltaMs - Number of milliseconds to advance by
      Returns:
      Computed value