Sound defines the properties of a sound such as position, volume, pitch, etc.
More...
#include <Sound.hpp>
|
| | Sound () |
| | Default constructor.
|
| | Sound (const SoundBuffer &Buffer, bool Loop=false, float Pitch=1.f, float Volume=100.f, const Vector3f &Position=Vector3f(0, 0, 0)) |
| | Construct the sound from its parameters.
|
| | Sound (const Sound &Copy) |
| | Copy constructor.
|
| | ~Sound () |
| | Destructor.
|
| void | Play () |
| | Play the sound.
|
| void | Pause () |
| | Pause the sound.
|
| void | Stop () |
| | Stop the sound.
|
| void | SetBuffer (const SoundBuffer &Buffer) |
| | Set the source buffer.
|
| void | SetLoop (bool Loop) |
| | Set the sound loop state.
|
| void | SetPitch (float Pitch) |
| | Set the sound pitch.
|
| void | SetVolume (float Volume) |
| | Set the sound volume.
|
| void | SetPosition (float X, float Y, float Z) |
| | Set the sound position (take 3 values).
|
| void | SetPosition (const Vector3f &Position) |
| | Set the sound position (take a 3D vector).
|
| void | SetRelativeToListener (bool Relative) |
| | Make the sound's position relative to the listener's position, or absolute.
|
| void | SetMinDistance (float MinDistance) |
| | Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume.
|
| void | SetAttenuation (float Attenuation) |
| | Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener.
|
| void | SetPlayingOffset (float TimeOffset) |
| | Set the current playing position of the sound.
|
| const SoundBuffer * | GetBuffer () const |
| | Get the source buffer.
|
| bool | GetLoop () const |
| | Tell whether or not the sound is looping.
|
| float | GetPitch () const |
| | Get the pitch.
|
| float | GetVolume () const |
| | Get the volume.
|
| Vector3f | GetPosition () const |
| | Get the sound position.
|
| bool | IsRelativeToListener () const |
| | Tell if the sound's position is relative to the listener's position, or if it's absolute.
|
| float | GetMinDistance () const |
| | Get the minimum distance.
|
| float | GetAttenuation () const |
| | Get the attenuation factor.
|
| Status | GetStatus () const |
| | Get the status of the sound (stopped, paused, playing).
|
| float | GetPlayingOffset () const |
| | Get the current playing position of the sound.
|
| Sound & | operator= (const Sound &Other) |
| | Assignment operator.
|
| void | ResetBuffer () |
| | Reset the internal buffer.
|
Sound defines the properties of a sound such as position, volume, pitch, etc.
Definition at line 45 of file Sound.hpp.
◆ Status
Enumeration of the sound states.
| Enumerator |
|---|
| Stopped | Sound is not playing.
|
| Paused | Sound is paused.
|
| Playing | Sound is playing.
|
Definition at line 52 of file Sound.hpp.
◆ Sound() [1/3]
Default constructor.
Definition at line 38 of file Sound.cpp.
◆ Sound() [2/3]
| sf::Sound::Sound |
( |
const SoundBuffer & | Buffer, |
|
|
bool | Loop = false, |
|
|
float | Pitch = 1.f, |
|
|
float | Volume = 100.f, |
|
|
const Vector3f & | Position = Vector3f(0, 0, 0) ) |
|
explicit |
Construct the sound from its parameters.
- Parameters
-
| Buffer | : Sound buffer to play (NULL by default) |
| Loop | : Loop flag (false by default) |
| Pitch | : Value of the pitch (1 by default) |
| Volume | : Volume (100 by default) |
| Position | : Position (0, 0, 0 by default) |
Definition at line 48 of file Sound.cpp.
◆ Sound() [3/3]
| sf::Sound::Sound |
( |
const Sound & | Copy | ) |
|
Copy constructor.
- Parameters
-
Definition at line 64 of file Sound.cpp.
◆ ~Sound()
◆ GetAttenuation()
| float sf::Sound::GetAttenuation |
( |
| ) |
const |
Get the attenuation factor.
- Returns
- Attenuation factor of the sound
Definition at line 319 of file Sound.cpp.
◆ GetBuffer()
Get the source buffer.
- Returns
- Sound buffer bound to the sound (can be NULL)
Definition at line 237 of file Sound.cpp.
◆ GetLoop()
| bool sf::Sound::GetLoop |
( |
| ) |
const |
Tell whether or not the sound is looping.
- Returns
- True if the sound is looping, false otherwise
Definition at line 246 of file Sound.cpp.
◆ GetMinDistance()
| float sf::Sound::GetMinDistance |
( |
| ) |
const |
Get the minimum distance.
- Returns
- Minimum distance for the sound
Definition at line 307 of file Sound.cpp.
◆ GetPitch()
| float sf::Sound::GetPitch |
( |
| ) |
const |
Get the pitch.
- Returns
- Pitch value
Definition at line 258 of file Sound.cpp.
◆ GetPlayingOffset()
| float sf::Sound::GetPlayingOffset |
( |
| ) |
const |
Get the current playing position of the sound.
- Returns
- Current playing position, expressed in seconds
Definition at line 331 of file Sound.cpp.
◆ GetPosition()
| Vector3f sf::Sound::GetPosition |
( |
| ) |
const |
Get the sound position.
- Returns
- Position of the sound in the world
Definition at line 282 of file Sound.cpp.
◆ GetStatus()
Get the status of the sound (stopped, paused, playing).
- Returns
- Current status of the sound
Definition at line 343 of file Sound.cpp.
◆ GetVolume()
| float sf::Sound::GetVolume |
( |
| ) |
const |
Get the volume.
- Returns
- Volume value (in range [1, 100])
Definition at line 270 of file Sound.cpp.
◆ IsRelativeToListener()
| bool sf::Sound::IsRelativeToListener |
( |
| ) |
const |
Tell if the sound's position is relative to the listener's position, or if it's absolute.
- Returns
- True if the position is relative, false if it's absolute
Definition at line 295 of file Sound.cpp.
◆ operator=()
| Sound & sf::Sound::operator= |
( |
const Sound & | Other | ) |
|
Assignment operator.
- Parameters
-
| Other | : Instance to assign |
- Returns
- Reference to the sound
Definition at line 363 of file Sound.cpp.
◆ Pause()
| void sf::Sound::Pause |
( |
| ) |
|
◆ Play()
◆ ResetBuffer()
| void sf::Sound::ResetBuffer |
( |
| ) |
|
Reset the internal buffer.
This function is for internal use only, you don't have to use it.
Definition at line 394 of file Sound.cpp.
◆ SetAttenuation()
| void sf::Sound::SetAttenuation |
( |
float | Attenuation | ) |
|
Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener.
The default attenuation factor 1.0
- Parameters
-
| Attenuation | : New attenuation factor for the sound |
The default attenuation factor 1.0
Definition at line 219 of file Sound.cpp.
◆ SetBuffer()
| void sf::Sound::SetBuffer |
( |
const SoundBuffer & | Buffer | ) |
|
Set the source buffer.
- Parameters
-
| Buffer | : New sound buffer to bind to the sound |
Definition at line 130 of file Sound.cpp.
◆ SetLoop()
| void sf::Sound::SetLoop |
( |
bool | Loop | ) |
|
Set the sound loop state.
This parameter is disabled by default
- Parameters
-
| Loop | : True to play in loop, false to play once |
Definition at line 149 of file Sound.cpp.
◆ SetMinDistance()
| void sf::Sound::SetMinDistance |
( |
float | MinDistance | ) |
|
Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume.
The default minimum distance is 1.0
- Parameters
-
| MinDistance | : New minimum distance for the sound |
The default minimum distance is 1.0
Definition at line 208 of file Sound.cpp.
◆ SetPitch()
| void sf::Sound::SetPitch |
( |
float | Pitch | ) |
|
Set the sound pitch.
The default pitch is 1
- Parameters
-
Definition at line 158 of file Sound.cpp.
◆ SetPlayingOffset()
| void sf::Sound::SetPlayingOffset |
( |
float | TimeOffset | ) |
|
Set the current playing position of the sound.
- Parameters
-
| TimeOffset | : New playing position, expressed in seconds |
Definition at line 228 of file Sound.cpp.
◆ SetPosition() [1/2]
| void sf::Sound::SetPosition |
( |
const Vector3f & | Position | ) |
|
Set the sound position (take a 3D vector).
The default position is (0, 0, 0)
- Parameters
-
| Position | : Position of the sound in the world |
The default position is (0, 0, 0)
Definition at line 186 of file Sound.cpp.
◆ SetPosition() [2/2]
| void sf::Sound::SetPosition |
( |
float | X, |
|
|
float | Y, |
|
|
float | Z ) |
Set the sound position (take 3 values).
The default position is (0, 0, 0)
- Parameters
-
| X,Y,Z | : Position of the sound in the world |
The default position is (0, 0, 0)
Definition at line 176 of file Sound.cpp.
◆ SetRelativeToListener()
| void sf::Sound::SetRelativeToListener |
( |
bool | Relative | ) |
|
Make the sound's position relative to the listener's position, or absolute.
The default value is false (absolute)
- Parameters
-
| Relative | : True to set the position relative, false to set it absolute |
The default value is false (absolute)
Definition at line 197 of file Sound.cpp.
◆ SetVolume()
| void sf::Sound::SetVolume |
( |
float | Volume | ) |
|
Set the sound volume.
The default volume is 100
- Parameters
-
| Volume | : Volume (in range [0, 100]) |
Definition at line 167 of file Sound.cpp.
◆ Stop()
◆ SoundStream
The documentation for this class was generated from the following files: