Documentation ¶
Overview ¶
The audio package is use for creating audio sources, managing/pooling resources, and playback of those audio sources.
Supported audio types are wav, ogg, and flac
Index ¶
- Constants
- func GetDopplerScale() float32
- func GetOrientation() (float32, float32, float32, float32, float32, float32)
- func GetPosition() (float32, float32, float32)
- func GetSourceCount() int
- func GetVelocity() (float32, float32, float32)
- func GetVolume() float32
- func Pause(source *Source)
- func Play(source *Source)
- func Resume(source *Source)
- func Rewind(source *Source)
- func SetDistanceModel(model DistanceModel)
- func SetDopplerScale(scale float32)
- func SetOrientation(fx, fy, fz, ux, uy, uz float32)
- func SetPosition(x, y, z float32)
- func SetVelocity(x, y, z float32)
- func SetVolume(gain float32)
- func Stop(source *Source)
- type DistanceModel
- type Source
- func (s *Source) GetAttenuationDistances() (float32, float32)
- func (s *Source) GetChannels() int16
- func (s *Source) GetCone() (float32, float32, float32)
- func (s *Source) GetDirection() (float32, float32, float32)
- func (s *Source) GetDuration() time.Duration
- func (s *Source) GetPitch() float32
- func (s *Source) GetPosition() (float32, float32, float32)
- func (s *Source) GetRolloff() float32
- func (s *Source) GetState() State
- func (s *Source) GetVelocity() (float32, float32, float32)
- func (s *Source) GetVolume() float32
- func (s *Source) GetVolumeLimits() (float32, float32)
- func (s *Source) IsFinished() bool
- func (s *Source) IsLooping() bool
- func (s *Source) IsPaused() bool
- func (s *Source) IsPlaying() bool
- func (s *Source) IsRelative() bool
- func (s *Source) IsStatic() bool
- func (s *Source) IsStopped() bool
- func (s *Source) Pause()
- func (s *Source) Play() bool
- func (s *Source) Resume()
- func (s *Source) Rewind()
- func (s *Source) Seek(offset time.Duration)
- func (s *Source) SetAttenuationDistances(ref, max float32)
- func (s *Source) SetCone(innerAngle, outerAngle, outerVolume float32)
- func (s *Source) SetDirection(x, y, z float32)
- func (s *Source) SetLooping(do_loop bool)
- func (s *Source) SetPitch(p float32)
- func (s *Source) SetPosition(x, y, z float32)
- func (s *Source) SetRelative(is_relative bool)
- func (s *Source) SetRolloff(roll_off float32)
- func (s *Source) SetVelocity(x, y, z float32)
- func (s *Source) SetVolume(v float32)
- func (s *Source) SetVolumeLimits(min, max float32)
- func (s *Source) Stop()
- func (s *Source) Tell() time.Duration
- type State
Constants ¶
const ( MAX_ATTENUATION_DISTANCE = 1000000.0 // upper limit of sound attentuation time. MAX_BUFFERS = 8 //arbitrary limit of umber of buffers a source can use to stream )
const ( Unknown = State(0) Initial = State(al.Initial) Playing = State(al.Playing) Paused = State(al.Paused) Stopped = State(al.Stopped) )
const MAX_SOURCES = 64
An upper limit to try and reach while finding out how many sources the system can handle
Variables ¶
This section is empty.
Functions ¶
func GetDopplerScale ¶
func GetDopplerScale() float32
GetDopplerScale gets the global scale factor for doppler effects
func GetOrientation ¶
GetOrientation returns the orientation vectors of the listener in the order of Forward{x,y,z} Up{x,y,z}
func GetPosition ¶
GetPosition returns the position of the listener x, y, z
func GetSourceCount ¶
func GetSourceCount() int
GetSourceCount gets the current number of simultaneously playing sources
func GetVelocity ¶
GetVelocity returns the velocity of the listener
func Pause ¶
func Pause(source *Source)
Pause pauses a specified source, if source is nil it will pause all
func Play ¶
func Play(source *Source)
Play plays a specified source, if source is nil it will play all
func Resume ¶
func Resume(source *Source)
Resume playes a specified source, if source is nil it will resume all
func Rewind ¶
func Rewind(source *Source)
Rewind rewinds a specified source, if source is nil it will rewind all
func SetDistanceModel ¶
func SetDistanceModel(model DistanceModel)
SetDistanceModel sets the distance attenuation model
func SetDopplerScale ¶
func SetDopplerScale(scale float32)
SetDopplerScale sets a global scale factor for doppler effects
func SetOrientation ¶
func SetOrientation(fx, fy, fz, ux, uy, uz float32)
SetOrientation sets the orientation of the listener in the order Front{x,y,z} Up{x,y,z}
Types ¶
type DistanceModel ¶
type DistanceModel int32
DistanceModel defines sound attenuation.
const ( DISTANCE_NONE DistanceModel = 0xD000 DISTANCE_INVERSE DistanceModel = 0xD001 DISTANCE_INVERSE_CLAMPED DistanceModel = 0xD002 DISTANCE_LINEAR DistanceModel = 0xD003 DISTANCE_LINEAR_CLAMPED DistanceModel = 0xD004 DISTANCE_EXPONENT DistanceModel = 0xD005 DISTANCE_EXPONENT_CLAMPED DistanceModel = 0xD006 )
func GetDistanceModel ¶
func GetDistanceModel() DistanceModel
GetDistanceModel returns the distance attenuation model
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source manages decoding sound data, creates an openal sound and manages the data associated with the source.
func NewSource ¶
NewSource creates a new Source from a file at the path provided. If you specify a static source it will all be buffered into a single buffer. If false then it will create many buffers a cycle through them with data chunks. This allows a smaller memory footprint while playing bigger music files. You may want a static file if the sound is less than 2 seconds. It allows for faster cleaning playing of shorter sounds like footsteps.
func (*Source) GetAttenuationDistances ¶
GetAttenuationDistances returns the reference and maximum attenuation distances of the Source.
func (*Source) GetChannels ¶
GetChannels returns the number of channels in the Source.
func (*Source) GetCone ¶
GetCone returns the Source's directional volume cones by inner angle, outer angle, and outer volume.
func (*Source) GetDirection ¶
GetDirection returns the direction of the Source with a vector of x, y, z
func (*Source) GetDuration ¶
GetDuration returns the total duration of the source.
func (*Source) GetPosition ¶
GetPosition returns the position of the Source in a point x, y, z
func (*Source) GetRolloff ¶
GetRolloff returns the rolloff factor of the source.
func (*Source) GetState ¶
GetState returns the playing state of the source.
source.GetState() == audio.Playing
func (*Source) GetVelocity ¶
GetVelocity returns the velocity of the Source with a vector x, y, x
func (*Source) GetVolumeLimits ¶
GetVolumeLimits returns the volume limits of the source, min, max.
func (*Source) IsFinished ¶
IsFinished will return true if the source is at the end of its duration and it is not a looping source.
func (*Source) IsRelative ¶
IsRelative returns whether the Source's position and direction are relative to the listener.
func (*Source) Rewind ¶
func (s *Source) Rewind()
Rewind rewinds the source source to its start time.
func (*Source) SetAttenuationDistances ¶
SetAttenuationDistances sets the reference and maximum attenuation distances of the Source.
func (*Source) SetCone ¶
SetCone sets the Source's directional volume cones with the inner angle, outer angle, and outer volume
func (*Source) SetDirection ¶
SetDirection sets the direction of the Source with the vector x, y, z
func (*Source) SetLooping ¶
SetLooping sets whether the Source should loop when the source is complete.
func (*Source) SetPitch ¶
SetPitch sets the pitch of the Source, the value should be between 0.0, 1.0
func (*Source) SetPosition ¶
SetPosition sets the position of the Source at the point x, y, z
func (*Source) SetRelative ¶
SetRelative sets whether the Source's position and direction are relative to the listener.
func (*Source) SetRolloff ¶
SetRolloff sets the rolloff factor.
func (*Source) SetVelocity ¶
SetVelocity sets the velocity of the Source with the vector x, y, z
func (*Source) SetVolumeLimits ¶
SetVolumeLimits sets the volume limits of the source both min and max