mixstatus

package
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: 4 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// AllowedInterruptBeats configures how many beats a track may not be live
	// or playing for it to still be considered active.
	AllowedInterruptBeats int

	// BeatsUntilReported configures how many beats the track must consecutively
	// be playing for (since the beat it was cued at) until the track is
	// considered to be active.
	BeatsUntilReported int

	// TimeBetweenSets specifies the duration that no tracks must be on air.
	// This can be thought of as how long 'air silence' is reasonable in a set
	// before a separate one has begun.
	TimeBetweenSets time.Duration
}

Config specifies configuration for the Handler.

type Event

type Event string

An Event is a string key for status change events

const (
	SetStarted Event = "set_started"
	SetEnded   Event = "set_ended"

	NowPlaying Event = "now_playing"
	Stopped    Event = "stopped"
	ComingSoon Event = "coming_soon"
)

Event constants

type Handler

type Handler interface {
	OnMixStatus(Event, *prolink.CDJStatus)
}

Handler is a interface that may be implemented to receive mix status events This includes the CDJStatus object that triggered the change.

type HandlerFunc

type HandlerFunc func(Event, *prolink.CDJStatus)

HandlerFunc is an adapter to implement the handler.

func (HandlerFunc) OnMixStatus

func (f HandlerFunc) OnMixStatus(e Event, s *prolink.CDJStatus)

OnMixStatus implements the Handler interface.

type Processor

type Processor struct {
	Config Config
	// contains filtered or unexported fields
}

Processor is a configurable object which implements the prolink.StatusListener interface to more accurately detect when a track has changed in a mixing situation.

The following track statuses are reported:

- NowPlaying: The track is considered playing and on air to the audience. - Stopped: The track was stopped / paused. - ComingSoon: A new track has been loaded.

Additionally the following non-track status are reported:

- SetStarted: The first track has begun playing. - SetEnded: The TimeBetweenSets has passed since any tracks were live.

See Config for configuration options.

Config options may be changed after the processor has been constructed and is actively receiving status updates.

Track changes are detected based on a number of rules:

  • The track that has been in the play state with the CDJ in the "on air" state for the longest period of time (allowing for a configurable length of interruption with AllowedInterruptBeats) is considered to be the active track that incoming tracks will be compared against.
  • A incoming track will immediately be reported as NowPlaying if it is on air, playing, and the last active track has been cued.
  • A incoming track will be reported as NowPlaying if the active track has not been on air or has not been playing for the configured AllowedInterruptBeats.
  • A incoming track will be reported as NowPlaying if it has played consecutively (with AllowedInterruptBeats honored for the incoming track) for the configured BeatsUntilReported.
  • A track will be reported as Stopped when it was NowPlaying and was stopped (cued, reached the end of the track, or a new track was loaded.

- A track will be reported as ComingSoon when a new track is selected.

func NewProcessor

func NewProcessor(config Config, handler Handler) *Processor

NewProcessor constructs a new Processor to watch for track changes

func (*Processor) OnStatusUpdate

func (p *Processor) OnStatusUpdate(s *prolink.CDJStatus)

OnStatusUpdate implements the prolink.StatusHandler interface

func (*Processor) SetHandler

func (p *Processor) SetHandler(handler Handler)

SetHandler sets the handler type to be used.

Jump to

Keyboard shortcuts

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