- java.lang.Object
-
- org.deepsymmetry.beatlink.DeviceUpdate
-
- Direct Known Subclasses:
Beat,CdjStatus,MixerStatus,PrecisePosition
@API(status=STABLE) public abstract class DeviceUpdate extends Object
Represents a device status update seen on a DJ Link network.- Author:
- James Elliott
-
-
Field Summary
Fields Modifier and Type Field Description static intDEVICE_NUMBER_OFFSETThe offset at which the device number that sent this packet can be found.booleanisFromOpusQuadIndicates whether this device update came from an Opus Quad, which behaves very differently from true Pro DJ Link hardware.
-
Constructor Summary
Constructors Constructor Description DeviceUpdate(DatagramPacket packet, String name, int length)Constructor sets all the immutable interpreted fields based on the packet content.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description InetAddressgetAddress()Get the address of the device from which this update was seen.abstract intgetBeatWithinBar()Get the position within a measure of music at which the most recent beat fell (a value from 1 to 4, where 1 represents the downbeat).abstract intgetBpm()Get the playback BPM at the time of the update.abstract 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.StringgetDeviceName()Get the name reported by the device sending the update.intgetDeviceNumber()Get the player/device number reporting the update.abstract doublegetEffectiveTempo()Get the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.byte[]getPacketBytes()Get the raw data bytes of the device update packet.abstract intgetPitch()Get the device pitch at the time of the update.longgetTimestamp()Get the timestamp recording when the device update was received.abstract booleanisBeatWithinBarMeaningful()Returnstrueif this update 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.booleanisPreNexusCdj()Check whether this packet seems to have come from a CDJ older than the original Nexus series (which means, for example, that beat numbers will not be available, so theTimeFindercan't work with it).abstract booleanisSynced()Is this device reporting itself synced to the current tempo master?abstract booleanisTempoMaster()Is this device reporting itself to be the current tempo master?StringtoString()
-
-
-
Field Detail
-
DEVICE_NUMBER_OFFSET
public static final int DEVICE_NUMBER_OFFSET
The offset at which the device number that sent this packet can be found.- See Also:
- Constant Field Values
-
isFromOpusQuad
@API(status=EXPERIMENTAL) public final boolean isFromOpusQuad
Indicates whether this device update came from an Opus Quad, which behaves very differently from true Pro DJ Link hardware.
-
-
Constructor Detail
-
DeviceUpdate
@API(status=STABLE) public DeviceUpdate(DatagramPacket packet, String name, int length)
Constructor sets all the immutable interpreted fields based on the packet content.- Parameters:
packet- the device update packet that was receivedname- the type of packet that is being processed, in case a problem needs to be reportedlength- the expected length of the packet
-
-
Method Detail
-
getAddress
@API(status=STABLE) public InetAddress getAddress()
Get the address of the device from which this update was seen.- Returns:
- the network address from which the update was sent
-
getTimestamp
@API(status=STABLE) public long getTimestamp()
Get the timestamp recording when the device update was received.- Returns:
- the nanosecond timestamp at which we received this update
-
getDeviceName
@API(status=STABLE) public String getDeviceName()
Get the name reported by the device sending the update.- Returns:
- the device name
-
isPreNexusCdj
@API(status=STABLE) public boolean isPreNexusCdj()
Check whether this packet seems to have come from a CDJ older than the original Nexus series (which means, for example, that beat numbers will not be available, so theTimeFindercan't work with it).- Returns:
trueif the device name starts with "CDJ" and ends with "0".
-
getDeviceNumber
@API(status=STABLE) public int getDeviceNumber()
Get the player/device number reporting the update.- Returns:
- the player number found in the update packet
-
getPacketBytes
@API(status=STABLE) public byte[] getPacketBytes()
Get the raw data bytes of the device update packet.- Returns:
- the data sent by the device to update its status
-
getPitch
public abstract int getPitch()
Get the device pitch at the time of the update. 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). Mixers always report a pitch of +0%, so tempo changes are purely reflected in the BPM value.- Returns:
- the raw effective device pitch at the time of the update
-
getBpm
public abstract int getBpm()
Get the playback BPM at the time of the update. This is an integer representing the BPM times 100, so a track running at 120.5 BPM would be represented by the value 12050. Mixers always report a pitch of +0%, so tempo changes are purely reflected in the BPM value.When the CDJ has just started up and no track has been loaded, it will report a BPM of 65535.
- Returns:
- the track BPM to two decimal places multiplied by 100
-
isTempoMaster
public abstract boolean isTempoMaster()
Is this device reporting itself to be the current tempo master?- Returns:
trueif the device that sent this update is the master- Throws:
IllegalStateException- if called with aBeatand theVirtualCdjis not running, since that is needed to find the latest status update from the device which sent the beat packet.
-
isSynced
public abstract boolean isSynced()
Is this device reporting itself synced to the current tempo master?- Returns:
trueif the device that sent this update is synced- Throws:
IllegalStateException- if called with aBeatand theVirtualCdjis not running, since that is needed to find the latest status update from the device which sent the beat packet.
-
getDeviceMasterIsBeingYieldedTo
public abstract Integer getDeviceMasterIsBeingYieldedTo()
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.- Returns:
- the device number, if any, this update is yielding the tempo master role to
-
getEffectiveTempo
public abstract double getEffectiveTempo()
Get the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.- Returns:
- the beats per minute this device is reporting
-
getBeatWithinBar
public abstract int getBeatWithinBar()
Get the position within a measure of music at which the most recent beat fell (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. The usefulness of this value can be checked withisBeatWithinBarMeaningful().- Returns:
- the beat number within the current measure of music
-
isBeatWithinBarMeaningful
public abstract boolean isBeatWithinBarMeaningful()
Returnstrueif this update 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.- Returns:
- true for status packets from players, false for status packets from mixers
-
-