Documentation ¶
Overview ¶
Package audio provides audio types, font types for filtering audio reactively, and channels to allow constant audio play signals to be restricted to play at variable frequencies.
Index ¶
- Variables
- func BatchLoad(baseFolder string) error
- func DefActiveChannel(freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
- func DefChannel(freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
- func DefPlay(filename string) error
- func GetActiveChannel(f *font.Font, freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
- func GetChannel(f *font.Font, freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
- func IsLoaded(filename string) bool
- func Play(f *font.Font, filename string) error
- func Unload(filename string)
- type Audio
- func (a *Audio) Copy() (audio.Audio, error)
- func (a *Audio) Filter(fs ...audio.Filter) (audio.Audio, error)
- func (a *Audio) GetX() *float64
- func (a *Audio) GetY() *float64
- func (a *Audio) MustCopy() audio.Audio
- func (a *Audio) MustFilter(fs ...audio.Filter) audio.Audio
- func (a *Audio) Play() <-chan error
- func (a *Audio) Stop() error
- type ChannelSignal
- type Data
- type Ears
- type FontManager
- type Pos
- type PosSignal
- type ScaleType
- type Signal
- type SupportsPos
Constants ¶
This section is empty.
Variables ¶
var ( // DefFont is the font used for default functions. It can be publicly // modified to apply a default font to generated audios through def // methods. If it is not modified, it is a font of zero filters. DefFont = font.New() )
Functions ¶
func BatchLoad ¶
BatchLoad attempts to load all files within a given directory depending on their file ending (currently supporting .wav and .mp3)
func DefActiveChannel ¶
func DefActiveChannel(freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
DefActiveChannel acts like GetActiveChannel when fed DefFont
func DefChannel ¶
func DefChannel(freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
DefChannel acts like GetChannel when given DefFont
func GetActiveChannel ¶
func GetActiveChannel(f *font.Font, freq intrange.Range, fileNames ...string) (chan ChannelSignal, error)
GetActiveChannel returns a channel that will block until its frequency rotates around. This means that continually sending on ChannelSignal will probably cause the game to freeze or substantially slow down. For this reason ActiveWavChannels are meant to be used for cases where the user knows they will not be sending on the ActiveWavChannel more often than the frequency they send in. Audio channels serve one purpose: handling audio effects which come in at very high or unpredictable frequencies while limiting the number of concurrent ongoing audio effects from any one source. All channels will only play once per a given frequency range.
func GetChannel ¶
GetChannel channels will attempt to steal most sends sent to the output audio channel. This will allow a game to constantly send on a channel and obtain an output rate of near the sent in frequency instead of locking or requiring buffered channel usage.
An important example case-- walking around When a character walks, they have some frequency step speed and some set of potential fileName sounds that play, and the usage of a channel here will let the EnterFrame code which detects the walking status to send on the walking audio channel constantly without worrying about triggering too many sounds.
Types ¶
type Audio ¶
Audio is a struct of some audio data and the variables required to filter it through a sound font.
func (*Audio) MustFilter ¶
MustFilter acts like Filter but ignores errors.
type ChannelSignal ¶
A ChannelSignal is sent to an AudioChannel to indicate when they should attempt to play an audio sound
type Data ¶
Data is an alias for an interface supporting the built in filters in our external audio playing library
type Ears ¶
type Ears struct { X *float64 Y *float64 PanWidth float64 SilenceRadius float64 // VolumeScale and PanScale are currently ignored because there is only // one scale type VolumeScale ScaleType PanScale ScaleType }
Ears are assisting variables and some position in the game world where audio should be 'heard' from, like the player character. Passing in that position's x and y as pointers then will allow for sounds further away from that point to be quieter and sounds to the left / right of that point to be panned left and right.
func (*Ears) CalculatePan ¶
CalculatePan converts PanWidth and two x positions into a left / right pan value.
type FontManager ¶
A FontManager is a map of names to Fonts that has a built in default font at name 'def'.
func NewFontManager ¶
func NewFontManager() *FontManager
NewFontManager returns a manager with a single 'def' font
type Pos ¶
type Pos func(SupportsPos)
Pos functions are filters that require a SupportsPos interface
type PosSignal ¶
PosSignal is a ChannelSignal compatible with Ears
func NewPosSignal ¶
NewPosSignal constructs a PosSignal
type ScaleType ¶
type ScaleType int
ScaleType should be moved to a different package that handles global scale varieties