engine: github.com/g3n/engine/audio Index | Files | Directories

package audio

import "github.com/g3n/engine/audio"

Package audio contains sub packages for binding to external audio libraries and implements a spatial audio player.

Index

Package Files

audio_file.go doc.go listener.go player.go wave.go

type AudioFile Uses

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

AudioFile represents an audio file

func NewAudioFile Uses

func NewAudioFile(filename string) (*AudioFile, error)

NewAudioFile creates and returns a pointer to a new audio file object and an error

func (*AudioFile) Close Uses

func (af *AudioFile) Close() error

Close closes the audiofile

func (*AudioFile) CurrentTime Uses

func (af *AudioFile) CurrentTime() float64

CurrentTime returns the current time in seconds for the current file read position

func (*AudioFile) Info Uses

func (af *AudioFile) Info() AudioInfo

Info returns the audio info structure for this audio file

func (*AudioFile) Looping Uses

func (af *AudioFile) Looping() bool

Looping returns the current looping state of this audio file

func (*AudioFile) Read Uses

func (af *AudioFile) Read(pdata unsafe.Pointer, nbytes int) (int, error)

Read reads decoded data from the audio file

func (*AudioFile) Seek Uses

func (af *AudioFile) Seek(pos uint) error

Seek sets the file reading position relative to the origin

func (*AudioFile) SetLooping Uses

func (af *AudioFile) SetLooping(looping bool)

SetLooping sets the looping state of this audio file

type AudioInfo Uses

type AudioInfo struct {
    Format     int     // OpenAl Format
    Channels   int     // Number of channels
    SampleRate int     // Sample rate in hz
    BitsSample int     // Number of bits per sample (8 or 16)
    DataSize   int     // Total data size in bytes
    BytesSec   int     // Bytes per second
    TotalTime  float64 // Total time in seconds
}

AudioInfo represents the information associated to an audio file

type Listener Uses

type Listener struct {
    core.Node
}

Listener is an audio listener positioned in space

func NewListener Uses

func NewListener() *Listener

NewListener returns a pointer to a new Listener object.

func (*Listener) Gain Uses

func (l *Listener) Gain() float32

Gain returns the gain of the listener

func (*Listener) Render Uses

func (l *Listener) Render(gl *gls.GLS)

Render is called by the renderer at each frame Updates the OpenAL position and orientation of this listener

func (*Listener) SetGain Uses

func (l *Listener) SetGain(gain float32)

SetGain sets the gain of the listener

func (*Listener) SetVelocity Uses

func (l *Listener) SetVelocity(vx, vy, vz float32)

SetVelocity sets the velocity of the listener with x, y, z components

func (*Listener) SetVelocityVec Uses

func (l *Listener) SetVelocityVec(v *math32.Vector3)

SetVelocityVec sets the velocity of the listener with a vector

func (*Listener) Velocity Uses

func (l *Listener) Velocity() (float32, float32, float32)

Velocity returns the velocity of the listener as x, y, z components

func (*Listener) VelocityVec Uses

func (l *Listener) VelocityVec() math32.Vector3

VelocityVec returns the velocity of the listener as a vector

type Player Uses

type Player struct {
    core.Node // Embedded node
    // contains filtered or unexported fields
}

Player is a 3D (spatial) audio file player It embeds a core.Node so it can be inserted as a child in any other 3D object.

func NewPlayer Uses

func NewPlayer(filename string) (*Player, error)

NewPlayer creates and returns a pointer to a new audio player object which will play the audio encoded in the specified file. Currently it supports wave and Ogg Vorbis formats.

func (*Player) CurrentTime Uses

func (p *Player) CurrentTime() float64

CurrentTime returns the current time in seconds spent in the stream

func (*Player) Dispose Uses

func (p *Player) Dispose()

Dispose disposes of this player resources

func (*Player) Gain Uses

func (p *Player) Gain() float32

Gain returns the current gain (volume) of this player

func (*Player) InnerCone Uses

func (p *Player) InnerCone() float32

InnerCone returns the inner cone angle in degrees

func (*Player) Looping Uses

func (p *Player) Looping() bool

Looping returns the current looping state of this player

func (*Player) MaxGain Uses

func (p *Player) MaxGain() float32

MaxGain returns the current maximum gain of this player

func (*Player) MinGain Uses

func (p *Player) MinGain() float32

MinGain returns the current minimum gain of this player

func (*Player) OuterCone Uses

func (p *Player) OuterCone() float32

OuterCone returns the outer cone angle in degrees

func (*Player) Pause Uses

func (p *Player) Pause()

Pause sets the player in the pause state

func (*Player) Pitch Uses

func (p *Player) Pitch() float32

Pitch returns the current pitch factor of this player

func (*Player) Play Uses

func (p *Player) Play() error

Play starts playing this player

func (*Player) Render Uses

func (p *Player) Render(gl *gls.GLS)

Render satisfies the INode interface. It is called by renderer at every frame and is used to update the audio source position and direction

func (*Player) SetGain Uses

func (p *Player) SetGain(gain float32)

SetGain sets the gain (volume) of this player

func (*Player) SetInnerCone Uses

func (p *Player) SetInnerCone(inner float32)

SetInnerCone sets the inner cone angle in degrees

func (*Player) SetLooping Uses

func (p *Player) SetLooping(looping bool)

SetLooping sets the looping state of this player

func (*Player) SetMaxGain Uses

func (p *Player) SetMaxGain(gain float32)

SetMaxGain sets the maximum gain (volume) of this player

func (*Player) SetMinGain Uses

func (p *Player) SetMinGain(gain float32)

SetMinGain sets the minimum gain (volume) of this player

func (*Player) SetOuterCone Uses

func (p *Player) SetOuterCone(outer float32)

SetOuterCone sets the outer cone angle in degrees

func (*Player) SetPitch Uses

func (p *Player) SetPitch(pitch float32)

SetPitch sets the pitch factor of this player

func (*Player) SetRolloffFactor Uses

func (p *Player) SetRolloffFactor(rfactor float32)

SetRolloffFactor sets this player rolloff factor user to calculate the gain attenuation by distance

func (*Player) SetVelocity Uses

func (p *Player) SetVelocity(vx, vy, vz float32)

SetVelocity sets the velocity of this player It is used to calculate Doppler effects

func (Player) SetVelocityVec Uses

func (p Player) SetVelocityVec(v *math32.Vector3)

SetVelocityVec sets the velocity of this player from the specified vector It is used to calculate Doppler effects

func (*Player) State Uses

func (p *Player) State() int

State returns the current state of this player

func (*Player) Stop Uses

func (p *Player) Stop()

Stop stops the player

func (*Player) TotalTime Uses

func (p *Player) TotalTime() float64

TotalTime returns the total time in seconds to play this stream

func (*Player) Velocity Uses

func (p *Player) Velocity() (float32, float32, float32)

Velocity returns this player velocity

func (*Player) VelocityVec Uses

func (p *Player) VelocityVec() math32.Vector3

VelocityVec returns this player velocity vector

type WaveSpecs Uses

type WaveSpecs struct {
    Format     int     // OpenAl Format
    Type       int     // Type field from wave header
    Channels   int     // Number of channels
    SampleRate int     // Sample rate in hz
    BitsSample int     // Number of bits per sample (8 or 16)
    DataSize   int     // Total data size in bytes
    BytesSec   int     // Bytes per second
    TotalTime  float64 // Total time in seconds
}

WaveSpecs describes the characteristics of the audio encoded in a wave file.

func WaveCheck Uses

func WaveCheck(filepath string) (*WaveSpecs, error)

WaveCheck checks if the specified filepath corresponds to a an audio wave file. If the file is a valid wave file, return a pointer to WaveSpec structure with information about the encoded audio data.

Directories

PathSynopsis
alPackage al implements the Go bindings of a subset of the functions of the OpenAL C library.
ovPackage ov implements the Go bindings of a subset of the functions of the Ogg Vorbis File C library.
vorbisPackage vorbis implements the Go bindings of a subset (only one function) of the functions of the libvorbis library See API reference at: https://xiph.org/vorbis/doc/libvorbis/reference.html

Package audio imports 11 packages (graph) and is imported by 4 packages. Updated 2018-09-07. Refresh now. Tools for package owners.