1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114 |
- package al
- import "C"
- import "runtime"
- import "unsafe"
- const (
- EVENT_AUDIO_STREAM_FRAGMENT = C.ALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT
- EVENT_AUDIO_STREAM_FINISHED = C.ALLEGRO_EVENT_AUDIO_STREAM_FINISHED
- EVENT_AUDIO_RECORDER_FRAGMENT = C.ALLEGRO_EVENT_AUDIO_RECORDER_FRAGMENT
- )
- func (self *Event) AUDIO_RECORDER_EVENT() *C.ALLEGRO_AUDIO_RECORDER_EVENT {
- return (*C.ALLEGRO_AUDIO_RECORDER_EVENT)(self.toPointer())
- }
- type AudioRecorderEvent C.ALLEGRO_AUDIO_RECORDER_EVENT
- type AudioDepth int
- func (self AudioDepth) toC() C.ALLEGRO_AUDIO_DEPTH {
- return C.ALLEGRO_AUDIO_DEPTH(self)
- }
- const (
- AUDIO_DEPTH_INT8 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT8
- AUDIO_DEPTH_INT16 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT16
- AUDIO_DEPTH_INT24 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT24
- AUDIO_DEPTH_UINT8 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT8
- AUDIO_DEPTH_UINT16 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT16
- AUDIO_DEPTH_UINT24 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT24
- AUDIO_DEPTH_FLOAT32 AudioDepth = C.ALLEGRO_AUDIO_DEPTH_FLOAT32
- AUDIO_DEPTH_UNSIGNED AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UNSIGNED
- )
- type ChannelConf int
- func (self ChannelConf) toC() C.ALLEGRO_CHANNEL_CONF {
- return (C.ALLEGRO_CHANNEL_CONF)(self)
- }
- const (
- CHANNEL_CONF_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_1
- CHANNEL_CONF_2 ChannelConf = C.ALLEGRO_CHANNEL_CONF_2
- CHANNEL_CONF_3 ChannelConf = C.ALLEGRO_CHANNEL_CONF_3
- CHANNEL_CONF_4 ChannelConf = C.ALLEGRO_CHANNEL_CONF_4
- CHANNEL_CONF_5_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_5_1
- CHANNEL_CONF_6_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_6_1
- CHANNEL_CONF_7_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_7_1
- MAX_CHANNELS ChannelConf = C.ALLEGRO_MAX_CHANNELS
- )
- type PlayMode int
- func (self PlayMode) toC() C.ALLEGRO_PLAYMODE {
- return (C.ALLEGRO_PLAYMODE)(self)
- }
- const (
- PLAYMODE_ONCE PlayMode = C.ALLEGRO_PLAYMODE_ONCE
- PLAYMODE_LOOP PlayMode = C.ALLEGRO_PLAYMODE_LOOP
- PLAYMODE_BIDIR PlayMode = C.ALLEGRO_PLAYMODE_BIDIR
- )
- type MixerQuality int
- func (self MixerQuality) toC() C.ALLEGRO_MIXER_QUALITY {
- return (C.ALLEGRO_MIXER_QUALITY)(self)
- }
- const (
- MIXER_QUALITY_POINT MixerQuality = C.ALLEGRO_MIXER_QUALITY_POINT
- MIXER_QUALITY_LINEAR MixerQuality = C.ALLEGRO_MIXER_QUALITY_LINEAR
- MIXER_QUALITY_CUBIC MixerQuality = C.ALLEGRO_MIXER_QUALITY_CUBIC
- )
- const AUDIO_PAN_NONE = -1000.0
- type AudioEventType int
- type Sample struct {
- handle *C.ALLEGRO_SAMPLE
- }
- type SampleId C.ALLEGRO_SAMPLE_ID
- func (self *SampleId) toC() *C.ALLEGRO_SAMPLE_ID {
- return (*C.ALLEGRO_SAMPLE_ID)(self)
- }
- type SampleInstance struct {
- handle *C.ALLEGRO_SAMPLE_INSTANCE
- }
- type AudioStream struct {
- handle *C.ALLEGRO_AUDIO_STREAM
- }
- type Mixer struct {
- handle *C.ALLEGRO_MIXER
- }
- type Voice struct {
- handle *C.ALLEGRO_VOICE
- }
- type AudioRecorder struct {
- handle *C.ALLEGRO_AUDIO_RECORDER
- }
- func (self *Sample) toC() *C.ALLEGRO_SAMPLE {
- return (*C.ALLEGRO_SAMPLE)(self.handle)
- }
- func (self *Sample) Destroy() {
- if self.handle != nil {
- C.al_destroy_sample(self.toC())
- }
- self.handle = nil
- }
- func (self *Sample) SetDestroyFinalizer() *Sample {
- if self != nil {
- runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
- }
- return self
- }
- func wrapSampleRaw(sample *C.ALLEGRO_SAMPLE) *Sample {
- if sample == nil {
- return nil
- }
- return &Sample{sample}
- }
- func wrapSample(sample *C.ALLEGRO_SAMPLE) *Sample {
- self := wrapSampleRaw(sample)
- if self != nil {
- runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
- }
- return self
- }
- func createSample(data []byte, samples uint, freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_SAMPLE {
-
-
- return C.al_create_sample(unsafe.Pointer(&data[0]), C.uint(samples),
- C.uint(freq), depth.toC(), chan_conf.toC(), b2cb(false))
- }
- func CreateSample(data []byte, samples uint, freq uint, depth AudioDepth, chan_conf ChannelConf) *Sample {
- return wrapSample(createSample(data, samples, freq, depth, chan_conf))
- }
- func (self *Sample) Frequency() uint {
- return uint(C.al_get_sample_frequency(self.handle))
- }
- func (self *Sample) Length() uint {
- return uint(C.al_get_sample_length(self.handle))
- }
- func (self *Sample) Depth() uint {
- return uint(C.al_get_sample_depth(self.handle))
- }
- func (self *Sample) Channels() uint {
- return uint(C.al_get_sample_channels(self.handle))
- }
- func (self *Sample) DataRaw() unsafe.Pointer {
- return (C.al_get_sample_data(self.handle))
- }
- func (self *SampleInstance) Frequency() uint {
- return uint(C.al_get_sample_instance_frequency(self.handle))
- }
- func (self *SampleInstance) Length() uint {
- return uint(C.al_get_sample_instance_length(self.handle))
- }
- func (self *SampleInstance) Position() uint {
- return uint(C.al_get_sample_instance_position(self.handle))
- }
- func (self *SampleInstance) Speed() float32 {
- return float32(C.al_get_sample_instance_speed(self.handle))
- }
- func (self *SampleInstance) Gain() float32 {
- return float32(C.al_get_sample_instance_gain(self.handle))
- }
- func (self *SampleInstance) Pan() float32 {
- return float32(C.al_get_sample_instance_pan(self.handle))
- }
- func (self *SampleInstance) Time() float32 {
- return float32(C.al_get_sample_instance_time(self.handle))
- }
- func (self *SampleInstance) Depth() AudioDepth {
- return AudioDepth(C.al_get_sample_instance_depth(self.handle))
- }
- func (self *SampleInstance) Channels() ChannelConf {
- return ChannelConf(C.al_get_sample_instance_channels(self.handle))
- }
- func (self *SampleInstance) Playmode() PlayMode {
- return PlayMode(C.al_get_sample_instance_playmode(self.handle))
- }
- func (self *SampleInstance) Playing() bool {
- return cb2b(C.al_get_sample_instance_playing(self.handle))
- }
- func (self *SampleInstance) Attached() bool {
- return cb2b(C.al_get_sample_instance_attached(self.handle))
- }
- func (self *SampleInstance) SetPosition(val uint) bool {
- return cb2b(C.al_set_sample_instance_position(self.handle, C.uint(val)))
- }
- func (self *SampleInstance) SetLength(val uint) bool {
- return cb2b(C.al_set_sample_instance_length(self.handle, C.uint(val)))
- }
- func (self *SampleInstance) SetSpeed(val float32) bool {
- return cb2b(C.al_set_sample_instance_speed(self.handle, C.float(val)))
- }
- func (self *SampleInstance) SetGain(val float32) bool {
- return cb2b(C.al_set_sample_instance_gain(self.handle, C.float(val)))
- }
- func (self *SampleInstance) SetPan(val float32) bool {
- return cb2b(C.al_set_sample_instance_pan(self.handle, C.float(val)))
- }
- func (self *SampleInstance) SetPlaymode(val PlayMode) bool {
- return cb2b(C.al_set_sample_instance_playmode(self.handle, val.toC()))
- }
- func (self *SampleInstance) SetPlaying(val bool) bool {
- return cb2b(C.al_set_sample_instance_playing(self.handle, b2cb(val)))
- }
- func (self *SampleInstance) Detach() bool {
- return cb2b(C.al_detach_sample_instance(self.handle))
- }
- func (self *SampleInstance) SetSample(val *Sample) bool {
- return cb2b(C.al_set_sample(self.handle, val.handle))
- }
- func (self *SampleInstance) SampleRaw() *Sample {
- return wrapSampleRaw(C.al_get_sample(self.handle))
- }
- func (self *SampleInstance) Play() bool {
- return cb2b(C.al_play_sample_instance(self.handle))
- }
- func (self *SampleInstance) Stop() bool {
- return cb2b(C.al_stop_sample_instance(self.handle))
- }
- func (self *AudioStream) toC() *C.ALLEGRO_AUDIO_STREAM {
- return (*C.ALLEGRO_AUDIO_STREAM)(self.handle)
- }
- func (self *AudioStream) Destroy() {
- if self.handle != nil {
- C.al_destroy_audio_stream(self.toC())
- }
- self.handle = nil
- }
- func (self *AudioStream) SetDestroyFinalizer() *AudioStream {
- if self != nil {
- runtime.SetFinalizer(self, func(me *AudioStream) { me.Destroy() })
- }
- return self
- }
- func wrapAudioStreamRaw(data *C.ALLEGRO_AUDIO_STREAM) *AudioStream {
- if data == nil {
- return nil
- }
- return &AudioStream{data}
- }
- func wrapAudioStream(data *C.ALLEGRO_AUDIO_STREAM) *AudioStream {
- self := wrapAudioStreamRaw(data)
- return self.SetDestroyFinalizer()
- }
- func CreateAudioStream(bufc, samples, freq uint, depth AudioDepth, chan_conf ChannelConf) *AudioStream {
- return wrapAudioStream(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
- C.uint(freq), depth.toC(), chan_conf.toC()))
- }
- func CreateAudioStreamRaw(bufc, samples, freq uint, depth AudioDepth, chan_conf ChannelConf) *AudioStream {
- return wrapAudioStreamRaw(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
- C.uint(freq), depth.toC(), chan_conf.toC()))
- }
- func (self *AudioStream) Drain() {
- C.al_drain_audio_stream(self.handle)
- }
- func (self *AudioStream) Frequency() uint {
- return uint(C.al_get_audio_stream_frequency(self.handle))
- }
- func (self *AudioStream) Length() uint {
- return uint(C.al_get_audio_stream_length(self.handle))
- }
- func (self *AudioStream) Speed() float32 {
- return float32(C.al_get_audio_stream_speed(self.handle))
- }
- func (self *AudioStream) Fragments() float32 {
- return float32(C.al_get_audio_stream_fragments(self.handle))
- }
- func (self *AudioStream) AvailableFragments() float32 {
- return float32(C.al_get_available_audio_stream_fragments(self.handle))
- }
- func (self *AudioStream) Gain() float32 {
- return float32(C.al_get_audio_stream_gain(self.handle))
- }
- func (self *AudioStream) Pan() float32 {
- return float32(C.al_get_audio_stream_pan(self.handle))
- }
- func (self *AudioStream) Depth() AudioDepth {
- return AudioDepth(C.al_get_audio_stream_depth(self.handle))
- }
- func (self *AudioStream) Channels() ChannelConf {
- return ChannelConf(C.al_get_audio_stream_channels(self.handle))
- }
- func (self *AudioStream) Playmode() PlayMode {
- return PlayMode(C.al_get_audio_stream_playmode(self.handle))
- }
- func (self *AudioStream) Playing() bool {
- return cb2b(C.al_get_audio_stream_playing(self.handle))
- }
- func (self *AudioStream) Attached() bool {
- return cb2b(C.al_get_audio_stream_attached(self.handle))
- }
- func (self *AudioStream) Fragment() unsafe.Pointer {
- return C.al_get_audio_stream_fragment(self.handle)
- }
- func (self *AudioStream) SetSpeed(val float32) bool {
- return cb2b(C.al_set_audio_stream_speed(self.handle, C.float(val)))
- }
- func (self *AudioStream) SetGain(val float32) bool {
- return cb2b(C.al_set_audio_stream_gain(self.handle, C.float(val)))
- }
- func (self *AudioStream) SetPan(val float32) bool {
- return cb2b(C.al_set_audio_stream_pan(self.handle, C.float(val)))
- }
- func (self *AudioStream) SetPlaymode(val PlayMode) bool {
- return cb2b(C.al_set_audio_stream_playmode(self.handle, val.toC()))
- }
- func (self *AudioStream) SetPlaying(val bool) bool {
- return cb2b(C.al_set_audio_stream_playing(self.handle, b2cb(val)))
- }
- func (self *AudioStream) Detach() bool {
- return cb2b(C.al_detach_audio_stream(self.handle))
- }
- func (self *AudioStream) SetFragment(ptr unsafe.Pointer) bool {
- return cb2b(C.al_set_audio_stream_fragment(self.handle, ptr))
- }
- func (self *AudioStream) Rewind() bool {
- return cb2b(C.al_rewind_audio_stream(self.handle))
- }
- func (self *AudioStream) SeekSeconds(secs float64) bool {
- return cb2b(C.al_seek_audio_stream_secs(self.handle, C.double(secs)))
- }
- func (self *AudioStream) PositionSeconds() (secs float64) {
- return float64(C.al_get_audio_stream_position_secs(self.handle))
- }
- func (self *AudioStream) LengthSeconds() (secs float64) {
- return float64(C.al_get_audio_stream_length_secs(self.handle))
- }
- func (self *AudioStream) LoopSeconds(start, end float64) bool {
- return cb2b(C.al_set_audio_stream_loop_secs(self.handle, C.double(start), C.double(end)))
- }
- func (self *AudioStream) Eventsource() *EventSource {
- return wrapEventSourceRaw(C.al_get_audio_stream_event_source(self.handle))
- }
- func (self *Mixer) toC() *C.ALLEGRO_MIXER {
- return (*C.ALLEGRO_MIXER)(self.handle)
- }
- func (self *Mixer) Destroy() {
- if self.handle != nil {
- C.al_destroy_mixer(self.toC())
- }
- self.handle = nil
- }
- func (self *Mixer) SetDestroyFinalizer() *Mixer {
- if self != nil {
- runtime.SetFinalizer(self, func(me *Mixer) { me.Destroy() })
- }
- return self
- }
- func wrapMixerRaw(data *C.ALLEGRO_MIXER) *Mixer {
- if data == nil {
- return nil
- }
- return &Mixer{data}
- }
- func wrapMixer(data *C.ALLEGRO_MIXER) *Mixer {
- self := wrapMixerRaw(data)
- return self.SetDestroyFinalizer()
- }
- func createMixer(freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_MIXER {
- return C.al_create_mixer(C.uint(freq), depth.toC(), chan_conf.toC())
- }
- func CreateMixerRaw(freq uint, depth AudioDepth, chan_conf ChannelConf) *Mixer {
- return wrapMixerRaw(createMixer(freq, depth, chan_conf))
- }
- func CreateMixer(freq uint, depth AudioDepth, chan_conf ChannelConf) *Mixer {
- return wrapMixer(createMixer(freq, depth, chan_conf))
- }
- func (mixer *Mixer) AttachSampleInstance(stream *SampleInstance) bool {
- return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
- }
- func (stream *SampleInstance) Attach(mixer *Mixer) bool {
- return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
- }
- func (mixer *Mixer) AttachAudioStream(stream *AudioStream) bool {
- return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
- }
- func (stream *AudioStream) Attach(mixer *Mixer) bool {
- return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
- }
- func (mixer *Mixer) AttachMixer(stream *Mixer) bool {
- return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
- }
- func (stream *Mixer) Attach(mixer *Mixer) bool {
- return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
- }
- func (self *Mixer) Frequency() uint {
- return uint(C.al_get_mixer_frequency(self.handle))
- }
- func (self *Mixer) Gain() float32 {
- return float32(C.al_get_mixer_gain(self.handle))
- }
- func (self *Mixer) Depth() AudioDepth {
- return AudioDepth(C.al_get_mixer_depth(self.handle))
- }
- func (self *Mixer) Channels() ChannelConf {
- return ChannelConf(C.al_get_mixer_channels(self.handle))
- }
- func (self *Mixer) Quality() MixerQuality {
- return MixerQuality(C.al_get_mixer_quality(self.handle))
- }
- func (self *Mixer) Playing() bool {
- return cb2b(C.al_get_mixer_playing(self.handle))
- }
- func (self *Mixer) Attached() bool {
- return cb2b(C.al_get_mixer_attached(self.handle))
- }
- func (self *Mixer) SetFrequency(val uint) bool {
- return cb2b(C.al_set_mixer_frequency(self.handle, C.uint(val)))
- }
- func (self *Mixer) SetQuality(val MixerQuality) bool {
- return cb2b(C.al_set_mixer_quality(self.handle, val.toC()))
- }
- func (self *Mixer) SetGain(val float32) bool {
- return cb2b(C.al_set_mixer_gain(self.handle, C.float(val)))
- }
- func (self *Mixer) SetPlaying(val bool) bool {
- return cb2b(C.al_set_mixer_playing(self.handle, b2cb(val)))
- }
- func (self *Mixer) Detach() bool {
- return cb2b(C.al_detach_mixer(self.handle))
- }
- func (self *Voice) toC() *C.ALLEGRO_VOICE {
- return (*C.ALLEGRO_VOICE)(self.handle)
- }
- func (self *Voice) Destroy() {
- if self.handle != nil {
- C.al_destroy_voice(self.toC())
- }
- self.handle = nil
- }
- func wrapVoiceRaw(data *C.ALLEGRO_VOICE) *Voice {
- if data == nil {
- return nil
- }
- return &Voice{data}
- }
- func (self *Voice) SetDestroyFinalizer() *Voice {
- if self != nil {
- runtime.SetFinalizer(self, func(me *Voice) { me.Destroy() })
- }
- return self
- }
- func wrapVoice(data *C.ALLEGRO_VOICE) *Voice {
- self := wrapVoiceRaw(data)
- return self.SetDestroyFinalizer()
- }
- func createVoice(freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_VOICE {
- return C.al_create_voice(C.uint(freq), depth.toC(), chan_conf.toC())
- }
- func CreateVoiceRaw(freq uint, depth AudioDepth, chan_conf ChannelConf) *Voice {
- return wrapVoiceRaw(createVoice(freq, depth, chan_conf))
- }
- func CreateVoice(freq uint, depth AudioDepth, chan_conf ChannelConf) *Voice {
- return wrapVoice(createVoice(freq, depth, chan_conf))
- }
- func (voice *Voice) AttachSampleInstance(stream *SampleInstance) bool {
- return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
- }
- func (stream *SampleInstance) AttachToVoice(voice *Voice) bool {
- return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
- }
- func (voice *Voice) AttachAudioStream(stream *AudioStream) bool {
- return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
- }
- func (stream *AudioStream) AttachToVoice(voice *Voice) bool {
- return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
- }
- func (mixer *Mixer) AttachToVoice(voice *Voice) bool {
- return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
- }
- func (voice *Voice) AttachMixer(mixer *Mixer) bool {
- return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
- }
- func (voice *Voice) Detach() {
- C.al_detach_voice(voice.handle)
- }
- func (self *Voice) Frequency() uint {
- return uint(C.al_get_voice_frequency(self.handle))
- }
- func (self *Voice) Position() uint {
- return uint(C.al_get_voice_position(self.handle))
- }
- func (self *Voice) Depth() AudioDepth {
- return AudioDepth(C.al_get_voice_depth(self.handle))
- }
- func (self *Voice) Channels() ChannelConf {
- return ChannelConf(C.al_get_voice_channels(self.handle))
- }
- func (self *Voice) Playing() bool {
- return cb2b(C.al_get_voice_playing(self.handle))
- }
- func (self *Voice) SetPosition(val uint) bool {
- return cb2b(C.al_set_voice_position(self.handle, C.uint(val)))
- }
- func (self *Voice) SetPlaying(val bool) bool {
- return cb2b(C.al_set_voice_playing(self.handle, b2cb(val)))
- }
- func InstallAudio() bool {
- return cb2b(C.al_install_audio())
- }
- func UninstallAudio() {
- C.al_uninstall_audio()
- }
- func IsAudioInstalled() bool {
- return cb2b(C.al_is_audio_installed())
- }
- func AudioVersion() uint32 {
- return uint32(C.al_get_allegro_audio_version())
- }
- func (self ChannelConf) ChannelCount() uint {
- return uint(C.al_get_channel_count(self.toC()))
- }
- func (self AudioDepth) Size() uint {
- return uint(C.al_get_audio_depth_size(self.toC()))
- }
- func ReserveSamples(samples int) bool {
- return cb2b(C.al_reserve_samples(C.int(samples)))
- }
- var defaultMixer *Mixer = nil
- func DefaultMixer() *Mixer {
- return wrapMixerRaw(C.al_get_default_mixer())
- }
- func (mixer *Mixer) SetDefault() {
-
- defaultMixer = mixer
- C.al_set_default_mixer(mixer.handle)
- }
- func RestoreDefaultMixer() {
-
- defaultMixer = nil
- C.al_restore_default_mixer()
- }
- func (self *Sample) Play(gain, pan, speed float32, loop PlayMode) (ok bool, id SampleId) {
- ok = cb2b(C.al_play_sample(self.handle, C.float(gain), C.float(pan), C.float(speed), loop.toC(), (&id).toC()))
- return ok, id
- }
- func (self *SampleId) Stop() {
- C.al_stop_sample(self.toC())
- }
- func StopSamples() {
- C.al_stop_samples()
- }
- func loadSample(filename string) *C.ALLEGRO_SAMPLE {
- cstr := cstr(filename)
- defer cstrFree(cstr)
- return C.al_load_sample(cstr)
- }
- func LoadSampleRaw(filename string) *Sample {
- return wrapSampleRaw(loadSample(filename))
- }
- func LoadSample(filename string) *Sample {
- return LoadSampleRaw(filename).SetDestroyFinalizer()
- }
- func (self *Sample) Save(filename string) bool {
- cstr := cstr(filename)
- defer cstrFree(cstr)
- return cb2b(C.al_save_sample(cstr, self.handle))
- }
- func loadAudioStream(filename string, buffer_count, samples uint) *C.ALLEGRO_AUDIO_STREAM {
- cstr := cstr(filename)
- defer cstrFree(cstr)
- return C.al_load_audio_stream(cstr, C.size_t(buffer_count), C.uint(samples))
- }
- func LoadAudioStreamRaw(filename string, buffer_count, samples uint) *AudioStream {
- return wrapAudioStreamRaw(loadAudioStream(filename, buffer_count, samples))
- }
- func LoadAudioStream(filename string, buffer_count, samples uint) *AudioStream {
- return LoadAudioStreamRaw(filename, buffer_count, samples).SetDestroyFinalizer()
- }
- type File struct {
- handle *C.ALLEGRO_FILE
- }
- func (self *File) Close() {
- if self.handle != nil {
- C.al_fclose(self.handle)
- }
- self.handle = nil
- }
- func (self *File) toC() * C.ALLEGRO_FILE {
- return self.handle
- }
- func wrapFileRaw(file *C.ALLEGRO_FILE) *File {
- if file == nil {
- return nil
- }
- return &File{file}
- }
- func openFile(filename, mode string) *C.ALLEGRO_FILE {
- cfilename := cstr(filename)
- defer cstrFree(cfilename)
- cmode := cstr(mode)
- defer cstrFree(cmode)
- return C.al_fopen(cfilename, cmode)
- }
- func (self *File) SetCloseFinalizer() *File {
- if self != nil {
- runtime.SetFinalizer(self, func(me *File) { me.Close() })
- }
- return self
- }
- func wrapFile(data *C.ALLEGRO_FILE) *File {
- self := wrapFileRaw(data)
- return self.SetCloseFinalizer()
- }
- func OpenFileRaw(filename, mode string) *File {
- self := openFile(filename, mode)
- return wrapFileRaw(self)
- }
- func OpenFile(filename, mode string) *File {
- self := OpenFileRaw(filename, mode)
- return self.SetCloseFinalizer()
- }
- func (self *File) loadSample(filetype string) *C.ALLEGRO_SAMPLE {
- cfiletype := cstr(filetype)
- defer cstrFree(cfiletype)
- return C.al_load_sample_f(self.handle, cfiletype)
- }
- func (self *File) SaveSample(filetype string, sample *Sample) bool {
- cfiletype := cstr(filetype)
- defer cstrFree(cfiletype)
- return cb2b(C.al_save_sample_f(self.handle, cfiletype, sample.handle))
- }
- func (self *File) loadAudioStream(filetype string, buffer_count,
- samples uint) *C.ALLEGRO_AUDIO_STREAM {
- cfiletype := cstr(filetype)
- defer cstrFree(cfiletype)
- return C.al_load_audio_stream_f(self.handle, cfiletype,
- C.size_t(buffer_count), C.uint(samples))
- }
- func (self *File) LoadSampleRaw(filetype string) *Sample {
- return wrapSampleRaw(loadSample(filetype))
- }
- func (self *File) LoadSample(filetype string) *Sample {
- return LoadSampleRaw(filetype).SetDestroyFinalizer()
- }
- func (self *File) LoadAudioStreamRaw(filetype string, buffer_count,
- samples uint) *AudioStream {
- return wrapAudioStreamRaw(loadAudioStream(filetype, buffer_count, samples))
- }
- func (self *File) LoadAudioStream(filetype string, buffer_count,
- samples uint) *AudioStream {
- return LoadAudioStreamRaw(filetype, buffer_count, samples).SetDestroyFinalizer()
- }
- func (self *AudioRecorder) toC() *C.ALLEGRO_AUDIO_RECORDER {
- return (*C.ALLEGRO_AUDIO_RECORDER)(self.handle)
- }
- func (self *AudioRecorder) Destroy() {
- if self.handle != nil {
- C.al_destroy_audio_recorder(self.toC())
- }
- self.handle = nil
- }
- func wrapAudioRecorderRaw(data *C.ALLEGRO_AUDIO_RECORDER) *AudioRecorder {
- if data == nil {
- return nil
- }
- return &AudioRecorder{data}
- }
- func (self *AudioRecorder) SetDestroyFinalizer() *AudioRecorder {
- if self != nil {
- runtime.SetFinalizer(self, func(me *AudioRecorder) { me.Destroy() })
- }
- return self
- }
- func wrapAudioRecorder(data *C.ALLEGRO_AUDIO_RECORDER) *AudioRecorder {
- self := wrapAudioRecorderRaw(data)
- return self.SetDestroyFinalizer()
- }
- func createAudioRecorder(fragment_count, samples, freq uint,
- depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_AUDIO_RECORDER {
- return C.al_create_audio_recorder(C.size_t(fragment_count), C.uint(samples),
- C.uint(freq), depth.toC(), chan_conf.toC())
- }
- func CreateAudioRecorderRaw(fragment_count, samples, freq uint,
- depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
- return wrapAudioRecorderRaw(createAudioRecorder(fragment_count, samples, freq, depth, chan_conf))
- }
- func CreateAudioRecorder(fragment_count, samples, freq uint,
- depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
- return CreateAudioRecorderRaw(fragment_count, samples,
- freq, depth, chan_conf).SetDestroyFinalizer()
- }
- func (self *AudioRecorder) Start() bool {
- return cb2b(C.al_start_audio_recorder(self.handle))
- }
- func (self *AudioRecorder) Stop() {
- C.al_stop_audio_recorder(self.handle)
- }
- func (self *AudioRecorder) EventSource() *EventSource {
- return wrapEventSourceRaw(C.al_get_audio_recorder_event_source(self.handle))
- }
- func wrapAudioRecorderEvent(event *C.ALLEGRO_AUDIO_RECORDER_EVENT) *AudioRecorderEvent {
- return (*AudioRecorderEvent)(event)
- }
- func (self *Event) AudioRecorderEvent() *AudioRecorderEvent {
- return wrapAudioRecorderEvent(C.al_get_audio_recorder_event(self.toC()))
- }
- func (self *AudioRecorderEvent) BufferPointer() unsafe.Pointer {
- return self.buffer
- }
- func (self *AudioRecorderEvent) Samples() uint {
- return uint(self.samples)
- }
- func (self *AudioRecorderEvent) Buffer() []byte {
- return C.GoBytes(self.buffer, C.int(self.samples))
- }
|