Documentation ¶
Index ¶
- type PlayOptions
- type Playlist
- func (pl *Playlist) Add(id resource.AudioID)
- func (pl *Playlist) AddWithOptions(id resource.AudioID, opts PlayOptions)
- func (pl *Playlist) GetSilenceDuration() float64
- func (pl *Playlist) IsPaused() bool
- func (pl *Playlist) Len() int
- func (pl *Playlist) SetPaused(paused bool)
- func (pl *Playlist) SetSilenceDuration(seconds float64)
- func (pl *Playlist) Update(delta float64)
- type Queue
- type System
- func (sys *System) GetContext() *audio.Context
- func (sys *System) GetGlobalVolume() float64
- func (sys *System) GetGroupVolume(groupID uint) float64
- func (sys *System) Init(a *audio.Context, l *resource.Loader)
- func (sys *System) PlaySound(id resource.AudioID) resource.Audio
- func (sys *System) PlaySoundWithOptions(id resource.AudioID, opts PlayOptions) resource.Audio
- func (sys *System) SetGlobalVolume(volume float64)
- func (sys *System) SetGroupVolume(groupID uint, multiplier float64)
- func (sys *System) Update()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PlayOptions ¶
type Playlist ¶
type Playlist struct { // SelectFunc implements the next track selection. // // By default, this field is set to a function // that selects the next track and wraps to track 0. // Another example of a selection strategy would be // a random selection or ping-pong style wrapping. // // When the first track needs to be selected, // the currentIndex argument would be -1 as // no tracks are being played at that moment. // // Use [Playlist.Len] to determine the appropriate // track index bound. SelectFunc func(currentIndex int) int // contains filtered or unexported fields }
func NewPlaylist ¶
func (*Playlist) AddWithOptions ¶
func (pl *Playlist) AddWithOptions(id resource.AudioID, opts PlayOptions)
func (*Playlist) GetSilenceDuration ¶
func (*Playlist) SetSilenceDuration ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func (*Queue) PlaySoundWithOptions ¶
func (q *Queue) PlaySoundWithOptions(id resource.AudioID, opts PlayOptions)
PlaySoundWithOptions adds the sound to the queue. If the queue is currently empty, it will start playing right away. Otherwise, it will be played after all other queued sound have played.
type System ¶
type System struct {
// contains filtered or unexported fields
}
func (*System) GetContext ¶
func (*System) GetGlobalVolume ¶
GetGlobalVolume reports the current global volume multiplier.
func (*System) GetGroupVolume ¶
GetGroupVolume reports the current volume multiplier for the given group. The max groupID is 7 (therefore, there could be 8 groups in total). Use [SetGroupVolume] to adjust the group's volume multiplier.
func (*System) PlaySound ¶
PlaySound is a shorthand for [PlaySoundWithOptions](id, {Volume: 1.0}).
The returned Audio object can be ignored unless you want to check it's player field for a readonly operation like IsPlaying.
func (*System) PlaySoundWithOptions ¶
func (*System) SetGlobalVolume ¶
SetGlobalVolume assigns an extra volume multiplier. It's used when computing the effective volume level. Setting it to 0.5 would make all sounds two times quiter.
Imagine an average game that has separate volume controls (sfx, voice, music) plus "master volume" that would be applied on top of that. The global volume level is that multiplier.
func (*System) SetGroupVolume ¶
SetGroupVolume assigns the volume multiplier for the given group. The max groupID is 7 (therefore, there could be 8 groups in total). Use [GetGroupVolume] to get the group's current volume multiplier.
A sound multiplier of 0 effectively mutes the group.