Package heronarts.lx.clip
Class Cursor
java.lang.Object
heronarts.lx.clip.Cursor
- All Implemented Interfaces:
LXSerializable
- Direct Known Subclasses:
Cursor.Immutable
A cursor can keep track of time in two ways - either raw wall-clock milliseconds or
a tempo-based beat count plus position within the beat.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
The Cursor.Operator interface specifies all the operations that can be performed on Cursors which depend upon the TimeBase setting.static enum
A reference time-base used for cursor timestampsNested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Cursor.Immutable
static final Cursor.Immutable
static final Cursor.Immutable
static final Cursor.Immutable
static final Cursor.Immutable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new cursor that sums the twoDestructively modifies this cursor, advancing it by the amount specifiedprotected void
Non-destructive version of constrain, bounds the cursor by the length of the given clip.clone()
Constrain the position of this cursor to the length of the clip.double
Gets the position of the cursor within a beat, bounded in the range [0,1)int
Gets the discrete beat-count of this cursor, greater than or equal to 0double
getDeltaMillis
(Cursor that) Returns the absolute time difference between these cursorsdouble
Gets the absolute time millisecond timestamp of this cursorReturn an immutable version of this cursor, typically a copy unless the cursor is already itself immutable.Increments a new cursor that adds or subtracts the two, bounded to zero minimumvoid
load
(LX lx, JsonObject obj) Restores this instance from a JSON objectvoid
reset()
Reset the cursor to zerovoid
save
(LX lx, JsonObject obj) Serializes this instance into the JSON objectscale
(double factor) Creates a new cursor that's a copy of this cursor scaled by the given factorscaleInt
(int factor) Creates a cursor that is an integer set of multiples of this cursorSet the value of the cursor to the value held by anotherSet the value of this cursor to the interpolation of two cursorstoString()
-
Field Details
-
ZERO
-
MIN_LOOP
-
MIN_VIEW
-
MIN_GRID_SPACING
-
MIN_LABEL_SPACING
-
-
Constructor Details
-
Cursor
public Cursor() -
Cursor
protected Cursor(double millis, int beatCount, double beatBasis)
-
-
Method Details
-
assertMutable
protected void assertMutable() -
clone
-
immutable
Return an immutable version of this cursor, typically a copy unless the cursor is already itself immutable.- Returns:
- Immutable version of this cursor
-
getMillis
public double getMillis()Gets the absolute time millisecond timestamp of this cursor- Returns:
- Absolute time of this cursor in milliseconds
-
getBeatCount
public int getBeatCount()Gets the discrete beat-count of this cursor, greater than or equal to 0- Returns:
- Beat count, non-negative
-
getBeatBasis
public double getBeatBasis()Gets the position of the cursor within a beat, bounded in the range [0,1)- Returns:
- Position of the cursor within the beat
-
constrain
Constrain the position of this cursor to the length of the clip. This is a potentially destructive operation which may modify the value if this cursor.- Parameters:
clip
- Clip to constrain the cursor to- Returns:
- This cursor, for method chaining
-
bound
Non-destructive version of constrain, bounds the cursor by the length of the given clip. If this cursor is out of bounds, then either Cursor.ZERO or clip.length.cursor will be returned instead.- Parameters:
clip
- Clip to bound the cursor to- Returns:
- This cursor if in bounds, otherwise clip.length.cursor
-
reset
public void reset()Reset the cursor to zero -
set
Set the value of the cursor to the value held by another- Parameters:
that
- Other cursor- Returns:
- This cursor, updated
-
setLerp
Set the value of this cursor to the interpolation of two cursors- Parameters:
from
- Source cursorto
- Target cursorscale
- Interpolation factor- Returns:
- This cursor, modified, for method chaining
-
scale
Creates a new cursor that's a copy of this cursor scaled by the given factor- Parameters:
factor
- Time scaling factor- Returns:
- New cursor scaled by the given amount
-
scaleInt
Creates a cursor that is an integer set of multiples of this cursor- Parameters:
factor
- Multiples of this cursor- Returns:
- New cursor scaled by the number of multiples
-
advance
Destructively modifies this cursor, advancing it by the amount specified- Parameters:
that
- Cursor specifying amount to advance- Returns:
- This cursor, modified
-
add
Creates a new cursor that sums the two- Parameters:
that
- Cursor to add- Returns:
- New cursor representing sum of this cursor with the other
-
inc
Increments a new cursor that adds or subtracts the two, bounded to zero minimum- Parameters:
that
- Cursor to add or subtractadd
- True to add, if false then subtraction- Returns:
- New cursor representing the result of the operation
-
subtract
-
getDeltaMillis
Returns the absolute time difference between these cursors- Parameters:
that
- Other cursor- Returns:
- Millisecond difference between these two cursors
-
toString
-
save
Description copied from interface:LXSerializable
Serializes this instance into the JSON object- Specified by:
save
in interfaceLXSerializable
- Parameters:
lx
- LX instanceobj
- Object to serialize into
-
load
Description copied from interface:LXSerializable
Restores this instance from a JSON object- Specified by:
load
in interfaceLXSerializable
- Parameters:
lx
- LX instanceobj
- Object to deserialize
-