playlist

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJSONConfigFile

func ParseJSONConfigFile(jsonAsString string, schedule *Schedule) error

Types

type ActualClock

type ActualClock struct{}

ActualClock uses the standard go time.

func (*ActualClock) Now

func (t *ActualClock) Now() time.Time

func (*ActualClock) Wait

func (t *ActualClock) Wait(duration time.Duration)

type AudioDevice

type AudioDevice interface {
	// Play plays a given audio file at a specified volume.
	Play(audioFileName string, volume int) error
}

AudioDevice models the device playing the audio.

type Clock

type Clock interface {
	// Now gets the current time
	Now() time.Time
	// Wait does a synchronous wait for the given time duration.
	Wait(time.Duration)
}

Clock models a clock. That has been abstracted for unit testing.

type Combo

type Combo struct {
	From    TimeOfDay
	Every   int
	Until   TimeOfDay
	Waits   []int
	Volumes []int
	Sounds  []string
}

type Schedule

type Schedule struct {
	Description   string
	ControlNights int
	PlayNights    int
	StartDay      int
	Combos        []Combo
	AllSounds     []int
}

func (*Schedule) CycleLength

func (schedule *Schedule) CycleLength() int

CycleLength calculates how many days the play-control cycle is.

func (*Schedule) GetReferencedSounds

func (schedule *Schedule) GetReferencedSounds() []int

GetReferencedSounds finds the sound file ids that required for playing this schedule.

type SchedulePlayer

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

SchedulePlayer takes a schedule and a bunch of audio files and plays them at the times specified on the schedule.

func NewPlayer

func NewPlayer(audioDevice AudioDevice, allSoundsMap map[int]string, filesDirectory string) *SchedulePlayer

NewPlayer creates a new schedule player.

func (SchedulePlayer) IsSoundPlayingDay

func (sp SchedulePlayer) IsSoundPlayingDay(schedule Schedule) bool

IsSoundPlayingDay works out whether sounds should be played today. Having control days when we play no sound, helps to make sure that we canaccurately determine whether sounds are attracting more animals or not. They may also help stop animals getting attuned to hearing the sounds.

func (SchedulePlayer) PlayTodaysSchedule

func (sp SchedulePlayer) PlayTodaysSchedule(schedule Schedule)

PlayTodaysSchedule plays todays schedule or if it is a control day it waits until the start of the next day

func (*SchedulePlayer) SetRecorder

func (sp *SchedulePlayer) SetRecorder(recorder SoundPlayedRecorder)

SetRecorder sets the call back that records when a sound has successfully played

func (SchedulePlayer) TimeUntilNextCombo added in v1.4.0

func (sp SchedulePlayer) TimeUntilNextCombo(schedule Schedule) time.Duration

type SoundChooser

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

func NewSoundChooser

func NewSoundChooser(allSoundsMap map[int]string) *SoundChooser

func NewSoundChooserWithRandom

func NewSoundChooserWithRandom(allSoundsMap map[int]string, seed int64) *SoundChooser

func (*SoundChooser) ChooseSound

func (chooser *SoundChooser) ChooseSound(choice string) (int, string)

type SoundPlayedRecorder

type SoundPlayedRecorder interface {
	// OnBaitPlayed is called when the device believes audobait has been played
	OnAudioBaitPlayed(ts time.Time, fileId int, volume int)
}

SoundPlayedRecorder gets a notification when a sound has been played.

type TimeOfDay

type TimeOfDay struct {
	time.Time
}

func NewTimeOfDay

func NewTimeOfDay(timeOfDayString string) *TimeOfDay

func (*TimeOfDay) UnmarshalJSON

func (timeOfDay *TimeOfDay) UnmarshalJSON(bValue []byte) (err error)

Jump to

Keyboard shortcuts

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