player

package
v0.0.0-...-bc4bfc3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var QuitError = errors.New("intentionally quitting")
View Source
var SigIntError = errors.New("SIGINT caught")

Functions

func CopyPreludeTags

func CopyPreludeTags(from map[string]bool) map[string]bool

func FindBestPort

func FindBestPort(pattern string, preferred string) (drivers.Out, error)

Types

type Backend

type Backend struct {
	// Commands can be used to send commands to the UI.
	Commands chan Command

	// UIStates receives updates to the UI state non-blockingly.
	UIStates chan UIState
	// contains filtered or unexported fields
}

func NewBackend

func NewBackend(options *Options) *Backend

func (*Backend) Close

func (b *Backend) Close()

func (*Backend) Loop

func (b *Backend) Loop() error

type Command

type Command struct {
	// Exit exits all current playbacks and returns to waiting state.
	Exit bool

	// Quit quits the entire main loop.
	Quit bool

	// PlayOne plays the given file.
	PlayOne string

	// PlayPrelude enters prelude player mode.
	PlayPrelude bool

	// New list of tags for prelude selection.
	PreludeTags map[string]bool

	// Tempo sets the tempo to a new factor.
	Tempo float64

	// NumVerses is an override for the verse count.
	NumVerses int

	// Answer continues the current playback (exits a Prompt state).
	Answer bool

	// Skip skips the current playback (exits a Prompt state).
	Skip bool

	// Config contains a new configuration. Will be applied on next hymn.
	Config *processor.Config

	// OutPort contains a new, not yet opened, MIDI port. Will be applied once silent.
	OutPort drivers.Out
}

func (Command) IsMainLoopCommand

func (c Command) IsMainLoopCommand() bool

IsMainLoopCommands returns if the command can only be handled by the main loop.

func (Command) IsZero

func (c Command) IsZero() bool

IsZero returns if the command is an empty message. If so, this likely indicates a closed channel.

type Options

type Options struct {
	// FSys is the virtual file system to use.
	FSys fs.FS

	// Config is the global configuration to use.
	Config *processor.Config

	// OutPort is the MIDI output port to use. OK to change later.
	OutPort drivers.Out

	// PlayOnly is the single file to play.
	PlayOnly string
}

type UIState

type UIState struct {
	// Err is set to show an error message. The backend is dead, but can be
	// restarted by sending a PlayOne or PlayPrelude message.
	Err error

	// PlayOne is the name of the currently playing file.
	PlayOne string

	// PlayPrelude indicates if we're in the prelude player.
	PlayPrelude bool

	// List of tags for prelude selection.
	PreludeTags map[string]bool

	// Tempo is the current tempo as a factor of normal.
	Tempo float64

	// Number of verses to play.
	NumVerses int

	// HavePostlude tells if a postlude is pending.
	HavePostlude bool

	// Prompt is the text to prompt the user with.
	// To clear a prompt, send the Answer or Skip message.
	Prompt string

	// SkipPrompt is nonempty is when the skip button should be available.
	// To clear a prompt, send the Answer or Skip message.
	SkipPrompt string

	// CurrentFile is the currently being played file.
	CurrentFile string

	// CurrentPart is the currently being played part.
	CurrentPart processor.OutputKey

	// CurrentMessage is a message for what is currently playing.
	CurrentMessage string

	// Playing is whether we are currently playing.
	Playing bool

	// PlaybackPosTime is the wall time PlaybackPos was last updated.
	PlaybackPosTime time.Time

	// PlaybackPos is the current playback position.
	PlaybackPos time.Duration

	// PlaybackLen is the length of the current file.
	PlaybackLen time.Duration

	// Verse is the current verse.
	Verse int

	// Comment is the hymn comment string.
	Comment string

	// UnrolledNumVerses of real verses in hymn. Only useful if NumVerses == 1.
	UnrolledNumVerses int
}

UIState is the state of the user interface.

func (UIState) ActualPlaybackFraction

func (ui UIState) ActualPlaybackFraction() float64

func (UIState) ActualPlaybackPos

func (ui UIState) ActualPlaybackPos() time.Duration

Jump to

Keyboard shortcuts

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