Package org.deepsymmetry.beatlink
Class Beat
- java.lang.Object
- 
- org.deepsymmetry.beatlink.DeviceUpdate
- 
- org.deepsymmetry.beatlink.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 toVirtualCdj.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 may be helpful for implementing Sync in a player, but the fullBeatGridcan be obtained as well.- Author:
- James Elliott
 
- 
- 
Constructor SummaryConstructors Constructor Description Beat(DatagramPacket packet)Constructor sets all the immutable interpreted fields based on the packet content.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBeatWithinBar()Get the position within a measure of music at which this beat falls (a value from 1 to 4, where 1 represents the downbeat).intgetBpm()Get the track BPM at the time of the beat.IntegergetDeviceMasterIsBeingYieldedTo()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 benull.doublegetEffectiveTempo()Get the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.longgetEighthBeat()Get the time at which the eighth beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%).longgetFourthBeat()Get the time at which the fourth beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%).longgetNextBar()Get the time at which the next bar would begin (the next downbeat would arrive), in milliseconds, if the track were being played at normal speed (a pitch of +0%).longgetNextBeat()Get the time at which the next beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%).intgetPitch()Get the device pitch at the time of the beat.longgetSecondBar()Get the time at which the second upcoming bar would begin (the second downbeat would arrive), in milliseconds, if the track were being played at normal speed (a pitch of +0%).longgetSecondBeat()Get the time at which the second upcoming beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%).booleanisBeatWithinBarMeaningful()Returnstrueif this beat is coming from a device wheregetBeatWithinBar()can reasonably be expected to have musical significance, because it respects the way a track was configured within rekordbox.booleanisSynced()Was this beat sent by a device that is synced to the tempo master?booleanisTempoMaster()Was this beat sent by the current tempo master?StringtoString()- 
Methods inherited from class org.deepsymmetry.beatlink.DeviceUpdategetAddress, getDeviceName, getDeviceNumber, getPacketBytes, getTimestamp, isPreNexusCdj
 
- 
 
- 
- 
- 
Constructor Detail- 
Beatpublic 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- 
getPitchpublic 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 toUtil.pitchToPercentage(long), and the corresponding fractional scaling value by passing it toUtil.pitchToMultiplier(long).- Specified by:
- getPitchin class- DeviceUpdate
- Returns:
- the raw device pitch
 
 - 
getBpmpublic 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:
- getBpmin class- DeviceUpdate
- Returns:
- the track BPM to two decimal places multiplied by 100
 
 - 
getBeatWithinBarpublic 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 downbeat). 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 downbeats with players, however, so this value is meaningless when coming from the mixer.- Specified by:
- getBeatWithinBarin class- DeviceUpdate
- Returns:
- the beat number within the current measure of music
 
 - 
getNextBeatpublic long getNextBeat() Get the time at which the next beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that beat, returns0xffffffff.- Returns:
- the number of milliseconds after which the next beat occurs
 
 - 
getSecondBeatpublic long getSecondBeat() Get the time at which the second upcoming beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that beat, returns0xffffffff.- Returns:
- the number of milliseconds after which the beat after the next occurs
 
 - 
getNextBarpublic long getNextBar() Get the time at which the next bar would begin (the next downbeat would arrive), in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that bar, returns0xffffffff.- Returns:
- the number of milliseconds after which the next bar occurs
 
 - 
getFourthBeatpublic long getFourthBeat() Get the time at which the fourth beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that beat, returns0xffffffff.- Returns:
- the number of milliseconds at which the fourth upcoming beat occurs
 
 - 
getSecondBarpublic long getSecondBar() Get the time at which the second upcoming bar would begin (the second downbeat would arrive), in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that bar, returns0xffffffff.- Returns:
- the number of milliseconds after which the second upcoming bar occurs
 
 - 
getEighthBeatpublic long getEighthBeat() Get the time at which the eighth beat would arrive, in milliseconds, if the track were being played at normal speed (a pitch of +0%). If the track ends before that beat, returns0xffffffff.- Returns:
- the number of milliseconds at which the eighth upcoming beat occurs
 
 - 
isBeatWithinBarMeaningfulpublic boolean isBeatWithinBarMeaningful() Returns trueif this beat is coming from a device wheregetBeatWithinBar()can reasonably be expected to have musical significance, because it respects the way a track was configured within rekordbox.If the VirtualCdjis 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:
- isBeatWithinBarMeaningfulin class- DeviceUpdate
- Returns:
- true for status packets from players, false for status packets from mixers
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- DeviceUpdate
 
 - 
isTempoMasterpublic boolean isTempoMaster() Was this beat sent by the current tempo master?- Specified by:
- isTempoMasterin class- DeviceUpdate
- Returns:
- trueif the device that sent this beat is the master
- Throws:
- IllegalStateException- if the- VirtualCdjis not running
 
 - 
isSyncedpublic boolean isSynced() Was this beat sent by a device that is synced to the tempo master?- Specified by:
- isSyncedin class- DeviceUpdate
- Returns:
- trueif the device that sent this beat is synced
- Throws:
- IllegalStateException- if the- VirtualCdjis not running
 
 - 
getDeviceMasterIsBeingYieldedTopublic Integer getDeviceMasterIsBeingYieldedTo() Description copied from class:DeviceUpdateIf 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 benull.- Specified by:
- getDeviceMasterIsBeingYieldedToin class- DeviceUpdate
- Returns:
- the device number, if any, this update is yielding the tempo master role to
 
 - 
getEffectiveTempopublic double getEffectiveTempo() Description copied from class:DeviceUpdateGet the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.- Specified by:
- getEffectiveTempoin class- DeviceUpdate
- Returns:
- the beats per minute this device is reporting
 
 
- 
 
-