sine

package
v0.0.0-...-e1c21c9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Zlib Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const (
	FormatMono8    = 0x1100
	FormatMono16   = 0x1101
	FormatStereo8  = 0x1102
	FormatStereo16 = 0x1103
)
View Source
const (
	NoError          = C.AL_NO_ERROR
	InvalidName      = C.AL_INVALID_NAME
	InvalidEnum      = C.AL_INVALID_ENUM
	InvalidValue     = C.AL_INVALID_VALUE
	InvalidOperation = C.AL_INVALID_OPERATION
	OutOfMemory      = C.AL_OUT_OF_MEMORY
)

AL error

View Source
const (
	Initial = 0x1011
	Playing = 0x1012
	Paused  = 0x1013
	Stopped = 0x1014
)

AL state

View Source
const (
	MaxChannelSize = 8
)
View Source
const MaxSoundPoolSize = 128 // 128=96+32
View Source
const MaxStaticData = 96
View Source
const MaxStreamData = 32

Variables

This section is empty.

Functions

func Destroy

func Destroy()

func Init

func Init(df DecoderFactory)

Types

type AudioManger

type AudioManger struct {
	// contains filtered or unexported fields
}
var R *AudioManger

public field

func NewAudioManager

func NewAudioManager() *AudioManger

func (*AudioManger) LoadSound

func (am *AudioManger) LoadSound(name string, ft FileType, sType SourceType) (id uint16, sound *Sound)

/ 加载数据,得到 Sound 实例 / 此时应该得出, 采样率,是否Stream等,

func (*AudioManger) LoadStatic

func (am *AudioManger) LoadStatic(name string, ft FileType) (id uint16, sd *StaticData)

func (*AudioManger) LoadStream

func (am *AudioManger) LoadStream(name string, ft FileType) (id uint16, data *StreamData)

func (*AudioManger) Sound

func (am *AudioManger) Sound(id uint16) (sound *Sound, ok bool)

func (*AudioManger) UnloadSound

func (am *AudioManger) UnloadSound(id uint16)

type BufferPlayer

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

BufferPlayer can play audio loaded as StaticData.

func NewBufferPlayer

func NewBufferPlayer() (bp *BufferPlayer)

func (*BufferPlayer) Pause

func (p *BufferPlayer) Pause()

func (*BufferPlayer) Play

func (p *BufferPlayer) Play(data *StaticData)

func (*BufferPlayer) Resume

func (p *BufferPlayer) Resume()

func (*BufferPlayer) SetLoop

func (p *BufferPlayer) SetLoop(loop int)

func (*BufferPlayer) SetVolume

func (p *BufferPlayer) SetVolume(v float32)

func (*BufferPlayer) State

func (p *BufferPlayer) State() uint32

func (*BufferPlayer) Stop

func (p *BufferPlayer) Stop()

func (*BufferPlayer) Volume

func (p *BufferPlayer) Volume() float32

type Decoder

type Decoder interface {
	// helper method for in-memory decode
	FullDecode(file res.File) (d []byte, numChan, bitDepth, freq int32, err error)

	// stream decode
	Decode() int
	NumOfChan() int32
	BitDepth() int32
	SampleRate() int32
	Buffer() []byte
	ReachEnd() bool
	Rewind()
}

audio file decoder

type DecoderFactory

type DecoderFactory interface {
	NewDecoder(name string, fileType FileType) (Decoder, error)
}

decoder factory, we use'll used it to create new decoder by file-type

type Engine

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

func (*Engine) Destroy

func (eng *Engine) Destroy()

func (*Engine) Initialize

func (eng *Engine) Initialize()

type FileType

type FileType uint8
const (
	None FileType = iota
	WAV
	VORB

	// NOT IMPLEMENT YET
	OPUS
	FLAC
)

type FormatEnum

type FormatEnum uint8
const (
	FormatNone FormatEnum = iota
	Mono8
	Mono16
	Stereo8
	Stereo16
)

type Sound

type Sound struct {
	Type     SourceType
	Priority uint16
	Data     interface{}
}

sound represent a audio segment

type SoundChannel

type SoundChannel struct {
	BufferPlayer
	// contains filtered or unexported fields
}

type SoundPollCallback

type SoundPollCallback func(id uint16)

TODO

type SoundPool

type SoundPool struct {
	R *AudioManger
	// contains filtered or unexported fields
}

manager priority and audio play

func NewSoundPool

func NewSoundPool() *SoundPool

func (*SoundPool) Destroy

func (sp *SoundPool) Destroy()

func (*SoundPool) GetChanVolume

func (sp *SoundPool) GetChanVolume(chanId int) (float32, bool)

GetChanVolume gets volume from the specified channel. Return false if not found.

func (*SoundPool) Mute

func (sp *SoundPool) Mute(mute bool)

func (*SoundPool) Pause

func (sp *SoundPool) Pause(pause bool)

func (*SoundPool) PauseChan

func (sp *SoundPool) PauseChan(chanId int)

func (*SoundPool) Play

func (sp *SoundPool) Play(id uint16, priority int) (chanId int)

func (*SoundPool) ResumeChan

func (sp *SoundPool) ResumeChan(chanId int)

func (*SoundPool) SetCallback

func (sp *SoundPool) SetCallback(cb SoundPollCallback)

func (*SoundPool) SetChanVolume

func (sp *SoundPool) SetChanVolume(chanId int, v float32)

SetChanVolume sets volume for the specified channel. It may fail if can't find the channel.

func (*SoundPool) SetLoop

func (sp *SoundPool) SetLoop(chanId int, loop int)

func (*SoundPool) SetVolume

func (sp *SoundPool) SetVolume(v float32)

SetVolume set volume for all the channels in the pool.

func (*SoundPool) StopChan

func (sp *SoundPool) StopChan(chanId int)

func (*SoundPool) Tick

func (sp *SoundPool) Tick()

TODO: This method has little Latency. Burst effects will use up all the play-channel quickly.

func (*SoundPool) Volume

func (sp *SoundPool) Volume() float32

type SourceType

type SourceType uint8
const (
	Static SourceType = iota
	Stream
)

type StaticData

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

StaticData is small audio sampler, which will be load into memory directly.

func (*StaticData) Create

func (d *StaticData) Create(fmt uint32, bits []byte, freq int32)

type StreamData

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

StreamData will decode pcm-data at runtime. It's used to play big audio files(like .ogg).

func (*StreamData) Create

func (d *StreamData) Create(file string, ft FileType)

type StreamPlayer

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

StreamPlayer can play audio loaded as StreamData.

func NewStreamPlayer

func NewStreamPlayer() (sp *StreamPlayer)

func (*StreamPlayer) Pause

func (p *StreamPlayer) Pause()

func (*StreamPlayer) Play

func (p *StreamPlayer) Play(stream *StreamData)

func (*StreamPlayer) Resume

func (p *StreamPlayer) Resume()

func (*StreamPlayer) SetVolume

func (p *StreamPlayer) SetVolume(v float32)

func (*StreamPlayer) State

func (p *StreamPlayer) State() uint32

func (*StreamPlayer) Stop

func (p *StreamPlayer) Stop()

func (*StreamPlayer) Tick

func (p *StreamPlayer) Tick()

func (*StreamPlayer) Volume

func (p *StreamPlayer) Volume() float32

Jump to

Keyboard shortcuts

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