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

Public Member Functions | Static Public Member Functions | List of all members
clan::SoundBuffer Class Reference
clanSound Audio Mixing

Sample interface in ClanLib. More...

`#include <soundbuffer.h>`

## Public Member Functions
| SoundBuffer ()
| Construct a null instance.
| SoundBuffer (const std::string &filename, bool streamed, const FileSystem &fs, const std::string &type="")
| SoundBuffer (const std::string &fullname, bool streamed=false, const std::string &format="")
| Construct sound buffer.
| SoundBuffer (IODevice &file, bool streamed, const std::string &type)
virtual | ~SoundBuffer ()
void | add_filter (SoundFilter &filter)
| Adds the sound filter to the sound buffer.
float | get_pan () const
| Returns the default panning position when the buffer is played.
SoundProvider * | get_provider () const
| Returns the sound provider to be used for playback.
float | get_volume () const
| Returns the start/default volume used when the buffer is played.
bool | is_null () const
| Returns true if this object is invalid.
SoundBuffer_Session | play (bool looping=false, SoundOutput *output=nullptr)
| Plays the soundbuffer on the specified soundcard.
SoundBuffer_Session | prepare (bool looping=false, SoundOutput *output=nullptr)
| Prepares the soundbuffer for playback on the specified soundcard.
void | remove_filter (SoundFilter &filter)
| Remove the sound filter from the sound buffer.
void | set_pan (float new_pan)
| Sets the panning of the sound buffer played in measures from -1 -> 1.
void | set_volume (float new_volume)
| Sets the volume of the sound buffer in a relative measure (0->1).
void | throw_if_null () const
| Throw an exception if this object is invalid.

## Static Public Member Functions
static SoundBuffer | load (const std::string &id, const XMLResourceDocument &doc)
| Loads a SoundBuffer from a XML resource definition.
static Resource< SoundBuffer > | resource (const std::string &id, const ResourceManager &resources)
| Retrieves a SoundBuffer resource from the resource manager.

## Detailed Description

Sample interface in ClanLib.

The SoundBuffer class represents a sample in ClanLib. It can either be static or streamed. The soundbuffer gets its sample data from a soundprovider, that is passed during construction.

## Constructor & Destructor Documentation

## ◆ SoundBuffer() [1/4]

clan::SoundBuffer::SoundBuffer | ( |  | ) |

Construct a null instance.

Referenced by load().

## ◆ SoundBuffer() [2/4]

clan::SoundBuffer::SoundBuffer | ( | const std::string & | fullname,
|  | bool | streamed = false,
|  | const std::string & | format = "" )

Construct sound buffer.

A sound buffer can be constructed either as static or streamed. If the sound buffer is loaded from resources, the buffer type is determined by the resource option 'stream' associated with the resource.

SoundBuffer's internals are reference counted, so the copy constructor will create a new soundbuffer object which shares the same buffer as the original one. This means that if the copy is modified, the original is affected as well.

If delete_provider is true, the provider will be deleted when the soundbuffer is deleted.

## ◆ SoundBuffer() [3/4]

clan::SoundBuffer::SoundBuffer | ( | const std::string & | filename,
|  | bool | streamed,
|  | const FileSystem & | fs,
|  | const std::string & | type = "" )

## ◆ SoundBuffer() [4/4]

clan::SoundBuffer::SoundBuffer | ( | IODevice & | file,
|  | bool | streamed,
|  | const std::string & | type )

## ◆ ~SoundBuffer()

virtual clan::SoundBuffer::~SoundBuffer | ( |  | ) |
| virtual

## Member Function Documentation

## ◆ add_filter()

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

Adds the sound filter to the sound buffer.

Parameters

  filter | Sound filter to pass sound through.

## ◆ get_pan()

float clan::SoundBuffer::get_pan | ( |  | ) | const

Returns the default panning position when the buffer is played.

## ◆ get_provider()

SoundProvider * clan::SoundBuffer::get_provider | ( |  | ) | const

Returns the sound provider to be used for playback.

## ◆ get_volume()

float clan::SoundBuffer::get_volume | ( |  | ) | const

Returns the start/default volume used when the buffer is played.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ load()

SoundBuffer clan::SoundBuffer::load | ( | const std::string & | id,
|  | const XMLResourceDocument & | doc )
| static

Loads a SoundBuffer from a XML resource definition.

References SoundBuffer().

## ◆ play()

SoundBuffer_Session clan::SoundBuffer::play | ( | bool | looping = false,
|  | SoundOutput * | output = nullptr )

Plays the soundbuffer on the specified soundcard.

Parameters

  looping | looping
  output | Sound output to be used - NULL means use the current selected sound output (Sound::get_selected_output().

Returns
  The playback session.

## ◆ prepare()

SoundBuffer_Session clan::SoundBuffer::prepare | ( | bool | looping = false,
|  | SoundOutput * | output = nullptr )

Prepares the soundbuffer for playback on the specified soundcard.

Parameters

  output | Sound output to be used - NULL means use the current selected sound output (Sound::get_selected_output().

Returns
  The playback session.

## ◆ remove_filter()

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

Remove the sound filter from the sound buffer.

## ◆ resource()

Resource< SoundBuffer > clan::SoundBuffer::resource | ( | const std::string & | id,
|  | const ResourceManager & | resources )
| static

Retrieves a SoundBuffer resource from the resource manager.

Parameters

  gc | = Graphic Context
  resources | = Resource manager
  id | = id

## ◆ set_pan()

void clan::SoundBuffer::set_pan | ( | float | new_pan | ) |

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

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

Parameters

  new_pan | New pan of the sound buffer played.

## ◆ set_volume()

void clan::SoundBuffer::set_volume | ( | float | new_volume | ) |

Sets the volume of the sound buffer 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 sound buffer.

## ◆ throw_if_null()

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

Throw an exception if this object is invalid.

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

- soundbuffer.h