audio

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioFile

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

AudioFile represents an audio file

func NewAudioFile

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

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

func (*AudioFile) Close

func (af *AudioFile) Close() error

Close closes the audiofile

func (*AudioFile) CurrentTime

func (af *AudioFile) CurrentTime() float64

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

func (*AudioFile) Info

func (af *AudioFile) Info() AudioInfo

Info returns the audio info structure for this audio file

func (*AudioFile) Looping

func (af *AudioFile) Looping() bool

Looping returns the current looping state of this audio file

func (*AudioFile) Read

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

Read reads decoded data from the audio file

func (*AudioFile) Seek

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

Seek sets the file reading position relative to the origin

func (*AudioFile) SetLooping

func (af *AudioFile) SetLooping(looping bool)

SetLooping sets the looping state of this audio file

type AudioInfo

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

type Listener struct {
	core.Node
}

Listener is an audio listener positioned in space

func NewListener

func NewListener() *Listener

NewListener returns a pointer to a new Listener object.

func (*Listener) Gain

func (l *Listener) Gain() float32

Gain returns the gain of the listener

func (*Listener) Render

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

func (l *Listener) SetGain(gain float32)

SetGain sets the gain of the listener

func (*Listener) SetVelocity

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

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

func (*Listener) SetVelocityVec

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

SetVelocityVec sets the velocity of the listener with a vector

func (*Listener) Velocity

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

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

func (*Listener) VelocityVec

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

VelocityVec returns the velocity of the listener as a vector

type Player

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

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

func (p *Player) CurrentTime() float64

CurrentTime returns the current time in seconds spent in the stream

func (*Player) Dispose

func (p *Player) Dispose()

Dispose disposes of this player resources

func (*Player) Gain

func (p *Player) Gain() float32

Gain returns the current gain (volume) of this player

func (*Player) InnerCone

func (p *Player) InnerCone() float32

InnerCone returns the inner cone angle in degrees

func (*Player) Looping

func (p *Player) Looping() bool

Looping returns the current looping state of this player

func (*Player) MaxGain

func (p *Player) MaxGain() float32

MaxGain returns the current maximum gain of this player

func (*Player) MinGain

func (p *Player) MinGain() float32

MinGain returns the current minimum gain of this player

func (*Player) OuterCone

func (p *Player) OuterCone() float32

OuterCone returns the outer cone angle in degrees

func (*Player) Pause

func (p *Player) Pause()

Pause sets the player in the pause state

func (*Player) Pitch

func (p *Player) Pitch() float32

Pitch returns the current pitch factor of this player

func (*Player) Play

func (p *Player) Play() error

Play starts playing this player

func (*Player) Render

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

func (p *Player) SetGain(gain float32)

SetGain sets the gain (volume) of this player

func (*Player) SetInnerCone

func (p *Player) SetInnerCone(inner float32)

SetInnerCone sets the inner cone angle in degrees

func (*Player) SetLooping

func (p *Player) SetLooping(looping bool)

SetLooping sets the looping state of this player

func (*Player) SetMaxGain

func (p *Player) SetMaxGain(gain float32)

SetMaxGain sets the maximum gain (volume) of this player

func (*Player) SetMinGain

func (p *Player) SetMinGain(gain float32)

SetMinGain sets the minimum gain (volume) of this player

func (*Player) SetOuterCone

func (p *Player) SetOuterCone(outer float32)

SetOuterCone sets the outer cone angle in degrees

func (*Player) SetPitch

func (p *Player) SetPitch(pitch float32)

SetPitch sets the pitch factor of this player

func (*Player) SetRolloffFactor

func (p *Player) SetRolloffFactor(rfactor float32)

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

func (*Player) SetVelocity

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

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

func (p *Player) State() int

State returns the current state of this player

func (*Player) Stop

func (p *Player) Stop()

Stop stops the player

func (*Player) TotalTime

func (p *Player) TotalTime() float64

TotalTime returns the total time in seconds to play this stream

func (*Player) Velocity

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

Velocity returns this player velocity

func (*Player) VelocityVec

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

VelocityVec returns this player velocity vector

type WaveSpecs

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

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

Path Synopsis
Package al implements the Go bindings of a subset of the functions of the OpenAL C library.
Package al implements the Go bindings of a subset of the functions of the OpenAL C library.
Package ov implements the Go bindings of a subset of the functions of the Ogg Vorbis File C library.
Package ov implements the Go bindings of a subset of the functions of the Ogg Vorbis File C library.
Package 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 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

Jump to

Keyboard shortcuts

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