Package org.deepsymmetry.beatlink
Class MixerStatus
- java.lang.Object
-
- org.deepsymmetry.beatlink.DeviceUpdate
-
- org.deepsymmetry.beatlink.MixerStatus
-
public class MixerStatus extends DeviceUpdate
Represents a status update sent by a mixer on a DJ Link network.- Author:
- James Elliott
-
-
Field Summary
Fields Modifier and Type Field Description static int
MASTER_HAND_OFF
The byte within a status packet which indicates that the device is in the process of handing off the tempo master role to anther device, labeled Mh in the Packet Analysis document.static int
MINIMUM_PACKET_SIZE
The smallest packet size from which we can be constructed.static int
STATUS_FLAGS
The byte within the status packet which contains useful status information, labeled F in the Packet Analysis document.
-
Constructor Summary
Constructors Constructor Description MixerStatus(DatagramPacket packet)
Constructor sets all the immutable interpreted fields based on the packet content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBeatWithinBar()
Get the position within a measure of music at which the most recent beat occurred (a value from 1 to 4, where 1 represents the down beat).int
getBpm()
Get the BPM at the time of the update.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
.double
getEffectiveTempo()
Get the effective tempo reflected by this update, which reflects both its track BPM and pitch as needed.int
getPitch()
Get the device pitch at the time of the update.boolean
isBeatWithinBarMeaningful()
Returnstrue
if 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.boolean
isSynced()
Was the mixer in Sync mode when this update was sent? Unless someone has been sending sync control packets using a package like Beat Link, this will generally returntrue
.boolean
isTempoMaster()
Is this mixer reporting itself to be the current tempo master?String
toString()
-
Methods inherited from class org.deepsymmetry.beatlink.DeviceUpdate
getAddress, getDeviceName, getDeviceNumber, getPacketBytes, getTimestamp, isPreNexusCdj
-
-
-
-
Field Detail
-
STATUS_FLAGS
public static final int STATUS_FLAGS
The byte within the status packet which contains useful status information, labeled F in the Packet Analysis document.- See Also:
- Constant Field Values
-
MASTER_HAND_OFF
public static final int MASTER_HAND_OFF
The byte within a status packet which indicates that the device is in the process of handing off the tempo master role to anther device, labeled Mh in the Packet Analysis document. Normally it holds the value 0xff, but during a tempo master hand-off, it holds the device number of the incoming tempo master, until that device asserts the master state, after which this device will stop doing so.- See Also:
- Constant Field Values
-
MINIMUM_PACKET_SIZE
public static final int MINIMUM_PACKET_SIZE
The smallest packet size from which we can be constructed. Anything less than this and we are missing crucial information.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MixerStatus
public MixerStatus(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
-
getBpm
public int getBpm()
Get the BPM at the time of the update. This is an integer representing the BPM times 100, so 120.5 BPM would be represented by the value 12050.- Specified by:
getBpm
in classDeviceUpdate
- Returns:
- the current BPM to two decimal places multiplied by 100
-
getBeatWithinBar
public int getBeatWithinBar()
Get the position within a measure of music at which the most recent beat occurred (a value from 1 to 4, where 1 represents the down beat). The mixer makes no effort to synchronize down beats with players, however, so this value is of little use.- Specified by:
getBeatWithinBar
in classDeviceUpdate
- Returns:
- the beat number within the current measure of music, as far as the mixer knows
-
isBeatWithinBarMeaningful
public boolean isBeatWithinBarMeaningful()
Returnstrue
if 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.- Specified by:
isBeatWithinBarMeaningful
in classDeviceUpdate
- Returns:
- false because mixers make no effort to line up their beats with rekordbox-identified measures
-
getPitch
public int getPitch()
Description copied from class:DeviceUpdate
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.- Specified by:
getPitch
in classDeviceUpdate
- Returns:
- the raw effective device pitch at the time of the update
-
isTempoMaster
public boolean isTempoMaster()
Is this mixer reporting itself to be the current tempo master?- Specified by:
isTempoMaster
in classDeviceUpdate
- Returns:
true
if the mixer that sent this update is the master
-
isSynced
public boolean isSynced()
Was the mixer in Sync mode when this update was sent? Unless someone has been sending sync control packets using a package like Beat Link, this will generally returntrue
.- Specified by:
isSynced
in classDeviceUpdate
- Returns:
- true if the sync flag was set
-
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 benull
.- Specified by:
getDeviceMasterIsBeingYieldedTo
in classDeviceUpdate
- 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 classDeviceUpdate
- Returns:
- the beats per minute this device is reporting
-
toString
public String toString()
- Overrides:
toString
in classDeviceUpdate
-
-