Exemple #1
0
// Play will play the sound. Volume ( 1.0 is normal volume, 0 is silence )
// Returns the PlayInstance that can be used to stop the source while playing
func (s *Sound) Play(volume float32) (request PlayInstance) {
	source, err := requestSource()
	if err != nil {
		return request
	}
	C.alSourcef(source.id, C.AL_GAIN, C.ALfloat(volume))
	C.alSourcei(source.id, C.AL_SOURCE_RELATIVE, C.AL_TRUE)
	C.alSource3f(source.id, C.AL_POSITION, 0, 0, 0)
	C.alSourcei(source.id, C.AL_BUFFER, C.ALint(s.buffer))

	source.setToPlay()
	request.id = source.requestId
	request.src = source
	return request
}
Exemple #2
0
// Play will play the sound at a given position, the falloff distance in which the sound's volume is cut in half,
// and the volume ( 1.0 is normal volume, 0 is silence )
// It will return the PlayInstance that can be used to stop the source while playing
// Remember that in order for the 3D audio to work properly that the audio needs to be all in one channel, not stereo!
func (s *Sound) Play3D(x, y, z, falloff, volume float32) (request PlayInstance) {
	source, err := requestSource()
	if err != nil {
		return request
	}
	C.alSourcef(source.id, C.AL_GAIN, C.ALfloat(volume))
	C.alSourcei(source.id, C.AL_SOURCE_RELATIVE, C.AL_FALSE)
	C.alSourcef(source.id, C.AL_REFERENCE_DISTANCE, C.ALfloat(falloff))
	C.alSource3f(source.id, C.AL_POSITION, C.ALfloat(x), C.ALfloat(y), C.ALfloat(z))
	C.alSourcei(source.id, C.AL_BUFFER, C.ALint(s.buffer))

	source.setToPlay()
	request.id = source.requestId
	request.src = source
	return request
}
Exemple #3
0
// Renamed, was Source3f.
func (self Source) Set3f(param int32, value1, value2, value3 float32) {
	C.alSource3f(C.ALuint(self), C.ALenum(param), C.ALfloat(value1), C.ALfloat(value2), C.ALfloat(value3))
}
Exemple #4
0
func (source Source) Source3f(
	param ALenum, value1, value2, value3 float32) {
	C.alSource3f(
		C.ALuint(source), C.ALenum(param),
		C.ALfloat(value1), C.ALfloat(value2), C.ALfloat(value3))
}
Exemple #5
0
func (source Source) SetDirection3f(x, y, z float32) error {
	C.alSource3f(source.source, C.AL_DIRECTION, C.ALfloat(C.float(x)), C.ALfloat(C.float(y)), C.ALfloat(C.float(z)))
	return GetError()
}
Exemple #6
0
func (source Source) SetVelocity3f(x, y, z float32) error {
	C.alSource3f(source.source, C.AL_VELOCITY, C.ALfloat(C.float(x)), C.ALfloat(C.float(y)), C.ALfloat(C.float(z)))
	return GetError()
}
Exemple #7
0
func (source Source) SetPosition3f(x, y, z float32) error {
	C.alSource3f(source.source, C.AL_POSITION, C.ALfloat(C.float(x)), C.ALfloat(C.float(y)), C.ALfloat(C.float(z)))
	return GetError()
}