CL_SoundBuffer_Session provides control over a playing soundeffect. More...
#include <soundbuffer_session.h>
Public Member Functions | |
Construction | |
CL_SoundBuffer_Session () | |
Creates a null instance. | |
virtual | ~CL_SoundBuffer_Session () |
Attributes | |
bool | is_null () const |
Returns true if this object is invalid. | |
void | throw_if_null () const |
Throw an exception if this object is invalid. | |
int | get_position () const |
Returns the current sample position of the playback. | |
float | get_position_relative () const |
Returns the sample position relative to the full length. | |
int | get_length () const |
Returns the total length (in samples) of the sound buffer played. | |
int | get_frequency () const |
Returns the frequency of the session. | |
float | get_volume () const |
Returns the linear relative volume of the soundeffect. | |
float | get_pan () const |
Returns the current pan (in a measure from -1 -> 1). | |
bool | get_looping () const |
Returns whether this session loops. | |
bool | is_playing () |
Returns true if the session is playing. | |
Operations | |
bool | set_position (int new_pos) |
Sets the session position to 'new_pos'. | |
bool | set_position_relative (float new_pos) |
Sets the relative position of the session. | |
bool | set_end_position (int pos) |
Sets the end position within the current stream. | |
void | set_frequency (int new_freq) |
Sets the frequency of the session. | |
void | set_volume (float new_volume) |
Sets the volume of the session in a relative measure (0->1). | |
void | set_pan (float new_pan) |
Sets the panning of the session played in measures from -1 -> 1. | |
void | play () |
Starts playback of the session. | |
void | stop () |
Stops playback of the session. | |
void | set_looping (bool loop) |
Determines whether this session should loop. | |
void | add_filter (CL_SoundFilter &filter) |
Adds the sound filter to the session. See CL_SoundFilter for details. | |
void | remove_filter (CL_SoundFilter &filter) |
Remove the sound filter from the session. See CL_SoundFilter for details. | |
Implementation | |
| |
class | CL_SoundBuffer |
class | CL_SoundOutput_Impl |
CL_SoundBuffer_Session provides control over a playing soundeffect.
Whenever a soundbuffer is played, it returns a CL_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.
CL_SoundBuffer_Session::CL_SoundBuffer_Session | ( | ) |
Creates a null instance.
virtual CL_SoundBuffer_Session::~CL_SoundBuffer_Session | ( | ) | [virtual] |
void CL_SoundBuffer_Session::add_filter | ( | CL_SoundFilter & | filter | ) |
Adds the sound filter to the session. See CL_SoundFilter for details.
filter | Sound filter to pass sound through. |
int CL_SoundBuffer_Session::get_frequency | ( | ) | const |
Returns the frequency of the session.
int CL_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 CL_SoundBuffer_Session::get_looping | ( | ) | const |
Returns whether this session loops.
float CL_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 CL_SoundBuffer_Session::get_position | ( | ) | const |
Returns the current sample position of the playback.
float CL_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 CL_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 CL_SoundBuffer_Session::is_null | ( | ) | const [inline] |
Returns true if this object is invalid.
bool CL_SoundBuffer_Session::is_playing | ( | ) |
Returns true if the session is playing.
void CL_SoundBuffer_Session::play | ( | ) |
Starts playback of the session.
void CL_SoundBuffer_Session::remove_filter | ( | CL_SoundFilter & | filter | ) |
Remove the sound filter from the session. See CL_SoundFilter for details.
bool CL_SoundBuffer_Session::set_end_position | ( | int | pos | ) |
Sets the end position within the current stream.
pos | = End position. |
void CL_SoundBuffer_Session::set_frequency | ( | int | new_freq | ) |
Sets the frequency of the session.
new_freq | New frequency of session. |
void CL_SoundBuffer_Session::set_looping | ( | bool | loop | ) |
Determines whether this session should loop.
loop | true if session should loop, false otherwise |
void CL_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).
new_pan | New pan of the session played. |
bool CL_SoundBuffer_Session::set_position | ( | int | new_pos | ) |
Sets the session position to 'new_pos'.
new_pos | = The new position of the session. |
bool CL_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.
new_pos | New relative position. |
void CL_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".
new_volume | New volume of session. |
void CL_SoundBuffer_Session::stop | ( | ) |
Stops playback of the session.
void CL_SoundBuffer_Session::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.
friend class CL_SoundBuffer [friend] |
friend class CL_SoundOutput_Impl [friend] |