audio

package
Version: v0.0.0-...-7296e18 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 5 Imported by: 0

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

View Source
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
)
View Source
const (
	Unknown = State(0)
	Initial = State(al.Initial)
	Playing = State(al.Playing)
	Paused  = State(al.Paused)
	Stopped = State(al.Stopped)
)
View Source
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

func GetOrientation() (float32, float32, float32, float32, float32, float32)

GetOrientation returns the orientation vectors of the listener in the order of Forward{x,y,z} Up{x,y,z}

func GetPosition

func GetPosition() (float32, float32, float32)

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

func GetVelocity() (float32, float32, float32)

GetVelocity returns the velocity of the listener

func GetVolume

func GetVolume() float32

GetVolume returns the master volume.

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}

func SetPosition

func SetPosition(x, y, z float32)

SetPosition sets the position of the listener

func SetVelocity

func SetVelocity(x, y, z float32)

SetVelocity sets the velocity of the listener

func SetVolume

func SetVolume(gain float32)

SetVolume sets the master volume

func Stop

func Stop(source *Source)

Stop stops a specified source, if source is nil it will stop all

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

func NewSource(filepath string, static bool) (*Source, error)

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

func (s *Source) GetAttenuationDistances() (float32, float32)

GetAttenuationDistances returns the reference and maximum attenuation distances of the Source.

func (*Source) GetChannels

func (s *Source) GetChannels() int16

GetChannels returns the number of channels in the Source.

func (*Source) GetCone

func (s *Source) GetCone() (float32, float32, float32)

GetCone returns the Source's directional volume cones by inner angle, outer angle, and outer volume.

func (*Source) GetDirection

func (s *Source) GetDirection() (float32, float32, float32)

GetDirection returns the direction of the Source with a vector of x, y, z

func (*Source) GetDuration

func (s *Source) GetDuration() time.Duration

GetDuration returns the total duration of the source.

func (*Source) GetPitch

func (s *Source) GetPitch() float32

GetPitch returns the current pitch of the Source in the range 0.0, 1.0

func (*Source) GetPosition

func (s *Source) GetPosition() (float32, float32, float32)

GetPosition returns the position of the Source in a point x, y, z

func (*Source) GetRolloff

func (s *Source) GetRolloff() float32

GetRolloff returns the rolloff factor of the source.

func (*Source) GetState

func (s *Source) GetState() State

GetState returns the playing state of the source.

source.GetState() == audio.Playing

func (*Source) GetVelocity

func (s *Source) GetVelocity() (float32, float32, float32)

GetVelocity returns the velocity of the Source with a vector x, y, x

func (*Source) GetVolume

func (s *Source) GetVolume() float32

GetVolume returns the current volume of the Source.

func (*Source) GetVolumeLimits

func (s *Source) GetVolumeLimits() (float32, float32)

GetVolumeLimits returns the volume limits of the source, min, max.

func (*Source) IsFinished

func (s *Source) IsFinished() bool

IsFinished will return true if the source is at the end of its duration and it is not a looping source.

func (*Source) IsLooping

func (s *Source) IsLooping() bool

IsLooping returns whether the Source will loop.

func (*Source) IsPaused

func (s *Source) IsPaused() bool

IsPaused returns whether the Source is paused.

func (*Source) IsPlaying

func (s *Source) IsPlaying() bool

IsPlaying returns whether the Source is playing.

func (*Source) IsRelative

func (s *Source) IsRelative() bool

IsRelative returns whether the Source's position and direction are relative to the listener.

func (*Source) IsStatic

func (s *Source) IsStatic() bool

IsStatic returns whether the Source is static or stream.

func (*Source) IsStopped

func (s *Source) IsStopped() bool

IsStopped returns whether the Source is stopped.

func (*Source) Pause

func (s *Source) Pause()

Pause pauses the source.

func (*Source) Play

func (s *Source) Play() bool

Play starts playing the source.

func (*Source) Resume

func (s *Source) Resume()

Resume resumes a paused source.

func (*Source) Rewind

func (s *Source) Rewind()

Rewind rewinds the source source to its start time.

func (*Source) Seek

func (s *Source) Seek(offset time.Duration)

Seek sets the currently playing position of the Source.

func (*Source) SetAttenuationDistances

func (s *Source) SetAttenuationDistances(ref, max float32)

SetAttenuationDistances sets the reference and maximum attenuation distances of the Source.

func (*Source) SetCone

func (s *Source) SetCone(innerAngle, outerAngle, outerVolume float32)

SetCone sets the Source's directional volume cones with the inner angle, outer angle, and outer volume

func (*Source) SetDirection

func (s *Source) SetDirection(x, y, z float32)

SetDirection sets the direction of the Source with the vector x, y, z

func (*Source) SetLooping

func (s *Source) SetLooping(do_loop bool)

SetLooping sets whether the Source should loop when the source is complete.

func (*Source) SetPitch

func (s *Source) SetPitch(p float32)

SetPitch sets the pitch of the Source, the value should be between 0.0, 1.0

func (*Source) SetPosition

func (s *Source) SetPosition(x, y, z float32)

SetPosition sets the position of the Source at the point x, y, z

func (*Source) SetRelative

func (s *Source) SetRelative(is_relative bool)

SetRelative sets whether the Source's position and direction are relative to the listener.

func (*Source) SetRolloff

func (s *Source) SetRolloff(roll_off float32)

SetRolloff sets the rolloff factor.

func (*Source) SetVelocity

func (s *Source) SetVelocity(x, y, z float32)

SetVelocity sets the velocity of the Source with the vector x, y, z

func (*Source) SetVolume

func (s *Source) SetVolume(v float32)

SetVolume sets the current volume of the Source.

func (*Source) SetVolumeLimits

func (s *Source) SetVolumeLimits(min, max float32)

SetVolumeLimits sets the volume limits of the source both min and max

func (*Source) Stop

func (s *Source) Stop()

Stop stops a playing source.

func (*Source) Tell

func (s *Source) Tell() time.Duration

Tell returns the currently playing position of the Source.

type State

type State int

State indicates the current playing state of the source.

Directories

Path Synopsis
Package decoding is used for converting familiar file types to data usable by OpenAL.
Package decoding is used for converting familiar file types to data usable by OpenAL.

Jump to

Keyboard shortcuts

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