public class VirtualCdj extends Object
BeatFinder reports, allowing you to keep track of which player is the tempo master, how many beats of
a track have been played, how close a player is getting to its next cue point, and more.| Modifier and Type | Field and Description |
|---|---|
static int |
UPDATE_PORT
The port to which other devices will send status update messages.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addMasterListener(MasterListener listener)
Adds the specified master listener to receive device updates when there are changes related
to the tempo master.
|
static void |
addUpdateListener(DeviceUpdateListener listener)
Adds the specified device update listener to receive device updates whenever they come in.
|
static int |
getAnnounceInterval()
Get the interval, in milliseconds, at which we broadcast presence announcements on the network to pose as
a virtual CDJ.
|
static InetAddress |
getBroadcastAddress()
Return the broadcast address used to reach the DJ Link network.
|
static String |
getDeviceName()
Get the name to be used in announcing our presence on the network.
|
static byte |
getDeviceNumber()
Get the device number that is used when sending presence announcements on the network to pose as a virtual CDJ.
|
static Set<DeviceUpdate> |
getLatestStatus()
Get the most recent status we have seen from all devices that are recent enough to be considered still
active on the network.
|
static DeviceUpdate |
getLatestStatusFor(DeviceAnnouncement device)
Look up the most recent status we have seen for a device, given its device announcement packet as returned
by
DeviceFinder.currentDevices(). |
static DeviceUpdate |
getLatestStatusFor(DeviceUpdate device)
Look up the most recent status we have seen for a device, given another update from it, which might be a
beat packet containing far less information.
|
static DeviceUpdate |
getLatestStatusFor(int deviceNumber)
Look up the most recent status we have seen for a device from a device identifying itself
with the specified device number, if any.
|
static InetAddress |
getLocalAddress()
Return the address being used by the virtual CDJ to send its own presence announcement broadcasts,
so they can be filtered out by the
DeviceFinder. |
static Set<MasterListener> |
getMasterListeners()
Get the set of master listeners that are currently registered.
|
static double |
getMasterTempo()
Get the current master tempo.
|
static double |
getTempoEpsilon()
Find out how large a tempo change is required before we consider it to be a real difference.
|
static DeviceUpdate |
getTempoMaster()
Check which device is the current tempo master, returning the
DeviceUpdate packet in which it
reported itself to be master. |
static Set<DeviceUpdateListener> |
getUpdateListeners()
Get the set of device update listeners that are currently registered.
|
static boolean |
isActive()
Check whether we are presently posing as a virtual CDJ and receiving device status updates.
|
static void |
removeMasterListener(MasterListener listener)
Removes the specified master listener so that it no longer receives device updates when
there are changes related to the tempo master.
|
static void |
removeUpdateListener(DeviceUpdateListener listener)
Removes the specified device update listener so it no longer receives device updates when they come in.
|
static void |
setAnnounceInterval(int interval)
Set the interval, in milliseconds, at which we broadcast presence announcements on the network to pose as
a virtual CDJ.
|
static void |
setDeviceName(String name)
Set the name to be used in announcing our presence on the network.
|
static void |
setDeviceNumber(byte number)
Set the device number to be used when sending presence announcements on the network to pose as a virtual CDJ.
|
static void |
setTempoEpsilon(double epsilon)
Set how large a tempo change is required before we consider it to be a real difference.
|
static boolean |
start()
Start announcing ourselves and listening for status packets.
|
static void |
stop()
Stop announcing ourselves and listening for status updates.
|
public static final int UPDATE_PORT
public static boolean isActive()
public static InetAddress getLocalAddress()
DeviceFinder.IllegalStateException - if the VirtualCdj is not activepublic static InetAddress getBroadcastAddress()
IllegalStateException - if the VirtualCdj is not activepublic static byte getDeviceNumber()
public static void setDeviceNumber(byte number)
number - the virtual player numberpublic static int getAnnounceInterval()
public static void setAnnounceInterval(int interval)
interval - the announcement intervalIllegalArgumentException - if interval is not between 200 and 2000public static String getDeviceName()
public static void setDeviceName(String name)
name - the device name to report in our presence announcement packets.public static DeviceUpdate getTempoMaster()
DeviceUpdate packet in which it
reported itself to be master. If there is no current tempo master returns null.IllegalStateException - if the VirtualCdj is not activepublic static double getTempoEpsilon()
public static void setTempoEpsilon(double epsilon)
epsilon - the BPM fraction that will trigger a tempo change updatepublic static double getMasterTempo()
IllegalStateException - if the VirtualCdj is not activepublic static boolean start()
throws SocketException
DeviceFinder to be active in order to find out how to communicate with other devices, so will start
that if it is not already.VirtualCdj, or it was already running.SocketException - if the socket to listen on port 50002 cannot be createdpublic static void stop()
public static Set<DeviceUpdate> getLatestStatus()
IllegalStateException - if the VirtualCdj is not activepublic static DeviceUpdate getLatestStatusFor(DeviceUpdate device)
device - the update identifying the device for which current status information is desiredIllegalStateException - if the VirtualCdj is not activepublic static DeviceUpdate getLatestStatusFor(DeviceAnnouncement device)
DeviceFinder.currentDevices().device - the announcement identifying the device for which current status information is desiredIllegalStateException - if the VirtualCdj is not activepublic static DeviceUpdate getLatestStatusFor(int deviceNumber)
deviceNumber - the device number of interestIllegalStateException - if the VirtualCdj is not activepublic static void addMasterListener(MasterListener listener)
listener is null or already present in the list
of registered listeners, no exception is thrown and no action is performed.
To reduce latency, tempo master updates are delivered to listeners directly on the thread that is receiving them
from the network, so if you want to interact with user interface objects in listener methods, you need to use
javax.swing.SwingUtilities.invokeLater(Runnable)
to do so on the Event Dispatch Thread.
Even if you are not interacting with user interface objects, any code in the listener method
must finish quickly, or it will add latency for other listeners, and master updates will back up.
If you want to perform lengthy processing of any sort, do so on another thread.
listener - the master listener to addpublic static void removeMasterListener(MasterListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the master listener to removepublic static Set<MasterListener> getMasterListeners()
public static void addUpdateListener(DeviceUpdateListener listener)
listener is null or already present in the list
of registered listeners, no exception is thrown and no action is performed.
To reduce latency, device updates are delivered to listeners directly on the thread that is receiving them
from the network, so if you want to interact with user interface objects in listener methods, you need to use
javax.swing.SwingUtilities.invokeLater(Runnable)
to do so on the Event Dispatch Thread.
Even if you are not interacting with user interface objects, any code in the listener method
must finish quickly, or it will add latency for other listeners, and device updates will back up.
If you want to perform lengthy processing of any sort, do so on another thread.
listener - the device update listener to addpublic static void removeUpdateListener(DeviceUpdateListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the device update listener to removepublic static Set<DeviceUpdateListener> getUpdateListeners()
Copyright © 2016 Deep Symmetry, LLC. All rights reserved.