Documentation ¶
Overview ¶
Package al provides OpenAL Soft bindings for Go.
Calls are not safe for concurrent use.
More information about OpenAL Soft is available at http://www.openal.org/documentation/openal-1.1-specification.pdf.
In order to use this package on Linux desktop distros, you will need OpenAL library as an external dependency. On Ubuntu 14.04 'Trusty', you may have to install this library by running the command below.
sudo apt-get install libopenal-dev
When compiled for Android, this package uses OpenAL Soft. Please add its license file to the open source notices of your application. OpenAL Soft's license file could be found at http://repo.or.cz/w/openal-soft.git/blob/HEAD:/COPYING.
Index ¶
- Constants
- func CloseDevice()
- func DeleteBuffers(buffer ...Buffer)
- func DeleteSources(source ...Source)
- func DeviceError() int32
- func Disable(c Capability)
- func DistanceModel() int32
- func DopplerFactor() float32
- func DopplerVelocity() float32
- func Enable(c Capability)
- func Enabled(c Capability) bool
- func Error() int32
- func Extensions() string
- func ListenerGain() float32
- func OpenDevice() error
- func PauseSources(source ...Source)
- func PlaySources(source ...Source)
- func Renderer() string
- func RewindSources(source ...Source)
- func SetDistanceModel(v int32)
- func SetDopplerFactor(v float32)
- func SetDopplerVelocity(v float32)
- func SetListenerGain(v float32)
- func SetListenerOrientation(v Orientation)
- func SetListenerPosition(v Vector)
- func SetListenerVelocity(v Vector)
- func SetSpeedOfSound(v float32)
- func SpeedOfSound() float32
- func StopSources(source ...Source)
- func Vendor() string
- func Version() string
- type Buffer
- type Capability
- type Orientation
- type Source
- func (s Source) BuffersProcessed() int32
- func (s Source) BuffersQueued() int32
- func (s Source) Gain() float32
- func (s Source) MaxGain() float32
- func (s Source) MinGain() float32
- func (s Source) OffsetByte() int32
- func (s Source) OffsetSample() int32
- func (s Source) OffsetSeconds() int32
- func (s Source) Orientation() Orientation
- func (s Source) Position() Vector
- func (s Source) QueueBuffers(buffer ...Buffer)
- func (s Source) SetGain(v float32)
- func (s Source) SetMaxGain(v float32)
- func (s Source) SetMinGain(v float32)
- func (s Source) SetOrientation(o Orientation)
- func (s Source) SetPosition(v Vector)
- func (s Source) SetVelocity(v Vector)
- func (s Source) State() int32
- func (s Source) UnqueueBuffers(buffer ...Buffer)
- func (s Source) Velocity() Vector
- type Vector
Constants ¶
const ( InvalidName = 0xA001 InvalidEnum = 0xA002 InvalidValue = 0xA003 InvalidOperation = 0xA004 OutOfMemory = 0xA005 )
Error returns one of these error codes.
const ( InverseDistance = 0xD001 InverseDistanceClamped = 0xD002 LinearDistance = 0xD003 LinearDistanceClamped = 0xD004 ExponentDistance = 0xD005 ExponentDistanceClamped = 0xD006 )
Distance models.
const ( Initial = 0x1011 Playing = 0x1012 Paused = 0x1013 Stopped = 0x1014 )
A source could be in the state of initial, playing, paused or stopped.
const ( FormatMono8 = 0x1100 FormatMono16 = 0x1101 FormatStereo8 = 0x1102 FormatStereo16 = 0x1103 )
Audio formats. Buffer.BufferData accepts one of these formats as the data format.
const CapabilityDistanceModel = Capability(0x200)
CapabilityDistanceModel represents the capability of specifying a different distance model for each source.
Variables ¶
This section is empty.
Functions ¶
func CloseDevice ¶
func CloseDevice()
CloseDevice closes the device and frees related resources. Calls to CloseDevice are safe for concurrent use.
func DeviceError ¶
func DeviceError() int32
DeviceError returns the last known error from the current device.
func Enabled ¶
func Enabled(c Capability) bool
Enabled returns true if the specified capability is enabled.
func ListenerGain ¶
func ListenerGain() float32
ListenerGain returns the total gain applied to the final mix.
func OpenDevice ¶
func OpenDevice() error
OpenDevice opens the default audio device. Calls to OpenDevice are safe for concurrent use.
func RewindSources ¶
func RewindSources(source ...Source)
RewindSources rewinds the sources to their beginning positions.
func SetDopplerVelocity ¶
func SetDopplerVelocity(v float32)
SetDopplerVelocity sets the doppler velocity.
func SetListenerGain ¶
func SetListenerGain(v float32)
SetListenerGain sets the total gain that will be applied to the final mix.
func SetListenerOrientation ¶
func SetListenerOrientation(v Orientation)
SetListenerOrientation sets the orientation of the listener.
func SetListenerPosition ¶
func SetListenerPosition(v Vector)
SetListenerPosition sets the position of the listener.
func SetListenerVelocity ¶
func SetListenerVelocity(v Vector)
SetListenerVelocity sets the velocity of the listener.
func SetSpeedOfSound ¶
func SetSpeedOfSound(v float32)
SetSpeedOfSound sets the speed of sound, its unit should be meters per second (m/s).
func SpeedOfSound ¶
func SpeedOfSound() float32
SpeedOfSound is the speed of sound in meters per second (m/s).
Types ¶
type Buffer ¶
type Buffer uint32
A buffer represents a chunk of PCM audio data that could be buffered to an audio source. A single buffer could be shared between multiple sources.
func GenBuffers ¶
GenBuffers generates n new buffers. The generated buffers should be deleted once they are no longer in use.
func (Buffer) BufferData ¶
BufferData buffers PCM data to the current buffer.
type Orientation ¶
type Orientation struct { // Forward vector is the direction that the object is looking at. Forward Vector // Up vector represents the rotation of the object. Up Vector }
Orientation represents the angular position of an object in a right-handed Cartesian coordinate system. A cross product between the forward and up vector returns a vector that points to the right.
func ListenerOrientation ¶
func ListenerOrientation() Orientation
ListenerOrientation returns the orientation of the listener.
type Source ¶
type Source uint32
Source represents an individual sound source in 3D-space. They take PCM data, apply modifications and then submit them to be mixed according to their spatial location.
func GenSources ¶
GenSources generates n new sources. These sources should be deleted once they are not in use.
func (Source) BuffersProcessed ¶
BuffersProcessed returns the number of the processed buffers.
func (Source) BuffersQueued ¶
BuffersQueued returns the number of the queued buffers.
func (Source) OffsetByte ¶
OffsetByte returns the byte offset of the current playback position.
func (Source) OffsetSample ¶
OffsetSample returns the sample offset of the current playback position.
func (Source) OffsetSeconds ¶
OffsetSeconds returns the current playback position of the source in seconds.
func (Source) Orientation ¶
func (s Source) Orientation() Orientation
Orientation returns the orientation of the source.
func (Source) QueueBuffers ¶
QueueBuffers adds the buffers to the buffer queue.
func (Source) SetMaxGain ¶
SetMaxGain sets the source's maximum gain setting.
func (Source) SetMinGain ¶
SetMinGain sets the source's minimum gain setting.
func (Source) SetOrientation ¶
func (s Source) SetOrientation(o Orientation)
SetOrientation sets the orientation of the source.
func (Source) SetPosition ¶
SetPosition sets the position of the source.
func (Source) SetVelocity ¶
SetVelocity sets the source's velocity.
func (Source) UnqueueBuffers ¶
UnqueueBuffers removes the specified buffers from the buffer queue.
type Vector ¶
type Vector [3]float32
Vector represents an vector in a Cartesian coordinate system.
func ListenerPosition ¶
func ListenerPosition() Vector
ListenerPosition returns the position of the listener.
func ListenerVelocity ¶
func ListenerVelocity() Vector
ListenerVelocity returns the velocity of the listener.