---
name: "CL_SoundBuffer_Session"
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_Session"
---

# CL\_SoundBuffer\_Session(3)

CL\_SoundBuffer\_Session provides control over a playing soundeffect.

## NAME

CL\_SoundBuffer\_Session - CL\_SoundBuffer\_Session provides control over a playing soundeffect.

## DESCRIPTION

Whenever a soundbuffer is played, it returns a CL\_SoundBuffer\_Session class, which can be used to control the sound (its volume, pitch,  pan, position). It can of course also be used to retrigger the sound or to stop it. The soundeffect is stored in the layer1 soundmanager until all references to the sound played are removed, meaning that the soundeffect (session) will be ready to play and remember its state and settings (volume, frequency...) until no CL\_SoundBuffer\_Session refers to it, via a soundbuffer session reference system.

## CLASS MEMBERS

- **CL\_SoundBuffer\_Session**()

  - **CL\_SoundBuffer\_Session**(

  ```
  void *handle,
  CL_SoundCard *_card)
  ```

- **CL\_SoundBuffer\_Session**(

  ```
  const CL_SoundBuffer_Session &copy)
  ```

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

  - CL\_SoundBuffer\_Session& **operator=**(

  ```
  const CL_SoundBuffer_Session &session)
  ```

- void \***get\_handle**()

  - CL\_SoundCard \***get\_card**()

  - int **get\_position**()

  - float **get\_position\_relative**()

  - bool **set\_position**(

  ```
  int new_pos)
  ```

- bool **set\_position\_relative**(

  ```
  float new_pos)
  ```

- int **get\_length**()

  - int **get\_frequency**()

  - bool **set\_frequency**(

  ```
  int new_freq)
  ```

- float **get\_volume**()

  - bool **set\_volume**(

  ```
  float new_volume)
  ```

- float **get\_pan**()

  - bool **set\_pan**(

  ```
  float new_pan)
  ```

- void **play**()

  - void **stop**()

  - bool **is\_playing**()

  - void **set\_looping**(

  ```
  bool loop)
  ```

## MEMBERS WITH DESCRIPTIONS

- **CL\_SoundBuffer\_Session**()

  ```
  Description:
  ```

  Creates a soundbuffer session not attached to any object.

- **CL\_SoundBuffer\_Session**(

  ```
  void *handle,
  CL_SoundCard *_card)
  ```

  ```
  Description:
  ```

- **CL\_SoundBuffer\_Session**(

  ```
  const CL_SoundBuffer_Session &copy)
  ```

  ```
  Description:
  ```

  Copy constructor.

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

  ```
  Description:
  ```

- CL\_SoundBuffer\_Session& **operator=**(

  ```
  const CL_SoundBuffer_Session &session)
  ```

  ```
  Description:
  ```

- void \***get\_handle**()

  ```
  Description:
  ```

- CL\_SoundCard \***get\_card**()

  ```
  Description:
  ```

  Returns a pointer to the card on which the soundbuffer controlledis played/playing.

  ```
  Return value:
  ```

  Pointer to soundcard

- int **get\_position**()

  ```
  Description:
  ```

  Returns the current position of the soundeffect

  ```
  Return value:
  ```

  Current position of soundeffect.

- float **get\_position\_relative**()

  ```
  Description:
  ```

  Returns the soundeffects relative position, comparedto the total length of the soundeffect.The value returned will be between 0-\>1, where 0means the soundeffect is at the beginning, and 1means that the soundeffect has reached the end.

  ```
  Return value:
  ```

  Relative position of the soundeffect.

- bool **set\_position**(

  ```
  int new_pos)
  ```

  ```
  Parameters:
  The new position of the soundeffect.
  ```

  ```
  Description:
  ```

  Sets the soundeffects position to *new\_pos*.

  ```
  Return value:
  ```

  Returns true if operation completed succesfully.

- bool **set\_position\_relative**(

  ```
  float new_pos)
  ```

  ```
  Parameters:
  New relative position
  ```

  ```
  Description:
  ```

  Sets the relative position of the soundeffect.Value must be between 0-\>1, where 0 sets the soundeffect to the beginning, and 1 sets itto the end of the soundbuffer.

  ```
  Return value:
  ```

  Returns true if operation completed succesfully.

- int **get\_length**()

  ```
  Description:
  ```

  Returns the total length of the soundeffect played.Value returned will be -1 if the length is unknown (incase of non-static soundeffects like streamed sound)

  ```
  Return value:
  ```

  Length of the soundeffect.

- int **get\_frequency**()

  ```
  Description:
  ```

  Returns the frequency of the soundeffect played.

  ```
  Return value:
  ```

  Frequency of soundeffect played.

- bool **set\_frequency**(

  ```
  int new_freq)
  ```

  ```
  Parameters:
  New frequency of soundeffect.
  ```

  ```
  Description:
  ```

  Sets the frequency of the soundeffect played.

  ```
  Return value:
  ```

  Returns true, if the operation completed succesfully.

- float **get\_volume**()

  ```
  Description:
  ```

  Returns the linear relative volume of the soundeffect.0 means the soundeffect is muted, 1 means the soundeffectis playing at "max" volume.

  ```
  Return value:
  ```

  Volume of soundeffect played.

- bool **set\_volume**(

  ```
  float new_volume)
  ```

  ```
  Parameters:
  new_volume - New volume of soundeffect
  ```

  ```
  Description:
  ```

  Sets the volume of the soundeffect in a relative measure (0-\>1)A value of 0 will effectively mute the sound (although it willstill be sampled), and a value of 1 will set the volume to "max".

  ```
  Return value:
  ```

  Returns true if the operation completed succesfully.

- float **get\_pan**()

  ```
  Description:
  ```

  Returns the current pan (in a measure from -1 -\> 1), where-1 means the soundeffect is only playing in the left speaker, and 1 means the soundeffect is only playing in the right speaker.

  ```
  Return value:
  ```

  Current pan of the soundeffect played.

- bool **set\_pan**(

  ```
  float new_pan)
  ```

  ```
  Parameters:
  new_pan - New pan of the soundeffect played.
  ```

  ```
  Description:
  ```

  Sets the panning of the soundeffect played in measures from -1 -\> 1Setting the pan with a value of -1 will pan the soundeffect to theextreme left (left speaker only), 1 will pan the soundeffect to theextreme right (right speaker only).

  ```
  Return value:
  ```

  Returns true if the operation completed sucecsfully.

- void **play**()

  ```
  Description:
  ```

  Starts playback of the session.

- void **stop**()

  ```
  Description:
  ```

  Stops playback of the session.

- bool **is\_playing**()

  ```
  Description:
  ```

  Returns true if the session is playing

- void **set\_looping**(

  ```
  bool loop)
  ```

  ```
  Parameters:
  loop - true if session should loop, false otherwise
  ```

  ```
  Description:
  ```

  Determines whether this session should loop

## SEE ALSO

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.
