Sample interface in ClanLib. More...

#include <soundbuffer.h>

Public Member Functions

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

Static Public Member Functions

static SoundBuffer load (const std::string &id, const XMLResourceDocument &doc)
 Loads a SoundBuffer from a XML resource definition. More...
 
static Resource< SoundBufferresource (const std::string &id, const ResourceManager &resources)
 Retrieves a SoundBuffer resource from the resource manager. More...
 

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

clan::SoundBuffer::SoundBuffer ( )

Construct a null instance.

clan::SoundBuffer::SoundBuffer ( SoundProvider provider)

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 fullname,
bool  streamed = false,
const std::string format = "" 
)
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 clan::SoundBuffer::~SoundBuffer ( )
virtual

Member Function Documentation

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

Adds the sound filter to the sound buffer.

Parameters
filterSound 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.

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

Returns true if this object is invalid.

static SoundBuffer clan::SoundBuffer::load ( const std::string id,
const XMLResourceDocument doc 
)
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.

Parameters
loopinglooping
outputSound output to be used - NULL means use the current selected sound output (Sound::get_selected_output().
Returns
The playback session.
SoundBuffer_Session clan::SoundBuffer::prepare ( bool  looping = false,
SoundOutput output = nullptr 
)

Prepares the soundbuffer for playback on the specified soundcard.

Parameters
outputSound output to be used - NULL means use the current selected sound output (Sound::get_selected_output().
Returns
The playback session.
void clan::SoundBuffer::remove_filter ( SoundFilter filter)

Remove the sound filter from the sound buffer.

static 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
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_panNew 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".

Parameters
new_volumeNew volume of sound buffer.
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: