| GL Studio C++ Runtime API

Public Member Functions | List of all members
SoundSystem Class Reference

`#include <sound.h>`

## Public Member Functions
| SoundSystem (int maxSounds)
| ~SoundSystem ()
bool | IsValid () const
void | Play (int which)
void | Play (int which, float volumeOrDistance)
void | LoadSound (const char *fn, int index)
void | LoadSounds (const char *firstArg,...)
void | ClearSound (int index)
void | SetMasterVolume (float volume)
float | GetMasterVolume () const

## Detailed Description

The SoundSystem class. Plays WAV files on Desktop Windows.

## Constructor & Destructor Documentation

## ◆ SoundSystem()

SoundSystem | ( | int | maxSounds | ) |
| explicit

Constructor

Parameters

  maxSounds | Maximum number of soundfiles in the sound system

Exceptions

  std::bad_alloc | if unable to allocate memory.

## ◆ ~SoundSystem()

~SoundSystem | ( |  | ) |

Destructor

## Member Function Documentation

## ◆ ClearSound()

void ClearSound | ( | int | index | ) |

Deletes the sound from the given index

Parameters

  index | Zero based index to clear

## ◆ GetMasterVolume()

float GetMasterVolume | ( |  | ) | const

Gets the master volume of the sound system, from 0.0 (min) to FLT_MAX (max)

Returns
  The master volume of the sound system, from 0.0 (min) to FLT_MAX (max)

## ◆ IsValid()

bool IsValid | ( |  | ) | const

Returns
  Whether the sound device was initialized sucessfully.

## ◆ LoadSound()

void LoadSound | ( | const char * | fn,
|  | int | index
| ) |  |

Loads the sound from a file into a slot in the sound system

Parameters

  fn | The name of the file to load from
  index | The zero based index to load the file into

Exceptions

  std::bad_alloc | if unable to allocate memory

## ◆ LoadSounds()

void LoadSounds | ( | const char * | firstArg,
|  |  | ...
| ) |  |

Loads a number of sounds from files into the sound system The sounds are loaded sequentially starting at slot zero

Parameters

  firstArg | Filenames to load, followed by a NULL

Exceptions

  std::bad_alloc | if unable to allocate memory

## ◆ Play() [1/2]

void Play | ( | int | which | ) |

Plays the sound at the given index

Parameters

  which | The zero based index of the sound to play

## ◆ Play() [2/2]

void Play | ( | int | which,
|  | float | volumeOrDistance
| ) |  |

Plays the sound at the given index, attenuated for distancec

Parameters

  which | The zero based index of the sound to play
  volumeOrDistance | The volume of the sound, from 0.0 (min) to FLT_MAX (max) or the distance in meters of the sound, depending on the platform.

## ◆ SetMasterVolume()

void SetMasterVolume | ( | float | volume | ) |

Sets the master volume of the sound system, from 0.0 (min) to FLT_MAX (max)

Parameters

  volume | The master volume of the sound system, from 0.0 (min) to FLT_MAX (max)

The documentation for this class was generated from the following file:

- sound.h