← Back

ofxBeatLink

github.com/daitomanabe/ofxBeatLink · @daitomanabe
OF 0.12 Audio Web/Networking

Addon for the Pioneer DJ Link protocol, detecting CDJ, XDJ and DJM devices on the network and receiving beat information.

0 1 Last commit 9mo ago Created 9mo ago

Forks

Forks pushed to more recently than daitomanabe/ofxBeatLink itself, plus any admin-confirmed fork with commits of its own — worth checking if you're hitting issues with the original.

yutaokuyama/ofxBeatLink by @yutaokuyama · ★ 0 · pushed 8mo ago

README

ofxBeatLink



openFrameworks addon for Pioneer DJ Link protocol. Wraps beat-link-cpp library.

Features



Requirements



Installation



1. Clone to your openFrameworks addons folder:
cd of_v0.12.x/addons
git clone --recursive https://github.com/daitomanabe/ofxBeatLink.git


2. If you cloned without --recursive, initialize submodules:
cd ofxBeatLink
git submodule update --init --recursive


Usage



Basic Mode (Passive Listener)



#include "ofxBeatLink.h"

class ofApp : public ofBaseApp {
    ofxBeatLink beatLink;

    void setup() {
        ofAddListener(beatLink.beatEvent, this, &ofApp::onBeat);
        ofAddListener(beatLink.deviceFoundEvent, this, &ofApp::onDeviceFound);
        beatLink.start();
    }

    void update() {
        beatLink.update();  // Required: dispatch events on main thread
    }

    void exit() {
        ofRemoveListener(beatLink.beatEvent, this, &ofApp::onBeat);
        ofRemoveListener(beatLink.deviceFoundEvent, this, &ofApp::onDeviceFound);
        beatLink.stop();
    }

    void onBeat(ofxBeatLinkBeat& beat) {
        cout << "BPM: " << beat.bpm << " Beat: " << beat.beatWithinBar << "/4" << endl;
    }

    void onDeviceFound(ofxBeatLinkDevice& device) {
        cout << "Found: " << device.deviceName << endl;
    }
};


VirtualCdj Mode (Full Status)



VirtualCdj mode makes your application appear as a CDJ on the network, enabling detailed status updates:

#include "ofxBeatLink.h"

class ofApp : public ofBaseApp {
    ofxBeatLink beatLink;

    void setup() {
        // Register for detailed status updates
        ofAddListener(beatLink.deviceUpdateEvent, this, &ofApp::onDeviceUpdate);
        ofAddListener(beatLink.masterChangedEvent, this, &ofApp::onMasterChanged);

        beatLink.start();
        beatLink.startVirtualCdj();  // Enables detailed status
    }

    void update() {
        beatLink.update();
    }

    void exit() {
        beatLink.stopVirtualCdj();
        beatLink.stop();
    }

    void onDeviceUpdate(ofxBeatLinkCdjStatus& status) {
        cout << status.deviceName
             << " Playing:" << status.isPlaying
             << " Master:" << status.isMaster
             << " Sync:" << status.isSynced
             << " OnAir:" << status.isOnAir << endl;
    }

    void onMasterChanged(ofxBeatLinkCdjStatus& status) {
        cout << status.deviceName << " is now tempo master" << endl;
    }
};


API Reference



ofxBeatLink



Main class for DJ Link communication.

Basic Methods



MethodDescription
start()Start listening on ports 50000/50001
stop()Stop listening
update()Call in ofApp::update() to dispatch events
isRunning()Check if listening
getCurrentDevices()Get list of detected devices
getLatestBeat(int deviceNumber)Get latest beat from specific device
getLatestBeat()Get latest beat from any device

VirtualCdj Methods



MethodDescription
startVirtualCdj(int deviceNumber = 0)Start as virtual CDJ (0 = auto-assign)
stopVirtualCdj()Stop VirtualCdj
isVirtualCdjRunning()Check if VirtualCdj is running
getVirtualCdjDeviceNumber()Get assigned device number
setVirtualCdjDeviceName(string)Set device name (before start)
getTempoMaster()Get current tempo master status
getMasterTempo()Get master tempo BPM
getCurrentStatuses()Get all device statuses
getStatusFor(int deviceNumber)Get status for specific device

Events



Basic Events



EventTypeDescription
beatEventofxBeatLinkBeatFired on each beat
deviceFoundEventofxBeatLinkDeviceFired when device appears
deviceLostEventofxBeatLinkDeviceFired when device disappears

VirtualCdj Events



EventTypeDescription
deviceUpdateEventofxBeatLinkCdjStatusDetailed status updates
masterChangedEventofxBeatLinkCdjStatusTempo master changed

ofxBeatLinkBeat



FieldTypeDescription
deviceNumberintDevice number (1-4)
deviceNamestringDevice name (e.g., "CDJ-3000")
bpmdoubleEffective BPM (with pitch)
trackBpmdoubleOriginal track BPM
beatWithinBarintPosition in bar (1-4, 1=downbeat)
pitchPercentdoublePitch adjustment %
nextBeatMsint64_tms until next beat
nextBarMsint64_tms until next bar

ofxBeatLinkDevice



FieldTypeDescription
deviceNumberintDevice number
deviceNamestringDevice name
ipAddressstringIP address
macAddressstringMAC address
isOpusQuadboolIs Opus Quad
isXdjAzboolIs XDJ-AZ

ofxBeatLinkCdjStatus



Detailed device status (requires VirtualCdj mode).

FieldTypeDescription
deviceNumberintDevice number
deviceNamestringDevice name
ipAddressstringIP address
isPlayingboolCurrently playing
isTrackLoadedboolTrack is loaded
isAtCueboolPaused at cue point
isPlayingForwardsboolPlaying forward
isPlayingBackwardsboolPlaying backward
isMasterboolIs tempo master
isSyncedboolSync enabled
isOnAirboolFader is up (on air)
isBpmOnlySyncedboolBPM-only sync
bpmdoubleTrack BPM
effectiveBpmdoubleBPM with pitch
pitchPercentdoublePitch adjustment %
beatWithinBarintPosition in bar (1-4)
beatNumberintBeat position in track
trackSourcePlayerintSource player number
rekordboxIdintrekordbox track ID
trackNumberintTrack number
timestampuint64_tUpdate timestamp

Examples



DJ Link Examples

rekordbox Database Examples (crate-digger-cpp)

Troubleshooting



Port already in use



Close rekordbox or other DJ Link applications using ports 50000-50002.

Check with:
lsof -i :50000


No devices found



VirtualCdj fails to start



License



EPL-2.0 (same as beat-link-cpp)

Credits



Get this addon

HTTPS
SSH