28 #include <SFML/Audio/Sound.hpp>
29 #include <SFML/Audio/SoundBuffer.hpp>
30 #include <SFML/Audio/OpenAL.hpp>
40 ALCheck(alGenSources(1, &mySource));
41 ALCheck(alSourcei(mySource, AL_BUFFER, 0));
51 ALCheck(alGenSources(1, &mySource));
68 ALCheck(alGenSources(1, &mySource));
92 ALCheck(alSourcei(mySource, AL_BUFFER, 0));
93 myBuffer->DetachSound(
this);
95 ALCheck(alDeleteSources(1, &mySource));
105 ALCheck(alSourcePlay(mySource));
114 ALCheck(alSourcePause(mySource));
123 ALCheck(alSourceStop(mySource));
136 myBuffer->DetachSound(
this);
141 myBuffer->AttachSound(
this);
142 ALCheck(alSourcei(mySource, AL_BUFFER, myBuffer->myBuffer));
151 ALCheck(alSourcei(mySource, AL_LOOPING, Loop));
160 ALCheck(alSourcef(mySource, AL_PITCH, Pitch));
169 ALCheck(alSourcef(mySource, AL_GAIN, Volume * 0.01f));
178 ALCheck(alSource3f(mySource, AL_POSITION, X, Y, Z));
199 ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, Relative));
210 ALCheck(alSourcef(mySource, AL_REFERENCE_DISTANCE, MinDistance));
221 ALCheck(alSourcef(mySource, AL_ROLLOFF_FACTOR, Attenuation));
230 ALCheck(alSourcef(mySource, AL_SEC_OFFSET, TimeOffset));
249 ALCheck(alGetSourcei(mySource, AL_LOOPING, &Loop));
261 ALCheck(alGetSourcef(mySource, AL_PITCH, &Pitch));
273 ALCheck(alGetSourcef(mySource, AL_GAIN, &Gain));
285 ALCheck(alGetSource3f(mySource, AL_POSITION, &Position.
x, &Position.
y, &Position.
z));
298 ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &Relative));
300 return Relative != 0;
310 ALCheck(alGetSourcef(mySource, AL_REFERENCE_DISTANCE, &MinDistance));
322 ALCheck(alGetSourcef(mySource, AL_ROLLOFF_FACTOR, &Attenuation));
333 ALfloat Seconds = 0.f;
334 ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &Seconds));
346 ALCheck(alGetSourcei(mySource, AL_SOURCE_STATE, &State));
351 case AL_STOPPED :
return Stopped;
352 case AL_PAUSED :
return Paused;
353 case AL_PLAYING :
return Playing;
372 myBuffer->DetachSound(
this);
400 ALCheck(alSourcei(mySource, AL_BUFFER, 0));
void SetPitch(float Pitch)
Set the sound pitch.
void SetRelativeToListener(bool Relative)
Make the sound's position relative to the listener's position, or absolute.
void Stop()
Stop the sound.
T z
Z coordinate of the vector.
void Play()
Play the sound.
void SetPosition(float X, float Y, float Z)
Set the sound position (take 3 values).
Sound defines the properties of a sound such as position, volume, pitch, etc.
Status GetStatus() const
Get the status of the sound (stopped, paused, playing)
void SetAttenuation(float Attenuation)
Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with d...
Sound()
Default constructor.
bool IsRelativeToListener() const
Tell if the sound's position is relative to the listener's position, or if it's absolute.
Vector3f GetPosition() const
Get the sound position.
Vector3 is an utility class for manipulating 3 dimensional vectors.
bool GetLoop() const
Tell whether or not the sound is looping.
void SetPlayingOffset(float TimeOffset)
Set the current playing position of the sound.
float GetPlayingOffset() const
Get the current playing position of the sound.
Sound & operator=(const Sound &Other)
Assignment operator.
void Pause()
Pause the sound.
T y
Y coordinate of the vector.
float GetMinDistance() const
Get the minimum distance.
void SetBuffer(const SoundBuffer &Buffer)
Set the source buffer.
const SoundBuffer * GetBuffer() const
Get the source buffer.
void ResetBuffer()
Reset the internal buffer.
void SetVolume(float Volume)
Set the sound volume.
float GetAttenuation() const
Get the attenuation factor.
void SetLoop(bool Loop)
Set the sound loop state.
T x
X coordinate of the vector.
Status
Enumeration of the sound states.
float GetVolume() const
Get the volume.
void SetMinDistance(float MinDistance)
Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum...
float GetPitch() const
Get the pitch.
SoundBuffer is the low-level for loading and manipulating sound buffers.
Abstract base class for every class that owns a device-dependant resource – allow them to initialize...