Package org.deepsymmetry.beatlink.data
Class TrackPositionUpdate
- java.lang.Object
-
- org.deepsymmetry.beatlink.data.TrackPositionUpdate
-
public class TrackPositionUpdate extends Object
Keeps track of the most recent information we have received from a player from which we have been able to compute a track position.
-
-
Field Summary
Fields Modifier and Type Field Description BeatGrid
beatGrid
The track metadata against which this update was calculated, so that if it has changed, we know to discard the update.int
beatNumber
The beat number that was reported (or incremented) by this update.boolean
definitive
Iftrue
, this was created in response to a beat packet or precise position packet, so we know exactly where the player was at that point.boolean
fromBeat
Iftrue
, this position update resulted from the receipt of a beat packet.long
milliseconds
How far into the track has the player reached.double
pitch
The playback pitch when this update was created.boolean
playing
Iftrue
, the player reported that it was playing when the update was received.boolean
precise
Iftrue
, we are receiving precise position packets from this player, so we know exactly where the player is even when it is not playing, or jumping or looping within beats.boolean
reverse
Iftrue
, the player was playing backwards when this update was created.long
timestamp
When this update was received.
-
Constructor Summary
Constructors Constructor Description TrackPositionUpdate(long timestamp, long milliseconds, int beatNumber, boolean definitive, boolean playing, double pitch, boolean reverse, BeatGrid beatGrid)
Constructor simply sets the fields of this immutable value class.TrackPositionUpdate(long timestamp, long milliseconds, int beatNumber, boolean definitive, boolean playing, double pitch, boolean reverse, BeatGrid beatGrid, boolean precise, boolean fromBeat)
Constructor simply sets the fields of this immutable value class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBeatWithinBar()
Returns the beat phase (where within a measure the current beat falls), a number from 1 to 4, corresponding to the beat being played at this playback position.String
toString()
-
-
-
Field Detail
-
timestamp
public final long timestamp
When this update was received.
-
milliseconds
public final long milliseconds
How far into the track has the player reached.
-
beatNumber
public final int beatNumber
The beat number that was reported (or incremented) by this update.
-
definitive
public final boolean definitive
Iftrue
, this was created in response to a beat packet or precise position packet, so we know exactly where the player was at that point. Otherwise, we infer position based on how long has elapsed since the previous beat packet, and the intervening playback pitch and direction.
-
precise
public final boolean precise
Iftrue
, we are receiving precise position packets from this player, so we know exactly where the player is even when it is not playing, or jumping or looping within beats.
-
fromBeat
public final boolean fromBeat
Iftrue
, this position update resulted from the receipt of a beat packet.
-
playing
public final boolean playing
Iftrue
, the player reported that it was playing when the update was received.
-
pitch
public final double pitch
The playback pitch when this update was created.
-
reverse
public final boolean reverse
Iftrue
, the player was playing backwards when this update was created.
-
beatGrid
public final BeatGrid beatGrid
The track metadata against which this update was calculated, so that if it has changed, we know to discard the update.
-
-
Constructor Detail
-
TrackPositionUpdate
public TrackPositionUpdate(long timestamp, long milliseconds, int beatNumber, boolean definitive, boolean playing, double pitch, boolean reverse, BeatGrid beatGrid)
Constructor simply sets the fields of this immutable value class. Backwards-compatible version which infers afalse
value forprecise
.- Parameters:
timestamp
- when this update was receivedmilliseconds
- how far into the track has the player reachedbeatNumber
- the beat number that was reported (or incremented) by this updatedefinitive
- indicates if this was based on a direct report of track position from the player (i.e. a beat)playing
- indicates whether the player was actively playing a track when this update was receivedpitch
- the playback pitch (where 1.0 is normal speed) when this update was receivedreverse
- indicates if the player was playing backwards when this update was receivedbeatGrid
- the track beat grid that was used to calculate the update
-
TrackPositionUpdate
public TrackPositionUpdate(long timestamp, long milliseconds, int beatNumber, boolean definitive, boolean playing, double pitch, boolean reverse, BeatGrid beatGrid, boolean precise, boolean fromBeat)
Constructor simply sets the fields of this immutable value class.- Parameters:
timestamp
- when this update was receivedmilliseconds
- how far into the track has the player reachedbeatNumber
- the beat number that was reported (or incremented) by this updatedefinitive
- indicates if this was based on a direct report of track position from the player (i.e. a beat)playing
- indicates whether the player was actively playing a track when this update was receivedpitch
- the playback pitch (where 1.0 is normal speed) when this update was receivedreverse
- indicates if the player was playing backwards when this update was receivedbeatGrid
- the track beat grid that was used to calculate the updateprecise
- this position was derived from a high-precision position packet, directly or through a beatfromBeat
- this position was created in response to a beat packet
-
-
Method Detail
-
getBeatWithinBar
public int getBeatWithinBar()
Returns the beat phase (where within a measure the current beat falls), a number from 1 to 4, corresponding to the beat being played at this playback position.- Returns:
- where the current beat falls in a measure, or 0 if no beat grid was available
-
-