prolink

package module
v0.0.0-...-af6bbc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 13 Imported by: 0

README

Build Status Go Report Card GoDoc

This go library provides an API to the Pioneer PRO DJ LINK network. Providing various interactions and event subscribing.

Massive thank you to @brunchboy for his work on dysentery.

import "github.com/voxxit/prolink-go"

Basic usage

network, err := prolink.Connect()
network.AutoConfigure(5 * time.Second)

dm := network.DeviceManager()
st := network.CDJStatusMonitor()

added := func(dev *prolink.Device) {
    fmt.Printf("Connected: %s\n", dev)
}

removed := func(dev *prolink.Device) {
    fmt.Printf("Disconected: %s\n", dev)
}

dm.OnDeviceAdded("", prolink.DeviceListenerFunc(added))
dm.OnDeviceRemoved("", prolink.DeviceListenerFunc(removed))

statusChange := func(status *prolink.CDJStatus) {
    // Status packets come every 300ms, or faster depending on what is
    // happening on the CDJ. Do something with them.
}

st.AddStatusHandler(prolink.StatusHandlerFunc(statusChange));

Features

  • Listen for Pioneer PRO DJ LINK devices to connect and disconnect from the network using the DeviceManager. Currently active devices may also be queried.

  • Receive Player status details for each CDJ on the network. The status is reported as CDJStatus structs.

  • Query the Rekordbox remoteDB server present on both CDJs themselves and on the Rekordbox (PC / OSX / Android / iOS) software for track metadata using RemoteDB. This includes most metadata fields as well as (low quality) album artwork.

  • View the status of a DJ setup as a whole using the mixstatus.Processor. This allows you to determine the status of tracks in a mixing situation. Has the track been playing long enough to be considered 'now playing'?

Limitations, bugs, and missing functionality

  • [GH-1] Currently the software cannot be run on the same machine that is running Rekordbox. Rekordbox takes exclusive access to the socket used to communicate to the CDJs making it impossible to receive track status information

  • [GH-6] To read track metadata from the CDJs USB drives you may have no more than 3 CDJs. Having 4 CDJs on the network will only allow you to read track metadata through linked Rekordbox.

Documentation

Index

Constants

View Source
const VirtualCDJFirmware = "1.43"

VirtualCDJFirmware is a string indicating the firmware version reported with status packets.

View Source
const VirtualCDJName = "prolink-go"

VirtualCDJName is the name given to the Virtual CDJ device.

Variables

View Source
var ErrDeviceNotLinked = fmt.Errorf("The device is not linked on the network")

ErrDeviceNotLinked is returned by RemoteDB if the device being queried is not currently 'linked' on the network.

View Source
var Log = log15.New("module", "prolink")

Log specifies the logger that should be used for capturing information. May be disabled by replacing with the logrus.test.NullLogger.

Functions

This section is empty.

Types

type CDJStatus

type CDJStatus struct {
	PlayerID       DeviceID
	TrackID        uint32
	TrackDevice    DeviceID
	TrackSlot      TrackSlot
	TrackType      TrackType
	PlayState      PlayState
	IsOnAir        bool
	IsSync         bool
	IsMaster       bool
	TrackBPM       float32
	EffectivePitch float32
	SliderPitch    float32
	BeatInMeasure  uint8
	BeatsUntilCue  uint16
	Beat           uint32
	PacketNum      uint32
}

CDJStatus represents various details about the current state of the CDJ.

func (*CDJStatus) String

func (s *CDJStatus) String() string

func (*CDJStatus) TrackKey

func (s *CDJStatus) TrackKey() *TrackKey

TrackKey constructs a track query object from the CDJStatus. If no track is currently provided in the CDJStatus nil will be returned.

type CDJStatusMonitor

type CDJStatusMonitor struct {
	// contains filtered or unexported fields
}

CDJStatusMonitor provides an interface for watching for status updates to CDJ devices on the PRO DJ LINK network.

func (*CDJStatusMonitor) AddStatusHandler

func (sm *CDJStatusMonitor) AddStatusHandler(h StatusHandler)

AddStatusHandler registers a StatusHandler to be called when any CDJ on the PRO DJ LINK network reports its status.

type Device

type Device struct {
	Name       string
	ID         DeviceID
	Type       DeviceType
	MacAddr    net.HardwareAddr
	IP         net.IP
	LastActive time.Time
}

Device represents a device on the network.

func (*Device) String

func (d *Device) String() string

String returns a string representation of a device.

type DeviceID

type DeviceID byte

DeviceID represents the ID of the device. For CDJs this is the number displayed on screen.

type DeviceListener

type DeviceListener interface {
	OnChange(*Device)
}

A DeviceListener responds to devices being added and removed from the PRO DJ LINK network.

type DeviceListenerFunc

type DeviceListenerFunc func(*Device)

The DeviceListenerFunc is an adapter to allow a function to be used as a listener for device changes.

func (DeviceListenerFunc) OnChange

func (f DeviceListenerFunc) OnChange(d *Device)

OnChange implements the DeviceListener interface.

type DeviceManager

type DeviceManager struct {
	// contains filtered or unexported fields
}

DeviceManager provides functionality for watching the connection status of PRO DJ LINK devices on the network.

func (*DeviceManager) ActiveDeviceMap

func (m *DeviceManager) ActiveDeviceMap() map[DeviceID]*Device

ActiveDeviceMap returns a mapping of device IDs to their associated devices.

func (*DeviceManager) ActiveDevices

func (m *DeviceManager) ActiveDevices() []*Device

ActiveDevices returns a list of active devices on the PRO DJ LINK network.

func (*DeviceManager) OnDeviceAdded

func (m *DeviceManager) OnDeviceAdded(key string, fn DeviceListener)

OnDeviceAdded registers a listener that will be called when any PRO DJ LINK devices are added to the network. Provide a key if you wish to remove the handler later with RemoveListener by specifying the same key.

func (*DeviceManager) OnDeviceRemoved

func (m *DeviceManager) OnDeviceRemoved(key string, fn DeviceListener)

OnDeviceRemoved registers a listener that will be called when any PRO DJ LINK devices are removed from the network. Provide a key if you wish to remove the handler later with RemoveListener by specifying the same key.

func (*DeviceManager) RemoveListener

func (m *DeviceManager) RemoveListener(key string, fn DeviceListener)

RemoveListener removes a DeviceListener that may have been added by OnDeviceAdded or OnDeviceRemoved. Use the key you provided when adding the handler.

type DeviceType

type DeviceType byte

DeviceType represents the types of devices on the network.

const (
	DeviceTypeCDJ   DeviceType = 0x01
	DeviceTypeMixer DeviceType = 0x03
	DeviceTypeRB    DeviceType = 0x04
)

Defined device types.

func (DeviceType) String

func (d DeviceType) String() string

String returns a string representation of a device.

type Network

type Network struct {

	// TargetInterface specifies what network interface to broadcast announce
	// packets for the virtual CDJ on.
	//
	// This field should not be reconfigured, use SetInterface instead to
	// ensure the announce is correctly restarted on the new interface.
	TargetInterface *net.Interface

	// VirtualCDJID specifies the CDJ Device ID (Player ID) that should be used
	// when announcing the device.
	//
	// This field should not be reconfigured, use SetVirtualCDJID instead to
	// ensure the announce is correctly restarted on the new interface.
	VirtualCDJID DeviceID
	// contains filtered or unexported fields
}

Network is the primary API to the PRO DJ LINK network.

func Connect

func Connect() (*Network, error)

Connect connects to the Pioneer PRO DJ LINK network, returning the singleton Network object to interact with the connection.

Note that after connecting you must configure the virtual CDJ ID and network interface to announce the virtual CDJ on before all functionality of the prolink network will be available, specifically:

  • CDJs will not broadcast detailed payer information until they receive the announce packet and recognize the libraries virtual CDJ as being on the network.

- Any remote DB devices will not respond to metadata queries.

Both values may be autodetected or manually configured.

func (*Network) AutoConfigure

func (n *Network) AutoConfigure(wait time.Duration) error

AutoConfigure attempts to configure the two configuration parameters of the network.

  • Determine which interface to announce the Virtual CDJ over by finding the interface which has a matching net mask to the first CDJ detected on the network.
  • Determine the Virtual CDJ ID to assume by looking for the first unused CDJ ID on the network.

wait specifies how long to wait before checking what devices have appeared on the network to determine auto configuration values from.

func (*Network) CDJStatusMonitor

func (n *Network) CDJStatusMonitor() *CDJStatusMonitor

CDJStatusMonitor obtains the CDJStatusMonitor for the network.

func (*Network) DeviceManager

func (n *Network) DeviceManager() *DeviceManager

DeviceManager returns the DeviceManager for the network.

func (*Network) RemoteDB

func (n *Network) RemoteDB() *RemoteDB

RemoteDB returns the remote database client for the network.

func (*Network) SetInterface

func (n *Network) SetInterface(iface *net.Interface) error

SetInterface configures what network interface should be used when announcing the Virtual CDJ.

func (*Network) SetVirtualCDJID

func (n *Network) SetVirtualCDJID(id DeviceID) error

SetVirtualCDJID configures the CDJ ID (Player ID) that the prolink library should use to identify itself on the network. To correctly access metadata on the network this *must* be in the range from 1-4, and should *not* be a player ID that is already in use by a CDJ, otherwise the CDJ simply will not respond. This is a known issue 1

type PlayState

type PlayState byte

PlayState represents the play state of the CDJ.

const (
	PlayStateEmpty     PlayState = 0x00
	PlayStateLoading   PlayState = 0x02
	PlayStatePlaying   PlayState = 0x03
	PlayStateLooping   PlayState = 0x04
	PlayStatePaused    PlayState = 0x05
	PlayStateCued      PlayState = 0x06
	PlayStateCuing     PlayState = 0x07
	PlayStateSearching PlayState = 0x09
	PlayStateSpunDown  PlayState = 0x0e
	PlayStateEnded     PlayState = 0x11
)

Play state flags

func (PlayState) String

func (s PlayState) String() string

String returns the string representation of the play state.

type RemoteDB

type RemoteDB struct {
	// contains filtered or unexported fields
}

RemoteDB provides an interface to talking to the remote database.

func (*RemoteDB) GetTrack

func (rd *RemoteDB) GetTrack(q *TrackKey) (*Track, error)

GetTrack queries the remote db for track details given a track ID.

func (*RemoteDB) IsLinked

func (rd *RemoteDB) IsLinked(devID DeviceID) bool

IsLinked reports weather the DB server is available for the given device.

type StatusHandler

type StatusHandler interface {
	OnStatusUpdate(*CDJStatus)
}

A StatusHandler responds to status updates on a CDJ.

type StatusHandlerFunc

type StatusHandlerFunc func(*CDJStatus)

The StatusHandlerFunc is an adapter to allow a function to be used as a StatusHandler.

func (StatusHandlerFunc) OnStatusUpdate

func (f StatusHandlerFunc) OnStatusUpdate(s *CDJStatus)

OnStatusUpdate implements StatusHandler.

type Track

type Track struct {
	ID        uint32
	Path      string
	Title     string
	Artist    string
	Album     string
	Label     string
	Genre     string
	Comment   string
	Key       string
	Length    time.Duration
	DateAdded time.Time
	Artwork   []byte
}

Track contains track information retrieved from the remote database.

func (Track) String

func (t Track) String() string

type TrackKey

type TrackKey struct {
	TrackID  uint32
	Slot     TrackSlot
	Type     TrackType
	DeviceID DeviceID
	// contains filtered or unexported fields
}

TrackKey is used to make queries for track metadata.

func NewTrackKey

func NewTrackKey(id int, slot, trackType string, deviceID int) *TrackKey

NewTrackKey constructs a TrackKey from human friendly representation of track keys. Slot and Type are strings, device and trackID are ints.

type TrackSlot

type TrackSlot byte

TrackSlot represents the slot that a track is loaded from on the CDJ.

const (
	TrackSlotEmpty TrackSlot = 0x00
	TrackSlotCD    TrackSlot = 0x01
	TrackSlotSD    TrackSlot = 0x02
	TrackSlotUSB   TrackSlot = 0x03
	TrackSlotRB    TrackSlot = 0x04
)

Track load slot flags

func (TrackSlot) String

func (s TrackSlot) String() string

String returns the string representation of the track slot.

type TrackType

type TrackType byte

TrackType represents the type of track.

const (
	TrackTypeNone       TrackType = 0x00
	TrackTypeRB         TrackType = 0x01
	TrackTypeUnanalyzed TrackType = 0x02
	TrackTypeAudioCD    TrackType = 0x05
)

Track type flags

func (TrackType) String

func (t TrackType) String() string

String returns the string representation of the track type.

Directories

Path Synopsis
cmd
Package mixstatus provides functionality for determining when a track has changed in a mixing situation.
Package mixstatus provides functionality for determining when a track has changed in a mixing situation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL