public class BeatFinder extends LifecycleParticipant
Watches for devices to report new beats by broadcasting beat packets on port 50001, and passes them on to registered listeners. When players are actively playing music, they send beat packets at the start of each beat which, in addition to announcing the start of the beat, provide information about where the beat falls within a measure of music (assuming that the track was properly configured in rekordbox, and is in 4/4 time), the current BPM of the track being played, and the current player pitch adjustment, from which the actual effective BPM can be calculated.
When players are stopped, they do not send beat packets, but the mixer continues sending them
at the last BPM reported by the master player, so it acts as the most reliable synchronization
source. The mixer does not make any effort to keep its notion of measures (down beats) consistent
with any player, however. So systems which want to stay in sync with measures as well as beats
will want to use the VirtualCdj to maintain awareness of which player is the master player.
| Modifier and Type | Field and Description |
|---|---|
static int |
BEAT_PORT
The port to which devices broadcast beat messages.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBeatListener(BeatListener listener)
Adds the specified beat listener to receive beat announcements when DJ Link devices broadcast
them on the network.
|
Set<BeatListener> |
getBeatListeners()
Get the set of beat listeners that are currently registered.
|
static BeatFinder |
getInstance()
Get the singleton instance of this class.
|
boolean |
isRunning()
Check whether we are presently listening for beat packets.
|
void |
removeBeatListener(BeatListener listener)
Removes the specified beat listener so that it no longer receives beat announcements when
DJ Link devices broadcast them to the network.
|
void |
start()
Start listening for beat announcements.
|
void |
stop()
Stop listening for beats.
|
String |
toString() |
addLifecycleListener, deliverLifecycleAnnouncement, ensureRunning, getLifecycleListeners, removeLifecycleListenerpublic static final int BEAT_PORT
public boolean isRunning()
isRunning in class LifecycleParticipanttrue if our socket is open and monitoring for DJ Link beat packets on the networkpublic void start()
throws SocketException
SocketException - if the socket to listen on port 50001 cannot be createdpublic void stop()
public void addBeatListener(BeatListener listener)
Adds the specified beat listener to receive beat announcements when DJ Link devices broadcast
them on the network. If listener is null or already present in the list
of registered listeners, no exception is thrown and no action is performed.
To reduce latency, beat announcements are delivered to listeners directly on the thread that is receiving them
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 beat announcements will back up.
If you want to perform lengthy processing of any sort, do so on another thread.
listener - the beat listener to addpublic void removeBeatListener(BeatListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the beat listener to removepublic Set<BeatListener> getBeatListeners()
public static BeatFinder getInstance()
Copyright © 2016–2018 Deep Symmetry, LLC. All rights reserved.