Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_SoundBuffer

Sample interface in ClanLib.
Contained in: global
Derived from: none
Derived by: none
Group: Sound (Audio Mixing)

#include <ClanLib/sound.h>

### public function member index:

### Construction:

``virtual`` | `~CL_SoundBuffer` | `()`;
``static` `CL_SoundBuffer`*` | `load` | `(`const` `std::string`& `res_id`, `CL_ResourceManager`* `manager`)`;
``static` `CL_SoundBuffer`*` | `create` | `(`CL_StaticSoundProvider`* `provider`, `bool` `delete_provider`=false)`;
``static` `CL_SoundBuffer`*` | `create` | `(`CL_StreamSoundProvider`* `provider`, `bool` `delete_provider`=false)`;
`` | `CL_SoundBuffer` | `()`;
`` | `CL_SoundBuffer` | `(`const` `std::string`& `res_id`, `CL_ResourceManager`* `manager`)`;
`` | `CL_SoundBuffer` | `(`CL_StaticSoundProvider`* `provider`, `bool` `delete_provider`=false)`;
`` | `CL_SoundBuffer` | `(`CL_StreamSoundProvider`* `provider`, `bool` `delete_provider`=false)`;
`` | `CL_SoundBuffer` | `(`const` `CL_SoundBuffer`& `copy`)`;

### Operators:

``void`` | `operator``=` | `(`const` `CL_SoundBuffer`& `copy`)`;

### Attributes:

``CL_StaticSoundProvider`*` | `get_static_provider` | `() `const``;
``CL_StreamSoundProvider`*` | `get_stream_provider` | `() `const``;
``int`` | `get_length` | `() `const``;
``int`` | `get_num_samples` | `() `const``;
``int`` | `get_frequency` | `() `const``;

### Operations:

``bool`` | `set_frequency` | `(`int` `new_freq`)`;
``float`` | `get_volume` | `() `const``;
``bool`` | `set_volume` | `(`float` `new_volume`)`;
``float`` | `get_pan` | `() `const``;
``bool`` | `set_pan` | `(`float` `new_pan`)`;
``bool`` | `is_playing` | `(`CL_SoundBuffer_Session`* *`session`=NULL, `CL_SoundCard`* `card`=NULL) `const``;
``void`` | `stop` | `(`CL_SoundCard`* `card`=NULL)`;
``CL_SoundBuffer_Session`` | `play` | `(`bool` `looping`=false, `CL_SoundCard`* `card`=NULL)`;
``CL_SoundBuffer_Session`` | `prepare` | `(`bool` `looping`=false, `CL_SoundCard`* `card`=NULL)`;

## Description:

The CL_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.
A static sample are normally sound effects and other sounds, that do not change. ClanLib will always load the entire sample into memory, and possibly upload it to the soundcard.
Streamed samples are either large sample that should be loaded a bit at a time (music for instance), or sounds that change from playback to playback (a microphone, speech over the net, etc).
See also - CL_StaticSoundProvider - Static sample data source.
See also -CL_StreamSoundProvider - Streamed sample data source.
See also -CL_SoundBuffer_Session - Sample playback control.

## Function Member Descriptions:

CL_SoundBuffer::CL_SoundBuffer - Construct unattached sound buffer.
`` `CL_SoundBuffer` `()`;

CL_SoundBuffer::CL_SoundBuffer - Loads a soundbuffer (sample) from a resource.
`` `CL_SoundBuffer` `(`const` `std::string`& `res_id`, `CL_ResourceManager`* `manager`)`;

CL_SoundBuffer::CL_SoundBuffer - Creates a static soundbuffer. If 'delete_provider' is true, the provider will be deleted when the soundbuffer is deleted.
`` `CL_SoundBuffer` `(`CL_StaticSoundProvider`* `provider`, `bool` `delete_provider`=false)`;

CL_SoundBuffer::CL_SoundBuffer - Creates a streamed soundbuffer. If 'delete_provider' is true, the provider will be delete when the soundbuffer is deleted.
`` `CL_SoundBuffer` `(`CL_StreamSoundProvider`* `provider`, `bool` `delete_provider`=false)`;

CL_SoundBuffer::CL_SoundBuffer - Create a copy of this soundbuffer. The copy will share the buffer with the original.
`` `CL_SoundBuffer` `(`const` `CL_SoundBuffer`& `copy`)`;

CL_SoundBuffer::create - Creates a static soundbuffer. If 'delete_provider' is true, the provider will be deleted when the soundbuffer is deleted.
``static` `CL_SoundBuffer`*` `create` `(`CL_StaticSoundProvider`* `provider`, `bool` `delete_provider`=false)`;

> Returns - The created soundbuffer.

CL_SoundBuffer::create - Creates a streamed soundbuffer. If 'delete_provider' is true, the provider will be delete when the soundbuffer is deleted.
``static` `CL_SoundBuffer`*` `create` `(`CL_StreamSoundProvider`* `provider`, `bool` `delete_provider`=false)`;

> Returns - The created soundbuffer.

CL_SoundBuffer::get_frequency - Returns the start frequency used when the buffer is played.
``int`` `get_frequency` `() `const``;

> Returns - Default/start frequency.

CL_SoundBuffer::get_length - Returns the length of the soundbuffer.
That is num_samples * bytes_per_sample.
``int`` `get_length` `() `const``;

> Returns - Length of soundbuffer.

CL_SoundBuffer::get_num_samples - Returns the number of samples in the soundbuffer.
``int`` `get_num_samples` `() `const``;

> Returns - Number of samples in soundbuffer.

CL_SoundBuffer::get_pan - Returns the default panning position when the buffer is played.
``float`` `get_pan` `() `const``;

> Returns - The panning position.

CL_SoundBuffer::get_static_provider - Returns the static soundprovider attached or NULL if it is a streamed sound buffer.
``CL_StaticSoundProvider`*` `get_static_provider` `() `const``;

> Returns - The static soundprovider or NULL if none.

CL_SoundBuffer::get_stream_provider - Return the streamed soundprovider attached or NULL if it is a static sound buffer.
``CL_StreamSoundProvider`*` `get_stream_provider` `() `const``;

> Returns - The streamed soundprovider of NULL if none.

CL_SoundBuffer::get_volume - Returns the start/default volume used when the buffer is played.
``float`` `get_volume` `() `const``;

> Returns - The volume.

CL_SoundBuffer::is_playing - Returns true if an instance of this soundbuffer is playing
``bool`` `is_playing` `(`CL_SoundBuffer_Session`* *`session`=NULL, `CL_SoundCard`* `card`=NULL) `const``;

> session - Pointer to session-pointer, set to point to the first session
> playing this soundbuffer. Return value is only valid if function returns true

CL_SoundBuffer::load - Load
``static` `CL_SoundBuffer`*` `load` `(`const` `std::string`& `res_id`, `CL_ResourceManager`* `manager`)`;

CL_SoundBuffer::operator = - Copy assignment.
``void`` `operator``=` `(`const` `CL_SoundBuffer`& `copy`)`;

CL_SoundBuffer::play - Plays the soundbuffer on the specified soundcard and using the specified playback description.
``CL_SoundBuffer_Session`` `play` `(`bool` `looping`=false, `CL_SoundCard`* `card`=NULL)`;

> card - Soundcard to be used - NULL means use the current selected
> sound card (CL_Sound::get_selected_card().
> Returns - The playback session.

CL_SoundBuffer::prepare - Prepares the soundbuffer for playback on the specified soundcard.
``CL_SoundBuffer_Session`` `prepare` `(`bool` `looping`=false, `CL_SoundCard`* `card`=NULL)`;

> card - Soundcard to be used or NULL to use
> CL_Sound::get_selected_card().
> Returns - The playback session.

CL_SoundBuffer::set_frequency - Sets the start frequency used when the buffer is played.
``bool`` `set_frequency` `(`int` `new_freq`)`;

> new_freq - The new default frequency.
> Returns - True if successful, false otherwise.

CL_SoundBuffer::set_pan - Sets the default panning position when the buffer is played.
``bool`` `set_pan` `(`float` `new_pan`)`;

> new_pan - The new default panning position.
> Returns - True if successful, false otherwise.

CL_SoundBuffer::set_volume - Sets the default volume used when the buffer is played.
``bool`` `set_volume` `(`float` `new_volume`)`;

> new_volume - The new default volume.
> Returns - True if successful, false otherwise.

CL_SoundBuffer::stop - Stops any sessions playing this soundbuffer
``void`` `stop` `(`CL_SoundCard`* `card`=NULL)`;

CL_SoundBuffer::~CL_SoundBuffer - Sound Buffer Destructor
``virtual`` `~CL_SoundBuffer` `()`;

## Variable Member Descriptions: