clan::SoundBuffer_Session Class Reference

SoundBuffer_Session provides control over a playing soundeffect. More...

#include <soundbuffer_session.h>

Public Member Functions

 SoundBuffer_Session ()
 Creates a null instance. More...
 
virtual ~SoundBuffer_Session ()
 
void add_filter (SoundFilter &filter)
 Adds the sound filter to the session. See SoundFilter for details. More...
 
int get_frequency () const
 Returns the frequency of the session. More...
 
int get_length () const
 Returns the total length (in samples) of the sound buffer played. More...
 
bool get_looping () const
 Returns whether this session loops. More...
 
float get_pan () const
 Returns the current pan (in a measure from -1 -> 1). More...
 
int get_position () const
 Returns the current sample position of the playback. More...
 
float get_position_relative () const
 Returns the sample position relative to the full length. More...
 
float get_volume () const
 Returns the linear relative volume of the soundeffect. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
bool is_playing ()
 Returns true if the session is playing. More...
 
void play ()
 Starts playback of the session. More...
 
void remove_filter (SoundFilter &filter)
 Remove the sound filter from the session. See SoundFilter for details. More...
 
bool set_end_position (int pos)
 Sets the end position within the current stream. More...
 
void set_frequency (int new_freq)
 Sets the frequency of the session. More...
 
void set_looping (bool loop)
 Determines whether this session should loop. More...
 
void set_pan (float new_pan)
 Sets the panning of the session played in measures from -1 -> 1. More...
 
bool set_position (int new_pos)
 Sets the session position to 'new_pos'. More...
 
bool set_position_relative (float new_pos)
 Sets the relative position of the session. More...
 
void set_volume (float new_volume)
 Sets the volume of the session in a relative measure (0->1) More...
 
void stop ()
 Stops playback of the session. More...
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Friends

class SoundBuffer
 
class SoundOutput_Impl
 

Detailed Description

SoundBuffer_Session provides control over a playing soundeffect.

Whenever a soundbuffer is played, it returns a SoundBuffer_Session class, which can be used to control the sound (its volume, pitch, pan, position). It can also be used to retrigger the sound or to stop it.

Constructor & Destructor Documentation

clan::SoundBuffer_Session::SoundBuffer_Session ( )

Creates a null instance.

virtual clan::SoundBuffer_Session::~SoundBuffer_Session ( )
virtual

Member Function Documentation

void clan::SoundBuffer_Session::add_filter ( SoundFilter filter)

Adds the sound filter to the session. See SoundFilter for details.

Parameters
filterSound filter to pass sound through.
int clan::SoundBuffer_Session::get_frequency ( ) const

Returns the frequency of the session.

int clan::SoundBuffer_Session::get_length ( ) const

Returns the total length (in samples) of the sound buffer played.

Value returned will be -1 if the length is unknown (in case of non-static soundeffects like streamed sound)

bool clan::SoundBuffer_Session::get_looping ( ) const

Returns whether this session loops.

Returns
true if session should loop, false otherwise
float clan::SoundBuffer_Session::get_pan ( ) const

Returns the current pan (in a measure from -1 -> 1).

-1 means the soundeffect is only playing in the left speaker, and 1 means the soundeffect is only playing in the right speaker.

int clan::SoundBuffer_Session::get_position ( ) const

Returns the current sample position of the playback.

float clan::SoundBuffer_Session::get_position_relative ( ) const

Returns the sample position relative to the full length.

The value returned will be between 0 and 1, where 0 means the session is at the beginning, and 1 means that the soundeffect has reached the end.

float clan::SoundBuffer_Session::get_volume ( ) const

Returns the linear relative volume of the soundeffect.

0 means the soundeffect is muted, 1 means the soundeffect is playing at "max" volume.

bool clan::SoundBuffer_Session::is_null ( ) const
inline

Returns true if this object is invalid.

bool clan::SoundBuffer_Session::is_playing ( )

Returns true if the session is playing.

void clan::SoundBuffer_Session::play ( )

Starts playback of the session.

void clan::SoundBuffer_Session::remove_filter ( SoundFilter filter)

Remove the sound filter from the session. See SoundFilter for details.

bool clan::SoundBuffer_Session::set_end_position ( int  pos)

Sets the end position within the current stream.

Parameters
pos= End position.
Returns
True for success. False otherwise.
void clan::SoundBuffer_Session::set_frequency ( int  new_freq)

Sets the frequency of the session.

Parameters
new_freqNew frequency of session.
void clan::SoundBuffer_Session::set_looping ( bool  loop)

Determines whether this session should loop.

Parameters
looptrue if session should loop, false otherwise
void clan::SoundBuffer_Session::set_pan ( float  new_pan)

Sets the panning of the session played in measures from -1 -> 1.

Setting the pan with a value of -1 will pan the session to the extreme left (left speaker only), 1 will pan the session to the extreme right (right speaker only).

Parameters
new_panNew pan of the session played.
Returns
Returns true if the operation completed sucecsfully.
bool clan::SoundBuffer_Session::set_position ( int  new_pos)

Sets the session position to 'new_pos'.

Parameters
new_pos= The new position of the session.
Returns
Returns true if operation completed succesfully.
bool clan::SoundBuffer_Session::set_position_relative ( float  new_pos)

Sets the relative position of the session.

Value must be between 0 and 1, where 0 sets the session to the beginning, and 1 sets it to the end of the sound buffer.

Parameters
new_posNew relative position.
Returns
Returns true if operation completed succesfully.
void clan::SoundBuffer_Session::set_volume ( float  new_volume)

Sets the volume of the session in a relative measure (0->1)

A value of 0 will effectively mute the sound (although it will still be sampled), and a value of 1 will set the volume to "max".

Parameters
new_volumeNew volume of session.
Returns
Returns true if the operation completed succesfully.
void clan::SoundBuffer_Session::stop ( )

Stops playback of the session.

void clan::SoundBuffer_Session::throw_if_null ( ) const

Throw an exception if this object is invalid.

Friends And Related Function Documentation

friend class SoundBuffer
friend
friend class SoundOutput_Impl
friend

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