clan::SoundBuffer_Session Class Reference - ClanLib SDK
Description: clan::SoundBuffer_Session Class Reference

Public Member Functions | Friends | List of all members
clan::SoundBuffer_Session Class Reference
clanSound Audio Mixing

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

`#include <soundbuffer_session.h>`

## Public Member Functions
| SoundBuffer_Session ()
| Creates a null instance.
virtual | ~SoundBuffer_Session ()
void | add_filter (SoundFilter &filter)
| Adds the sound filter to the session. See SoundFilter for details.
int | get_frequency () const
| Returns the frequency of the session.
int | get_length () const
| Returns the total length (in samples) of the sound buffer played.
bool | get_looping () const
| Returns whether this session loops.
float | get_pan () const
| Returns the current pan (in a measure from -1 -> 1).
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.
float | get_volume () const
| Returns the linear relative volume of the soundeffect.
bool | is_null () const
| Returns true if this object is invalid.
bool | is_playing ()
| Returns true if the session is playing.
void | play ()
| Starts playback of the session.
void | remove_filter (SoundFilter &filter)
| Remove the sound filter from the session. See SoundFilter for details.
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_looping (bool loop)
| Determines whether this session should loop.
void | set_pan (float new_pan)
| Sets the panning of the session played in measures from -1 -> 1.
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.
void | set_volume (float new_volume)
| Sets the volume of the session in a relative measure (0->1)
void | stop ()
| Stops playback of the session.
void | throw_if_null () const
| Throw an exception if this object is invalid.

## 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

## ◆ SoundBuffer_Session()

clan::SoundBuffer_Session::SoundBuffer_Session | ( |  | ) |

Creates a null instance.

## ◆ ~SoundBuffer_Session()

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

## Member Function Documentation

## ◆ add_filter()

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

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

Parameters

  filter | Sound filter to pass sound through.

## ◆ get_frequency()

int clan::SoundBuffer_Session::get_frequency | ( |  | ) | const

Returns the frequency of the session.

## ◆ get_length()

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)

## ◆ get_looping()

bool clan::SoundBuffer_Session::get_looping | ( |  | ) | const

Returns whether this session loops.

Returns
  true if session should loop, false otherwise

## ◆ get_pan()

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.

## ◆ get_position()

int clan::SoundBuffer_Session::get_position | ( |  | ) | const

Returns the current sample position of the playback.

## ◆ get_position_relative()

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.

## ◆ get_volume()

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.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ is_playing()

bool clan::SoundBuffer_Session::is_playing | ( |  | ) |

Returns true if the session is playing.

## ◆ play()

void clan::SoundBuffer_Session::play | ( |  | ) |

Starts playback of the session.

## ◆ remove_filter()

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

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

References SoundBuffer.

## ◆ set_end_position()

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.

## ◆ set_frequency()

void clan::SoundBuffer_Session::set_frequency | ( | int | new_freq | ) |

Sets the frequency of the session.

Parameters

  new_freq | New frequency of session.

## ◆ set_looping()

void clan::SoundBuffer_Session::set_looping | ( | bool | loop | ) |

Determines whether this session should loop.

Parameters

  loop | true if session should loop, false otherwise

## ◆ set_pan()

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_pan | New pan of the session played.

Returns
  Returns true if the operation completed sucecsfully.

## ◆ set_position()

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.

## ◆ set_position_relative()

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_pos | New relative position.

Returns
  Returns true if operation completed succesfully.

## ◆ set_volume()

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_volume | New volume of session.

Returns
  Returns true if the operation completed succesfully.

## ◆ stop()

void clan::SoundBuffer_Session::stop | ( |  | ) |

Stops playback of the session.

## ◆ throw_if_null()

void clan::SoundBuffer_Session::throw_if_null | ( |  | ) | const

Throw an exception if this object is invalid.

## Friends And Related Symbol Documentation

## ◆ SoundBuffer

friend class SoundBuffer
| friend

References SoundBuffer.

Referenced by remove_filter(), and SoundBuffer.

## ◆ SoundOutput_Impl

friend class SoundOutput_Impl
| friend

References SoundOutput_Impl.

Referenced by SoundOutput_Impl.

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

- soundbuffer_session.h