public synchronized void setSendingStatus ( boolean send ) throws IOException { if ( isSendingStatus ( ) == send ) { return ; } if ( send ) { // Start sending status packets. ensureRunning ( ) ; if ( ( getDeviceNumber ( ) < 1 ) || ( getDeviceNumber ( ) > 4 ) ) { throw new IllegalStateException ( "Can only send status when using a standard player number, 1 through 4." ) ; } BeatFinder . getInstance ( ) . start ( ) ; BeatFinder . getInstance ( ) . addLifecycleListener ( beatFinderLifecycleListener ) ; final AtomicBoolean stillRunning = new AtomicBoolean ( true ) ; sendingStatus = stillRunning ; // Allow other threads to stop us when necessary. Thread sender = new Thread ( null , new Runnable ( ) { @ Override public void run ( ) { while ( stillRunning . get ( ) ) { sendStatus ( ) ; try { Thread . sleep ( getStatusInterval ( ) ) ; } catch ( InterruptedException e ) { logger . warn ( "beat-link VirtualCDJ status sender thread was interrupted; continuing" ) ; } } } } , "beat-link VirtualCdj status sender" ) ; sender . setDaemon ( true ) ; sender . start ( ) ; if ( isSynced ( ) ) { // If we are supposed to be synced, we need to respond to master beats and tempo changes. addMasterListener ( ourSyncMasterListener ) ; } if ( isPlaying ( ) ) { // Start the beat sender too, if we are supposed to be playing. beatSender . set ( new BeatSender ( metronome ) ) ; } } else { // Stop sending status packets, and responding to master beats and tempo changes if we were synced. BeatFinder . getInstance ( ) . removeLifecycleListener ( beatFinderLifecycleListener ) ; removeMasterListener ( ourSyncMasterListener ) ; sendingStatus . set ( false ) ; // Stop the status sending thread. sendingStatus = null ; // Indicate that we are no longer sending status. final BeatSender activeSender = beatSender . get ( ) ; // And stop the beat sender if we have one. if ( activeSender != null ) { activeSender . shutDown ( ) ; beatSender . set ( null ) ; } } }
Control whether the Virtual CDJ sends status packets to the other players . Most uses of Beat Link will not require this level of activity . However if you want to be able to take over the tempo master role and control the tempo and beat alignment of other players you will need to turn on this feature which also requires that you are using one of the standard player numbers 1 - 4 .