Class 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
      If true, 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
      If true, 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
      If true, the player reported that it was playing when the update was received.
      boolean precise
      If true, 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
      If true, 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.
    • 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
        If true, 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
        If true, 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
        If true, this position update resulted from the receipt of a beat packet.
      • playing

        public final boolean playing
        If true, 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
        If true, 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 a false value for precise.
        Parameters:
        timestamp - when this update was received
        milliseconds - how far into the track has the player reached
        beatNumber - the beat number that was reported (or incremented) by this update
        definitive - 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 received
        pitch - the playback pitch (where 1.0 is normal speed) when this update was received
        reverse - indicates if the player was playing backwards when this update was received
        beatGrid - 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 received
        milliseconds - how far into the track has the player reached
        beatNumber - the beat number that was reported (or incremented) by this update
        definitive - 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 received
        pitch - the playback pitch (where 1.0 is normal speed) when this update was received
        reverse - indicates if the player was playing backwards when this update was received
        beatGrid - the track beat grid that was used to calculate the update
        precise - this position was derived from a high-precision position packet, directly or through a beat
        fromBeat - 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