---
name: "CL_SoundBuffer"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_SoundBuffer"
---

# CL\_SoundBuffer(3)

Sample interface in ClanLib.

## NAME

CL\_SoundBuffer - Sample interface in ClanLib.

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

## CLASS MEMBERS

- virtual **~CL\_SoundBuffer**()

  - static CL\_SoundBuffer \***load**(

  ```
   const char *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)
  ```

- virtual CL\_StaticSoundProvider \***get\_static\_provider**()

  - virtual CL\_StreamSoundProvider \***get\_stream\_provider**()

  - virtual int **get\_length**()

  - virtual int **get\_num\_samples**()

  - virtual int **get\_frequency**()

  - virtual bool **set\_frequency**(

  ```
  int new_freq)
  ```

- virtual float **get\_volume**()

  - virtual bool **set\_volume**(

  ```
  float new_volume)
  ```

- virtual float **get\_pan**()

  - virtual bool **set\_pan**(

  ```
  float new_pan)
  ```

- virtual bool **is\_playing**(

  ```
  CL_SoundBuffer_Session **session=NULL,
  CL_SoundCard *card=NULL)
  ```

- virtual void **stop**(

  ```
  CL_SoundCard *card=NULL)
  ```

- virtual CL\_SoundBuffer\_Session **play**(

  ```
  bool looping=false,
  CL_SoundCard *card=NULL)
  ```

- virtual CL\_SoundBuffer\_Session **prepare**(

  ```
  bool looping=false,
  CL_SoundCard *card=NULL)
  ```

## MEMBERS WITH DESCRIPTIONS

- virtual **~CL\_SoundBuffer**()

  ```
  Description:
  ```

- static CL\_SoundBuffer \***load**(

  ```
   const char *res_id,
  CL_ResourceManager *manager)
  ```

  ```
  Description:
  ```

- static CL\_SoundBuffer \***create**(

  ```
   CL_StaticSoundProvider *provider,
  bool delete_provider=false)
  ```

  ```
  Description:
  ```

  Creates a static soundbuffer. If *delete\_provider* is true, the providerwill be deleted when the soundbuffer is deleted.

  ```
  Return value:
  ```

  The created soundbuffer.

- static CL\_SoundBuffer \***create**(

  ```
   CL_StreamSoundProvider *provider,
  bool delete_provider=false)
  ```

  ```
  Description:
  ```

  Creates a streamed soundbuffer. If *delete\_provider* is true, the providerwill be delete when the soundbuffer is deleted.

  ```
  Return value:
  ```

  The created soundbuffer.

- virtual CL\_StaticSoundProvider \***get\_static\_provider**()

  ```
  Description:
  ```

  Returns the static soundprovider attached or NULL if it is a streamedsound buffer.

  ```
  Return value:
  ```

  The static soundprovider or NULL if none.

- virtual CL\_StreamSoundProvider \***get\_stream\_provider**()

  ```
  Description:
  ```

  Return the streamed soundprovider attached or NULL if it is a staticsound buffer.

  ```
  Return value:
  ```

  The streamed soundprovider of NULL if none.

- virtual int **get\_length**()

  ```
  Description:
  ```

  Returns the length of the soundbuffer. That is num\_samples \* bytes\_per\_sample.

  ```
  Return value:
  ```

  Length of soundbuffer.

- virtual int **get\_num\_samples**()

  ```
  Description:
  ```

  Returns the number of samples in the soundbuffer.

  ```
  Return value:
  ```

  Number of samples in soundbuffer.

- virtual int **get\_frequency**()

  ```
  Description:
  ```

  Returns the start frequency used when the buffer is played.

  ```
  Return value:
  ```

  Default/start frequency.

- virtual bool **set\_frequency**(

  ```
  int new_freq)
  ```

  ```
  Parameters:
  new_freq - The new default frequency.
  ```

  ```
  Description:
  ```

  Sets the start frequency used when the buffer is played.

  ```
  Return value:
  ```

  True if successful, false otherwise.

- virtual float **get\_volume**()

  ```
  Description:
  ```

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

  ```
  Return value:
  ```

  The volume.

- virtual bool **set\_volume**(

  ```
  float new_volume)
  ```

  ```
  Parameters:
  new_volume - The new default volume.
  ```

  ```
  Description:
  ```

  Sets the default volume used when the buffer is played.

  ```
  Return value:
  ```

  True if successful, false otherwise.

- virtual float **get\_pan**()

  ```
  Description:
  ```

  Returns the default panning position when the buffer is played.

  ```
  Return value:
  ```

  The panning position.

- virtual bool **set\_pan**(

  ```
  float new_pan)
  ```

  ```
  Parameters:
  new_pan - The new default panning position.
  ```

  ```
  Description:
  ```

  Sets the default panning position when the buffer is played.

  ```
  Return value:
  ```

  True if successful, false otherwise.

- virtual bool **is\_playing**(

  ```
  CL_SoundBuffer_Session **session=NULL,
  CL_SoundCard *card=NULL)
  ```

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

  ```
  Description:
  ```

  Returns true if an instance of this soundbuffer is playing

- virtual void **stop**(

  ```
  CL_SoundCard *card=NULL)
  ```

  ```
  Description:
  ```

  Stops any sessions playing this soundbuffer

- virtual CL\_SoundBuffer\_Session **play**(

  ```
  bool looping=false,
  CL_SoundCard *card=NULL)
  ```

  ```
  Parameters:
  card - Soundcard to be used - NULL means use the current selected
  sound card (CL_Sound::get_selected_card().
  ```

  ```
  Description:
  ```

  Plays the soundbuffer on the specified soundcard and using the specified playback description.

  ```
  Return value:
  ```

  The playback session.

- virtual CL\_SoundBuffer\_Session **prepare**(

  ```
  bool looping=false,
  CL_SoundCard *card=NULL)
  ```

  ```
  Parameters:
  card - Soundcard to be used or NULL to use
  CL_Sound::get_selected_card().
  ```

  ```
  Description:
  ```

  Prepares the soundbuffer for playback on the specified soundcard.

  ```
  Return value:
  ```

  The playback session.

## SEE ALSO

- **CL\_StaticSoundProvider**

  Static sample data source.

- **CL\_StreamSoundProvider**

  Streamed sample data source.

- **CL\_SoundBuffer\_Session**

  Sample playback control.

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
