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.
VirtualCdj is sending status packets, it needs to be notified about these
so it can properly update its sync and on-air state if the mixer tells it to, so it will ensure the
BeatFinder is running whenever it is sending status updates.| 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.
|
void |
addFaderStartListener(FaderStartListener listener)
Adds the specified fader start listener to receive fader start commands when the mixer broadcasts
them on the network.
|
void |
addMasterHandoffListener(MasterHandoffListener listener)
Adds the specified master handoff listener to receive tempo master handoff commands when DJ Link devices send
them to Beat Link.
|
void |
addOnAirListener(OnAirListener listener)
Adds the specified on-air listener to receive channel on-air updates when the mixer broadcasts
them on the network.
|
void |
addSyncListener(SyncListener listener)
Adds the specified sync command listener to receive sync commands when DJ Link devices send
them to Beat Link.
|
Set<BeatListener> |
getBeatListeners()
Get the set of beat listeners that are currently registered.
|
Set<FaderStartListener> |
getFaderStartListeners()
Get the set of fader start listeners that are currently registered.
|
static BeatFinder |
getInstance()
Get the singleton instance of this class.
|
Set<MasterHandoffListener> |
getMasterHandoffListeners()
Get the set of master handoff command listeners that are currently registered.
|
Set<OnAirListener> |
getOnAirListeners()
Get the set of on-air listeners that are currently registered.
|
Set<SyncListener> |
getSyncListeners()
Get the set of sync command listeners that are currently registered.
|
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 |
removeFaderStartListener(FaderStartListener listener)
Removes the specified fader start listener so that it no longer receives fader start commands when
the mixer broadcasts them to the network.
|
void |
removeMasterHandoffListener(MasterHandoffListener listener)
Removes the specified master handoff listener so that it no longer receives tempo master handoff commands when
DJ Link devices send them to Beat Link.
|
void |
removeOnAirListener(OnAirListener listener)
Removes the specified on-air listener so that it no longer receives channel on-air updates when
the mixer broadcasts them to the network.
|
void |
removeSyncListener(SyncListener listener)
Removes the specified sync listener so that it no longer receives sync commands when
DJ Link devices send them to Beat Link.
|
void |
start()
Start listening for beat announcements and sync commands.
|
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 void addSyncListener(SyncListener listener)
Adds the specified sync command listener to receive sync commands when DJ Link devices send
them to Beat Link. 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, sync commands 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 sync listener to addpublic void removeSyncListener(SyncListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the sync listener to removepublic Set<SyncListener> getSyncListeners()
public void addMasterHandoffListener(MasterHandoffListener listener)
Adds the specified master handoff listener to receive tempo master handoff commands when DJ Link devices send
them to Beat Link. 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, handoff commands 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 tempo master handoff listener to addpublic void removeMasterHandoffListener(MasterHandoffListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the tempo master handoff listener to removepublic Set<MasterHandoffListener> getMasterHandoffListeners()
public void addOnAirListener(OnAirListener listener)
Adds the specified on-air listener to receive channel on-air updates when the mixer broadcasts
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, on-air updates 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 on-air listener to addpublic void removeOnAirListener(OnAirListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the on-air listener to removepublic Set<OnAirListener> getOnAirListeners()
public void addFaderStartListener(FaderStartListener listener)
Adds the specified fader start listener to receive fader start commands when the mixer broadcasts
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, fader start commands 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 fader start listener to addpublic void removeFaderStartListener(FaderStartListener listener)
listener is null or not present
in the list of registered listeners, no exception is thrown and no action is performed.listener - the fader start listener to removepublic Set<FaderStartListener> getFaderStartListeners()
public static BeatFinder getInstance()
Copyright © 2016–2019 Deep Symmetry, LLC. All rights reserved.