Class Beat


  • public class Beat
    extends DeviceUpdate
    A device update that announces the start of a new beat on a DJ Link network. Even though beats contain far less detailed information than status updates, they can be passed to VirtualCdj.getLatestStatusFor(DeviceUpdate) to find the current detailed status for that device, as long as the Virtual CDJ is active. They also provide information about the timing of a variety upcoming beats and bars, which would be helpful for implementing Sync in a player, but since the full BeatGrid can be used for that purpose just as well, access has not been provided to those values. If they would be useful to you, please open an Issue.
    Author:
    James Elliott
    • Constructor Detail

      • Beat

        public Beat​(DatagramPacket packet)
        Constructor sets all the immutable interpreted fields based on the packet content.
        Parameters:
        packet - the beat announcement packet that was received
    • Method Detail

      • getPitch

        public int getPitch()
        Get the device pitch at the time of the beat. This is an integer ranging from 0 to 2097152, which corresponds to a range between completely stopping playback to playing at twice normal tempo. The equivalent percentage value can be obtained by passing the pitch to Util.pitchToPercentage(long), and the corresponding fractional scaling value by passing it to Util.pitchToMultiplier(long).
        Specified by:
        getPitch in class DeviceUpdate
        Returns:
        the raw device pitch
      • getBpm

        public int getBpm()
        Get the track BPM at the time of the beat. This is an integer representing the BPM times 100, so a track running at 120.5 BPM would be represented by the value 12050.
        Specified by:
        getBpm in class DeviceUpdate
        Returns:
        the track BPM to two decimal places multiplied by 100
      • getBeatWithinBar

        public int getBeatWithinBar()
        Get the position within a measure of music at which this beat falls (a value from 1 to 4, where 1 represents the down beat). This value will be accurate for players when the track was properly configured within rekordbox (and if the music follows a standard House 4/4 time signature). The mixer makes no effort to synchronize down beats with players, however, so this value is meaningless when coming from the mixer.
        Specified by:
        getBeatWithinBar in class DeviceUpdate
        Returns:
        the beat number within the current measure of music
      • isBeatWithinBarMeaningful

        public boolean isBeatWithinBarMeaningful()

        Returns true if this beat is coming from a device where getBeatWithinBar() can reasonably be expected to have musical significance, because it respects the way a track was configured within rekordbox.

        If the VirtualCdj is running, we can check the latest status update received from this device to get a definitive answer. Otherwise we guess based on the device number; mixers seem to fall in the range 33 and up.

        Specified by:
        isBeatWithinBarMeaningful in class DeviceUpdate
        Returns:
        true for status packets from players, false for status packets from mixers
      • isSynced

        public boolean isSynced()
        Was this beat sent by a device that is synced to the tempo master?
        Specified by:
        isSynced in class DeviceUpdate
        Returns:
        true if the device that sent this beat is synced
        Throws:
        IllegalStateException - if the VirtualCdj is not running
      • getDeviceMasterIsBeingYieldedTo

        public Integer getDeviceMasterIsBeingYieldedTo()
        Description copied from class: DeviceUpdate
        If this packet indicates the device in the process of yielding the tempo master role to another player, this will hold the device number of that player, otherwise it will be null.
        Specified by:
        getDeviceMasterIsBeingYieldedTo in class DeviceUpdate
        Returns:
        the device number, if any, this update is yielding the tempo master role to
      • getEffectiveTempo

        public double getEffectiveTempo()
        Description copied from class: DeviceUpdate
        Get the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.
        Specified by:
        getEffectiveTempo in class DeviceUpdate
        Returns:
        the beats per minute this device is reporting