playback

package
v0.0.0-...-c66ceb2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProcessName defines the name of the playback process
	ProcessName = "playback"
)

Variables

View Source
var (
	ErrCancelled                = errors.New("playback cancelled")
	ErrNoSongIDOrSetListIDGiven = errors.New("no songID or setListID given")
)

Player errors

Functions

func CalcRenderSpeed

func CalcRenderSpeed(bc *cntl.BarChange) time.Duration

CalcRenderSpeed calculates the render speed of a BarChange to a time.Duration

func EnsureDefaultConfig

func EnsureDefaultConfig(storage storage) error

EnsureDefaultConfig ensures that the default configuration exists in given storage

func Play

func Play(ctx context.Context, logger logging.Logger, writers []TransportWriter, commands []cntl.Command) error

Play plays a given slice of commands and send it to the given writers

func ToPlayable

func ToPlayable(bp cntl.BarParams, dmxCommands []cntl.DMXCommands) []cntl.Command

ToPlayable takes a slice of DMXCommands and combines it with the given BarParams to a playable slice of Commands

Types

type Config

type Config struct {
	Waiters struct {
		Audio struct {
			Enabled   bool    `json:"enabled"`
			Threshold float32 `json:"threshold"`
		} `json:"audio"`
	} `json:"waiters"`
	TransportWriters struct {
		ArtNet struct {
			Enabled bool `json:"enabled"`
		} `json:"artNet"`
		Visualizer struct {
			Enabled bool `json:"enabled"`
		} `json:"visualizer"`
		MIDI struct {
			Enabled        bool `json:"enabled"`
			OutputDeviceID int8 `json:"outputDeviceId"`
		} `json:"midi"`
	} `json:"transportWriters"`
}

Config stores the information on which waiters and/or transport writers are enabled and what their config is

type Params

type Params struct {
	Song struct {
		ID string `json:"id"`
	} `json:"song"`
	SetList struct {
		ID string `json:"id"`
	} `json:"setList"`
}

Params specifies how to run a playback

type Player

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

Player plays various things from a given data store, for example songs or a whole SetList.

func NewPlayer

func NewPlayer(logger logging.Logger, ds *cntl.DataStore, writers []TransportWriter, waiters []Waiter) *Player

NewPlayer returns a new Player instance

func (*Player) PlaySetList

func (p *Player) PlaySetList(ctx context.Context, setListID string) error

PlaySetList plays a full SetList

func (*Player) PlaySong

func (p *Player) PlaySong(ctx context.Context, songID string) error

PlaySong plays a full song

type Process

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

Process handles the playback of a single song

func NewProcess

func NewProcess(loader loader, storage storage, controller artnet.Controller, visualizer *visualizer.Server) *Process

NewProcess returns a new playback process instance

func (*Process) Blocking

func (p *Process) Blocking() bool

Blocking returns true if calling Start() is a blocking operation and the process is stopped after start returned

func (*Process) GetParams

func (p *Process) GetParams() Params

GetParams returns the params the process is currently running with

func (*Process) SetLogger

func (p *Process) SetLogger(logger logging.Logger)

SetLogger sets the logger for the process

func (*Process) SetParams

func (p *Process) SetParams(params Params)

SetParams tells the playback process whether to playback a song or set list and the corresponding ID

func (*Process) Start

func (p *Process) Start(ctx context.Context) error

Start the process, i.e. start the player with all the collected information

func (*Process) Stop

func (p *Process) Stop() error

Stop the process, i.e. cancel the playback context

type TransportWriter

type TransportWriter interface {
	Write(cntl.Command) error
}

TransportWriter is a writer to an output stream, for example a websocket or Stdout.

type Waiter

type Waiter interface {
	Wait(done chan struct{}, cancel chan struct{}) error
}

Waiter waits for a trigger to happen

Jump to

Keyboard shortcuts

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