audio

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SampleRate = 44100

SampleRate is the sample rate at which the player plays audio. Any audios resource that is added to the system is resampled to this sample rate. To change the sample rate, you must do so BEFORE adding the audio system to the world.

Functions

func GetMasterVolume

func GetMasterVolume() float64

GetMasterVolume gets the master volume of the audio system.

func SetMasterVolume

func SetMasterVolume(volume float64)

SetMasterVolume sets the master volume. The masterVolume is multiplied by all the other volumes to get the volume of each entity played. Value must be between 0 and 1 or else it doesn't set.

Types

type AudioComponent

type AudioComponent struct {
	Player *Player
}

AudioComponent is a Component which is used by the AudioSystem

func (*AudioComponent) GetAudioComponent

func (c *AudioComponent) GetAudioComponent() *AudioComponent

GetAudioComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods

type AudioFace

type AudioFace interface {
	GetAudioComponent() *AudioComponent
}

AudioFace allows typesafe access to an anonymouse child AudioComponent

type AudioSystem

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

AudioSystem is a System that allows for sound effects and / or music

func (*AudioSystem) Add

func (a *AudioSystem) Add(basic *ecs.BasicEntity, audio *AudioComponent)

Add adds an entity to the AudioSystem

func (*AudioSystem) AddByInterface

func (a *AudioSystem) AddByInterface(i ecs.Identifier)

AddByInterface Allows an Entity to be added directly using the Audioable interface, which every entity containing the BasicEntity and AnimationComponent anonymously, automatically satisfies.

func (*AudioSystem) New

func (a *AudioSystem) New(w *ecs.World)

New is called when the AudioSystem is added to the world.

func (*AudioSystem) Remove

func (a *AudioSystem) Remove(basic ecs.BasicEntity)

Remove removes an entity from the AudioSystem

func (*AudioSystem) Update

func (a *AudioSystem) Update(dt float32)

Update is called once per frame, and updates/plays the players in the AudioSystem

type Audioable

type Audioable interface {
	basic.BasicFace
	AudioFace
}

Audioable is the required interface for the AudioSystem.AddByInterface method

type NotAudioComponent

type NotAudioComponent struct{}

NotAudioComponent is used to flag an entity as not in the AudioSystem even if it has the proper components

func (*NotAudioComponent) GetNotAudioComponent

func (n *NotAudioComponent) GetNotAudioComponent() *NotAudioComponent

GetNotAudioComponent implements the NotAudioable interface

type NotAudioable

type NotAudioable interface {
	GetNotAudioComponent() *NotAudioComponent
}

NotAudioable is an interface used to flag an entity as not in the AudioSystem even if it has the proper components

type Player

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

Player holds the underlying audio data and plays/pauses/stops/rewinds/seeks it.

func LoadedPlayer

func LoadedPlayer(url string) (*Player, error)

LoadedPlayer retrieves the *audio.Player created from the URL

func (*Player) Close

func (p *Player) Close() error

Close removes the player from the audio system's players, which are currently playing players. it then finalizes and frees the data from the player.

func (*Player) Current

func (p *Player) Current() time.Duration

Current returns the current position.

func (*Player) GetVolume

func (p *Player) GetVolume() float64

GetVolume gets the Player's volume

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

IsPlaying returns boolean indicating whether the player is playing.

func (*Player) Pause

func (p *Player) Pause()

Pause pauses the playing.

func (*Player) Play

func (p *Player) Play()

Play plays the player's audio.

func (*Player) Rewind

func (p *Player) Rewind() error

Rewind rewinds the current position to the start.

Rewind returns error when seeking the source stream returns error.

func (*Player) Seek

func (p *Player) Seek(offset time.Duration) error

Seek seeks the position with the given offset.

Seek returns error when seeking the source stream returns error.

func (*Player) SetVolume

func (p *Player) SetVolume(volume float64)

SetVolume sets the Player's volume volume can only be set from 0 to 1

func (*Player) URL

func (p *Player) URL() string

URL implements the engo.Resource interface. It retrieves the player's source url.

Directories

Path Synopsis
internal
decode/convert
package convert resamples and converts audio data
package convert resamples and converts audio data
decode/mp3
Package mp3 provides MP3 decoder.
Package mp3 provides MP3 decoder.
decode/vorbis
Package vorbis provides Ogg/Vorbis decoder.
Package vorbis provides Ogg/Vorbis decoder.
decode/wav
Package wav provides WAV (RIFF) decoder.
Package wav provides WAV (RIFF) decoder.

Jump to

Keyboard shortcuts

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