Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | List of all members
sf::SoundStream Class Referenceabstract

SoundStream is a streamed sound, ie samples are acquired while the sound is playing. More...

#include <SoundStream.hpp>

Inheritance diagram for sf::SoundStream:
sf::Thread sf::Sound sf::Music

Classes

struct  Chunk
 Structure defining a chunk of audio data to stream. More...
 

Public Types

enum  Status
 Enumeration of the sound states. More...
 

Public Member Functions

virtual ~SoundStream ()
 Virtual destructor. More...
 
void Play ()
 Start playing the audio stream. More...
 
void Stop ()
 Stop playing the audio stream. More...
 
unsigned int GetChannelsCount () const
 Return the number of channels (1 = mono, 2 = stereo) More...
 
unsigned int GetSampleRate () const
 Get the stream sample rate. More...
 
Status GetStatus () const
 Get the status of the stream (stopped, paused, playing) More...
 
float GetPlayingOffset () const
 Get the current playing position of the stream. More...
 
void SetLoop (bool Loop)
 Set the stream loop state. More...
 
bool GetLoop () const
 Tell whether or not the stream is looping. More...
 
void Pause ()
 Pause the sound. More...
 
void SetPitch (float Pitch)
 Set the sound pitch. More...
 
void SetVolume (float Volume)
 Set the sound volume. More...
 
void SetPosition (float X, float Y, float Z)
 Set the sound position (take 3 values). More...
 
void SetPosition (const Vector3f &Position)
 Set the sound position (take a 3D vector). More...
 
void SetRelativeToListener (bool Relative)
 Make the sound's position relative to the listener's position, or absolute. More...
 
void SetMinDistance (float MinDistance)
 Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume. More...
 
void SetAttenuation (float Attenuation)
 Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener. More...
 
float GetPitch () const
 Get the pitch. More...
 
float GetVolume () const
 Get the volume. More...
 
Vector3f GetPosition () const
 Get the sound position. More...
 
bool IsRelativeToListener () const
 Tell if the sound's position is relative to the listener's position, or if it's absolute. More...
 
float GetMinDistance () const
 Get the minimum distance. More...
 
float GetAttenuation () const
 Get the attenuation factor. More...
 

Protected Member Functions

 SoundStream ()
 Default constructor. More...
 
void Initialize (unsigned int ChannelsCount, unsigned int SampleRate)
 Set the audio stream parameters, you must call it before Play() More...
 

Private Types

typedef void(* FuncType) (void *)
 

Private Member Functions

void Launch ()
 Create and run the thread. More...
 
void Wait ()
 Wait until the thread finishes. More...
 
void Terminate ()
 Terminate the thread Terminating a thread with this function is not safe, you should rather try to make the thread function terminate by itself. More...
 
void Pause ()
 Pause the sound. More...
 
void SetBuffer (const SoundBuffer &Buffer)
 Set the source buffer. More...
 
void SetPitch (float Pitch)
 Set the sound pitch. More...
 
void SetVolume (float Volume)
 Set the sound volume. More...
 
void SetPosition (float X, float Y, float Z)
 Set the sound position (take 3 values). More...
 
void SetPosition (const Vector3f &Position)
 Set the sound position (take a 3D vector). More...
 
void SetRelativeToListener (bool Relative)
 Make the sound's position relative to the listener's position, or absolute. More...
 
void SetMinDistance (float MinDistance)
 Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume. More...
 
void SetAttenuation (float Attenuation)
 Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener. More...
 
void SetPlayingOffset (float TimeOffset)
 Set the current playing position of the sound. More...
 
const SoundBufferGetBuffer () const
 Get the source buffer. More...
 
float GetPitch () const
 Get the pitch. More...
 
float GetVolume () const
 Get the volume. More...
 
Vector3f GetPosition () const
 Get the sound position. More...
 
bool IsRelativeToListener () const
 Tell if the sound's position is relative to the listener's position, or if it's absolute. More...
 
float GetMinDistance () const
 Get the minimum distance. More...
 
float GetAttenuation () const
 Get the attenuation factor. More...
 
void ResetBuffer ()
 Reset the internal buffer. More...
 

Detailed Description

SoundStream is a streamed sound, ie samples are acquired while the sound is playing.

Use it for big sounds that would require hundreds of MB in memory (see Music), or for streaming sound from the network

Definition at line 44 of file SoundStream.hpp.

Member Enumeration Documentation

◆ Status

Enumeration of the sound states.

Definition at line 52 of file Sound.hpp.

Constructor & Destructor Documentation

◆ ~SoundStream()

sf::SoundStream::~SoundStream ( )
virtual

Virtual destructor.

Definition at line 54 of file SoundStream.cpp.

◆ SoundStream()

sf::SoundStream::SoundStream ( )
protected

Default constructor.

Definition at line 39 of file SoundStream.cpp.

Member Function Documentation

◆ GetAttenuation()

float sf::Sound::GetAttenuation

Get the attenuation factor.

Returns
Attenuation factor of the sound

Definition at line 319 of file Sound.cpp.

◆ GetChannelsCount()

unsigned int sf::SoundStream::GetChannelsCount ( ) const

Return the number of channels (1 = mono, 2 = stereo)

Return the number of channels (1 = mono, 2 = stereo, ...)

Returns
Number of channels

Definition at line 126 of file SoundStream.cpp.

◆ GetLoop()

bool sf::SoundStream::GetLoop ( ) const

Tell whether or not the stream is looping.

Tell whether or not the music is looping.

Returns
True if the music is looping, false otherwise

Definition at line 180 of file SoundStream.cpp.

◆ GetMinDistance()

float sf::Sound::GetMinDistance

Get the minimum distance.

Returns
Minimum distance for the sound

Definition at line 307 of file Sound.cpp.

◆ GetPitch()

float sf::Sound::GetPitch

Get the pitch.

Returns
Pitch value

Definition at line 258 of file Sound.cpp.

◆ GetPlayingOffset()

float sf::SoundStream::GetPlayingOffset ( ) const

Get the current playing position of the stream.

Returns
Current playing position, expressed in seconds

Definition at line 162 of file SoundStream.cpp.

◆ GetPosition()

Vector3f sf::Sound::GetPosition

Get the sound position.

Returns
Position of the sound in the world

Definition at line 282 of file Sound.cpp.

◆ GetSampleRate()

unsigned int sf::SoundStream::GetSampleRate ( ) const

Get the stream sample rate.

Get the sound frequency (sample rate)

Returns
Stream frequency (number of samples per second)

Definition at line 135 of file SoundStream.cpp.

◆ GetStatus()

Sound::Status sf::SoundStream::GetStatus ( ) const

Get the status of the stream (stopped, paused, playing)

Get the status of the sound (stopped, paused, playing)

Returns
Current status of the sound

Definition at line 144 of file SoundStream.cpp.

◆ GetVolume()

float sf::Sound::GetVolume

Get the volume.

Returns
Volume value (in range [1, 100])

Definition at line 270 of file Sound.cpp.

◆ Initialize()

void sf::SoundStream::Initialize ( unsigned int  ChannelsCount,
unsigned int  SampleRate 
)
protected

Set the audio stream parameters, you must call it before Play()

Parameters
ChannelsCount: Number of channels
SampleRate: Sample rate

Definition at line 64 of file SoundStream.cpp.

◆ IsRelativeToListener()

bool sf::Sound::IsRelativeToListener

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.

◆ Pause()

void sf::Sound::Pause

Pause the sound.

Definition at line 112 of file Sound.cpp.

◆ Play()

void sf::SoundStream::Play ( )

Start playing the audio stream.

Definition at line 85 of file SoundStream.cpp.

◆ SetAttenuation()

void sf::Sound::SetAttenuation

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.

◆ SetLoop()

void sf::SoundStream::SetLoop ( bool  Loop)

Set the stream loop state.

Set the music loop state.

This parameter is disabled by default

Parameters
Loop: True to play in loop, false to play once

Definition at line 171 of file SoundStream.cpp.

◆ SetMinDistance()

void sf::Sound::SetMinDistance

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

Set the sound pitch.

The default pitch is 1

Parameters
Pitch: New pitch

Definition at line 158 of file Sound.cpp.

◆ SetPosition() [1/2]

void sf::Sound::SetPosition

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

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

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

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()

void sf::SoundStream::Stop ( )

Stop playing the audio stream.

Definition at line 115 of file SoundStream.cpp.


The documentation for this class was generated from the following files: