Example #1
0
func RewindSources(sources ...Source) error {
	if len(sources) == 0 {
		return nil
	}
	C.alSourceRewindv(C.ALsizei(C.int(len(sources))), (*C.ALuint)(unsafe.Pointer(&sources[0])))
	return GetError()
}
Example #2
0
func (source Source) UnqueueBuffers(buffers ...Buffer) error {
	if len(buffers) == 0 {
		return nil
	}
	C.alSourceUnqueueBuffers(source.source, C.ALsizei(C.int(len(buffers))), (*C.ALuint)(unsafe.Pointer(&buffers[0])))
	return GetError()
}
Example #3
0
func DeleteBuffers(toDelete ...Buffer) error {
	if len(toDelete) == 0 {
		return nil
	}

	C.alDeleteBuffers(C.ALsizei(C.int(len(toDelete))), (*C.ALuint)(unsafe.Pointer(&toDelete[0])))
	return GetError()
}
Example #4
0
File: alut.go Project: nzlov/goal
func LoadMemoryFromFileImage(data interface{}, length int) (
	format al.ALenum, size int32, frequency float32, rdata unsafe.Pointer) {
	rdata = C.alutLoadMemoryFromFileImage(
		ptr(data), C.ALsizei(length),
		(*C.ALenum)(&format),
		(*C.ALsizei)(&size),
		(*C.ALfloat)(&frequency),
	)
	return
}
Example #5
0
func GenBuffers(numBuffers int) ([]Buffer, error) {
	if numBuffers == 0 {
		return nil, nil // AL guarantees that 0 will have no effect, so we'll save ourselves the C call
	}
	buf := make([]Buffer, numBuffers)
	C.alGenBuffers(C.ALsizei(C.int(numBuffers)), (*C.ALuint)(unsafe.Pointer(&buf[0]))) // Since a Buffer is a struct{C.ALuint} an array of Buffers is an array of ALuints
	if err := GetError(); err != nil {
		return nil, err
	}

	return buf, nil
}
Example #6
0
func DeleteBuffers(buffers []*Buffer) {
	n := len(buffers)
	bufferIds := make([]C.ALuint, n)

	for i, v := range buffers {
		forgetBuffer(v)
		bufferIds[i] = v.handle
	}

	C.walDeleteBuffers(C.ALsizei(n), unsafe.Pointer(&bufferIds[0]))
	return
}
Example #7
0
func GenSources(numSources int) ([]Source, error) {
	if numSources == 0 {
		return nil, nil // AL guarantees that 0 will have no effect, so we'll save ourselves the C call
	}
	buf := make([]Source, numSources)
	C.alGenSources(C.ALsizei(C.int(numSources)), (*C.ALuint)(unsafe.Pointer(&buf[0])))
	if err := GetError(); err != nil {
		return nil, err
	}

	return buf, nil
}
Example #8
0
func GenBuffers(n int) (buffers []*Buffer) {
	bufferIds := make([]C.ALuint, n)
	C.walGenBuffers(C.ALsizei(n), unsafe.Pointer(&bufferIds[0]))

	if GetError() != AlNoError {
		return
	}

	buffers = make([]*Buffer, n)
	for i, v := range bufferIds {
		b := new(Buffer)
		b.handle = v
		rememberBuffer(b)
		buffers[i] = b
	}
	return
}
Example #9
0
func (s *Sound) LoadPCMData() {
	format := 0

	if s.Channels > 1 {
		switch s.BitsPerSample {
		case 8:
			format = C.AL_FORMAT_STEREO8
		case 16:
			format = C.AL_FORMAT_STEREO16
		}
	} else {
		switch s.BitsPerSample {
		case 8:
			format = C.AL_FORMAT_MONO8
		case 16:
			format = C.AL_FORMAT_MONO16
		}
	}

	C.alGenBuffers(1, &s.buffer)
	C.alBufferData(s.buffer, C.ALenum(format), unsafe.Pointer(&s.Data[0]), C.ALsizei(s.Size), C.ALsizei(s.Frequency))
}
Example #10
0
// NewBuffers() creates n fresh buffers.
// Renamed, was GenBuffers.
func NewBuffers(n int) (buffers []Buffer) {
	buffers = make([]Buffer, n)
	C.walGenBuffers(C.ALsizei(n), unsafe.Pointer(&buffers[0]))
	return
}
Example #11
0
// Renamed, was SourcePausev.
func PauseSources(sources []Source) {
	C.walSourcePausev(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Example #12
0
// Renamed, was SourceRewindv.
func RewindSources(sources []Source) {
	C.walSourceRewindv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Example #13
0
// Renamed, was SourceStopv.
func StopSources(sources []Source) {
	C.walSourceStopv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Example #14
0
// Renamed, was SourcePlayv.
func PlaySources(sources []Source) {
	C.walSourcePlayv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Example #15
0
func alDeleteBuffers(b []Buffer) {
	C.call_alDeleteBuffers(alDeleteBuffersFunc, C.ALsizei(len(b)), (*C.ALuint)(unsafe.Pointer(&b[0])))
}
Example #16
0
func alSourceUnqueueBuffers(s Source, b []Buffer) {
	C.call_alSourceUnqueueBuffers(alSourceUnqueueBuffersFunc, C.ALuint(s), C.ALsizei(len(b)), (*C.ALuint)(unsafe.Pointer(&b[0])))
}
Example #17
0
func alSourceRewindv(s []Source) {
	C.call_alSourceRewindv(alSourceRewindvFunc, C.ALsizei(len(s)), (*C.ALuint)(unsafe.Pointer(&s[0])))
}
Example #18
0
func GenSources(sources []uint) {
	n := len(sources)
	C.walGenSources(C.ALsizei(n), unsafe.Pointer(&sources[0]))
}
Example #19
0
// SetData() specifies the sample data the buffer should use.
// For FormatMono16 and FormatStereo8 the data slice must be a
// multiple of two bytes long; for FormatStereo16 the data slice
// must be a multiple of four bytes long. The frequency is given
// in Hz.
// Renamed, was BufferData.
func (self Buffer) SetData(format int32, data []byte, frequency int32) {
	C.alBufferData(C.ALuint(self), C.ALenum(format), unsafe.Pointer(&data[0]),
		C.ALsizei(len(data)), C.ALsizei(frequency))
}
Example #20
0
File: alut.go Project: nzlov/goal
func CreateBufferFromFileImage(data interface{}, length int) {
	C.alutCreateBufferFromFileImage(ptr(data), C.ALsizei(length))
}
Example #21
0
// Renamed, was SourceStopv.
func (self Sources) Stop() {
	C.walSourceStopv(C.ALsizei(len(self)), unsafe.Pointer(&self[0]))
}
Example #22
0
// Renamed, was SourcePlayv.
func (self Sources) Play() {
	C.walSourcePlayv(C.ALsizei(len(self)), unsafe.Pointer(&self[0]))
}
Example #23
0
func alGenSources(n int) []Source {
	s := make([]Source, n)
	C.call_alGenSources(alGenSourcesFunc, C.ALsizei(n), (*C.ALuint)(unsafe.Pointer(&s[0])))
	return s
}
Example #24
0
// DeleteBuffers() deletes the given buffers.
func DeleteBuffers(buffers []Buffer) {
	n := len(buffers)
	C.walDeleteBuffers(C.ALsizei(n), unsafe.Pointer(&buffers[0]))
}
Example #25
0
func alDeleteSources(s []Source) {
	C.call_alDeleteSources(alDeleteSourcesFunc, C.ALsizei(len(s)), (*C.ALuint)(unsafe.Pointer(&s[0])))
}
Example #26
0
// Renamed, was SourceUnqueueBuffers.
func (self Source) UnqueueBuffers(buffers []Buffer) {
	C.walSourceUnqueueBuffers(C.ALuint(self), C.ALsizei(len(buffers)), unsafe.Pointer(&buffers[0]))
}
Example #27
0
func alGenBuffers(n int) []Buffer {
	s := make([]Buffer, n)
	C.call_alGenBuffers(alGenBuffersFunc, C.ALsizei(n), (*C.ALuint)(unsafe.Pointer(&s[0])))
	return s
}
Example #28
0
// NewSources() creates n sources.
// Renamed, was GenSources.
func NewSources(n int) (sources []Source) {
	sources = make([]Source, n)
	C.walGenSources(C.ALsizei(n), unsafe.Pointer(&sources[0]))
	return
}
Example #29
0
func alBufferData(b Buffer, format uint32, data []byte, freq int32) {
	C.call_alBufferData(alBufferDataFunc, C.ALuint(b), C.ALenum(format), unsafe.Pointer(&data[0]), C.ALsizei(len(data)), C.ALsizei(freq))
}
Example #30
0
// DeleteSources() deletes the given sources.
func DeleteSources(sources []Source) {
	n := len(sources)
	C.walDeleteSources(C.ALsizei(n), unsafe.Pointer(&sources[0]))
}