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. | |
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.
clan::SoundBuffer::SoundBuffer | ( | ) |
Construct a null instance.
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.
clan::SoundBuffer::SoundBuffer | ( | const std::string & | filename, |
bool | streamed, | ||
const FileSystem & | fs, | ||
const std::string & | type = "" ) |
clan::SoundBuffer::SoundBuffer | ( | IODevice & | file, |
bool | streamed, | ||
const std::string & | type ) |
|
virtual |
void clan::SoundBuffer::add_filter | ( | SoundFilter & | filter | ) |
Adds the sound filter to the sound buffer.
filter | Sound filter to pass sound through. |
float clan::SoundBuffer::get_pan | ( | ) | const |
Returns the default panning position when the buffer is played.
SoundProvider * clan::SoundBuffer::get_provider | ( | ) | const |
Returns the sound provider to be used for playback.
float clan::SoundBuffer::get_volume | ( | ) | const |
Returns the start/default volume used when the buffer is played.
|
inline |
Returns true if this object is invalid.
|
static |
Loads a SoundBuffer from a XML resource definition.
SoundBuffer_Session clan::SoundBuffer::play | ( | bool | looping = false, |
SoundOutput * | output = nullptr ) |
Plays the soundbuffer on the specified soundcard.
looping | looping |
output | Sound output to be used - NULL means use the current selected sound output (Sound::get_selected_output(). |
SoundBuffer_Session clan::SoundBuffer::prepare | ( | bool | looping = false, |
SoundOutput * | output = nullptr ) |
Prepares the soundbuffer for playback on the specified soundcard.
output | Sound output to be used - NULL means use the current selected sound output (Sound::get_selected_output(). |
void clan::SoundBuffer::remove_filter | ( | SoundFilter & | filter | ) |
Remove the sound filter from the sound buffer.
|
static |
Retrieves a SoundBuffer resource from the resource manager.
gc | = Graphic Context |
resources | = Resource manager |
id | = id |
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).
new_pan | New pan of the sound buffer played. |
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".
new_volume | New volume of sound buffer. |
void clan::SoundBuffer::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.