Documentation ¶
Index ¶
- Constants
- func Destroy()
- func Init(df DecoderFactory)
- type AudioManger
- func (am *AudioManger) LoadSound(name string, ft FileType, sType SourceType) (id uint16, sound *Sound)
- func (am *AudioManger) LoadStatic(name string, ft FileType) (id uint16, sd *StaticData)
- func (am *AudioManger) LoadStream(name string, ft FileType) (id uint16, data *StreamData)
- func (am *AudioManger) Sound(id uint16) (sound *Sound, ok bool)
- func (am *AudioManger) UnloadSound(id uint16)
- type BufferPlayer
- func (p *BufferPlayer) Pause()
- func (p *BufferPlayer) Play(data *StaticData)
- func (p *BufferPlayer) Resume()
- func (p *BufferPlayer) SetLoop(loop int)
- func (p *BufferPlayer) SetVolume(v float32)
- func (p *BufferPlayer) State() uint32
- func (p *BufferPlayer) Stop()
- func (p *BufferPlayer) Volume() float32
- type Decoder
- type DecoderFactory
- type Engine
- type FileType
- type FormatEnum
- type Sound
- type SoundChannel
- type SoundPollCallback
- type SoundPool
- func (sp *SoundPool) Destroy()
- func (sp *SoundPool) GetChanVolume(chanId int) (float32, bool)
- func (sp *SoundPool) Mute(mute bool)
- func (sp *SoundPool) Pause(pause bool)
- func (sp *SoundPool) PauseChan(chanId int)
- func (sp *SoundPool) Play(id uint16, priority int) (chanId int)
- func (sp *SoundPool) ResumeChan(chanId int)
- func (sp *SoundPool) SetCallback(cb SoundPollCallback)
- func (sp *SoundPool) SetChanVolume(chanId int, v float32)
- func (sp *SoundPool) SetLoop(chanId int, loop int)
- func (sp *SoundPool) SetVolume(v float32)
- func (sp *SoundPool) StopChan(chanId int)
- func (sp *SoundPool) Tick()
- func (sp *SoundPool) Volume() float32
- type SourceType
- type StaticData
- type StreamData
- type StreamPlayer
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 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) 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 ¶
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) Initialize ¶
func (eng *Engine) Initialize()
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 SoundPool ¶
type SoundPool struct { R *AudioManger // contains filtered or unexported fields }
manager priority and audio play
func NewSoundPool ¶
func NewSoundPool() *SoundPool
func (*SoundPool) GetChanVolume ¶
GetChanVolume gets volume from the specified channel. Return false if not found.
func (*SoundPool) ResumeChan ¶
func (*SoundPool) SetCallback ¶
func (sp *SoundPool) SetCallback(cb SoundPollCallback)
func (*SoundPool) SetChanVolume ¶
SetChanVolume sets volume for the specified channel. It may fail if can't find the channel.
type StaticData ¶
type StaticData struct {
// contains filtered or unexported fields
}
StaticData is small audio sampler, which will be load into memory directly.
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
Click to show internal directories.
Click to hide internal directories.