示例#1
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
}
示例#2
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
}
示例#3
0
// Renamed, was Sourcef.
func (self Source) Setf(param int32, value float32) {
	C.alSourcef(C.ALuint(self), C.ALenum(param), C.ALfloat(value))
}
示例#4
0
文件: source.go 项目: nzlov/goal
/*
 * Set Source parameters
 */
func (source Source) Sourcef(param ALenum, value float32) {
	C.alSourcef(C.ALuint(source), C.ALenum(param), C.ALfloat(value))
}
示例#5
0
文件: al_pc.go 项目: tanema/amore
func alSourcef(s Source, k int, v float32) {
	C.alSourcef(C.ALuint(s), C.ALenum(k), C.ALfloat(v))
}
示例#6
0
func (source Source) SetConeOuterGain(val float32) error {
	C.alSourcef(source.source, C.AL_CONE_OUTER_GAIN, C.ALfloat(C.float(val)))
	return GetError()
}
示例#7
0
文件: al.go 项目: Miaque/mojo
func setSourcef(s Source, param int, v float32) {
	C.alSourcef(C.ALuint(s), C.ALenum(param), C.ALfloat(v))
}
示例#8
0
func (source Source) SetMaxGain(val float32) error {
	C.alSourcef(source.source, C.AL_MAX_GAIN, C.ALfloat(C.float(val)))
	return GetError()
}
示例#9
0
func (source Source) SetReferenceDist(val float32) error {
	C.alSourcef(source.source, C.AL_REFERENCE_DISTANCE, C.ALfloat(C.float(val)))
	return GetError()
}
示例#10
0
func (source Source) SetRolloff(val float32) error {
	C.alSourcef(source.source, C.AL_ROLLOFF_FACTOR, C.ALfloat(C.float(val)))
	return GetError()
}
示例#11
0
func (source Source) SetMaxDist(val float32) error {
	C.alSourcef(source.source, C.AL_MAX_DISTANCE, C.ALfloat(C.float(val)))
	return GetError()
}
示例#12
0
func (source Source) SetPitch(val float32) error {
	C.alSourcef(source.source, C.AL_PITCH, C.ALfloat(C.float(val)))
	return GetError()
}