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));
AudioResource()
Default constructor.
SoundBuffer is the low-level for loading and manipulating sound buffers.
float GetPlayingOffset() const
Get the current playing position of the sound.
void SetMinDistance(float MinDistance)
Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum...
void ResetBuffer()
Reset the internal buffer.
void SetVolume(float Volume)
Set the sound volume.
const SoundBuffer * GetBuffer() const
Get the source buffer.
bool GetLoop() const
Tell whether or not the sound is looping.
Status
Enumeration of the sound states.
@ Playing
Sound is playing.
@ Stopped
Sound is not playing.
bool IsRelativeToListener() const
Tell if the sound's position is relative to the listener's position, or if it's absolute.
Sound()
Default constructor.
void SetLoop(bool Loop)
Set the sound loop state.
float GetVolume() const
Get the volume.
void Pause()
Pause the sound.
float GetAttenuation() const
Get the attenuation factor.
void SetRelativeToListener(bool Relative)
Make the sound's position relative to the listener's position, or absolute.
Vector3f GetPosition() const
Get the sound position.
void SetBuffer(const SoundBuffer &Buffer)
Set the source buffer.
void Stop()
Stop the sound.
void SetPosition(float X, float Y, float Z)
Set the sound position (take 3 values).
float GetPitch() const
Get the pitch.
Sound & operator=(const Sound &Other)
Assignment operator.
void SetAttenuation(float Attenuation)
Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with d...
Status GetStatus() const
Get the status of the sound (stopped, paused, playing).
float GetMinDistance() const
Get the minimum distance.
void SetPlayingOffset(float TimeOffset)
Set the current playing position of the sound.
void SetPitch(float Pitch)
Set the sound pitch.
void Play()
Play the sound.
T z
Z coordinate of the vector.
T x
X coordinate of the vector.
T y
Y coordinate of the vector.