示例#1
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
}
示例#2
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))
}
示例#3
0
// Not really any different from GenBuffers(1), except it returns a single buffer instead of a slice
func GenBuffer() (buf Buffer, err error) {
	C.alGenBuffers(C.ALsizei(C.int(1)), &buf.buffer)
	err = GetError()
	return
}
示例#4
0
文件: al_pc.go 项目: tanema/amore
func alGenBuffers(n int) []Buffer {
	s := make([]Buffer, n)
	C.alGenBuffers(C.ALsizei(n), (*C.ALuint)(unsafe.Pointer(&s[0])))
	return s
}
示例#5
0
文件: buffer.go 项目: nzlov/goal
func GenBuffers(buffers []Buffer) {
	if len(buffers) > 0 {
		C.alGenBuffers(C.ALsizei(len(buffers)), (*C.ALuint)(&buffers[0]))
	}
}
示例#6
0
文件: buffer.go 项目: nzlov/goal
func GenBuffer() Buffer {
	var b C.ALuint
	C.alGenBuffers(1, &b)
	return Buffer(b)
}