Пример #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()
}
Пример #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()
}
Пример #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()
}
Пример #4
0
Файл: alut.go Проект: 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
}
Пример #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
}
Пример #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
}
Пример #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
}
Пример #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
}
Пример #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))
}
Пример #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
}
Пример #11
0
// Renamed, was SourcePausev.
func PauseSources(sources []Source) {
	C.walSourcePausev(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Пример #12
0
// Renamed, was SourceRewindv.
func RewindSources(sources []Source) {
	C.walSourceRewindv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Пример #13
0
// Renamed, was SourceStopv.
func StopSources(sources []Source) {
	C.walSourceStopv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Пример #14
0
// Renamed, was SourcePlayv.
func PlaySources(sources []Source) {
	C.walSourcePlayv(C.ALsizei(len(sources)), unsafe.Pointer(&sources[0]))
}
Пример #15
0
func alDeleteBuffers(b []Buffer) {
	C.call_alDeleteBuffers(alDeleteBuffersFunc, C.ALsizei(len(b)), (*C.ALuint)(unsafe.Pointer(&b[0])))
}
Пример #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])))
}
Пример #17
0
func alSourceRewindv(s []Source) {
	C.call_alSourceRewindv(alSourceRewindvFunc, C.ALsizei(len(s)), (*C.ALuint)(unsafe.Pointer(&s[0])))
}
Пример #18
0
func GenSources(sources []uint) {
	n := len(sources)
	C.walGenSources(C.ALsizei(n), unsafe.Pointer(&sources[0]))
}
Пример #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))
}
Пример #20
0
Файл: alut.go Проект: nzlov/goal
func CreateBufferFromFileImage(data interface{}, length int) {
	C.alutCreateBufferFromFileImage(ptr(data), C.ALsizei(length))
}
Пример #21
0
// Renamed, was SourceStopv.
func (self Sources) Stop() {
	C.walSourceStopv(C.ALsizei(len(self)), unsafe.Pointer(&self[0]))
}
Пример #22
0
// Renamed, was SourcePlayv.
func (self Sources) Play() {
	C.walSourcePlayv(C.ALsizei(len(self)), unsafe.Pointer(&self[0]))
}
Пример #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
}
Пример #24
0
// DeleteBuffers() deletes the given buffers.
func DeleteBuffers(buffers []Buffer) {
	n := len(buffers)
	C.walDeleteBuffers(C.ALsizei(n), unsafe.Pointer(&buffers[0]))
}
Пример #25
0
func alDeleteSources(s []Source) {
	C.call_alDeleteSources(alDeleteSourcesFunc, C.ALsizei(len(s)), (*C.ALuint)(unsafe.Pointer(&s[0])))
}
Пример #26
0
// Renamed, was SourceUnqueueBuffers.
func (self Source) UnqueueBuffers(buffers []Buffer) {
	C.walSourceUnqueueBuffers(C.ALuint(self), C.ALsizei(len(buffers)), unsafe.Pointer(&buffers[0]))
}
Пример #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
}
Пример #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
}
Пример #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))
}
Пример #30
0
// DeleteSources() deletes the given sources.
func DeleteSources(sources []Source) {
	n := len(sources)
	C.walDeleteSources(C.ALsizei(n), unsafe.Pointer(&sources[0]))
}