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