|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Static Public Member Functions
gameplay::AudioSource Class Reference

`#include <AudioSource.h>`

Inheritance diagram for gameplay::AudioSource:

List of all members.

## Public Types

enum | State { INITIAL, PLAYING, PAUSED, STOPPED }

## Public Member Functions

void | play ()
void | pause ()
void | resume ()
void | stop ()
void | rewind ()
AudioSource::State | getState () const
bool | isStreamed () const
bool | isLooped () const
void | setLooped (bool looped)
float | getGain () const
void | setGain (float gain)
float | getPitch () const
void | setPitch (float pitch)
const Vector3 & | getVelocity () const
void | setVelocity (const Vector3 &velocity)
void | setVelocity (float x, float y, float z)
Node * | getNode () const

## Static Public Member Functions

static AudioSource * | create (const char *url, bool streamed=false)
static AudioSource * | create (Properties *properties)

## Detailed Description

Defines an audio source in 3D space.

This can be attached to a Node for applying its 3D transformation.

See also:
  http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Audio

## Member Enumeration Documentation

enum gameplay::AudioSource::State

The audio source's audio state.

## Member Function Documentation

static AudioSource* gameplay::AudioSource::create | ( | const char * | url,
|  | bool | streamed = `false`
| ) |  | `[static]`

Create an audio source. This is used to instantiate an Audio Source. Currently only wav, au, and raw files are supported. Alternately, a URL specifying a Properties object that defines an audio source can be used (where the URL is of the format "<file-path>.<extension>#<namespace-id>/<namespace-id>/.../<namespace-id>" and "#<namespace-id>/<namespace-id>/.../<namespace-id>" is optional).

Parameters:

  url | The relative location on disk of the sound file or a URL specifying a Properties object defining an audio source.
  streamed | Don't read the entire audio buffer first before playing, instead play immediately from a stream that is read on demand.

Returns:
  The newly created audio source, or NULL if an audio source cannot be created.

static AudioSource* gameplay::AudioSource::create | ( | Properties * | properties | ) | `[static]`

Create an audio source from the given properties object.

Parameters:

  properties | The properties object defining the audio source (must have namespace equal to 'audio').

Returns:
  The newly created audio source, or `NULL` if the audio source failed to load.

float gameplay::AudioSource::getGain | ( |  | ) | const

Returns the gain of the audio source.

Returns:
  The gain.

Node* gameplay::AudioSource::getNode | ( |  | ) | const

Gets the node that this source is attached to.

Returns:
  The node that this audio source is attached to.

float gameplay::AudioSource::getPitch | ( |  | ) | const

Returns the pitch of the audio source.

Returns:
  The pitch.

AudioSource::State gameplay::AudioSource::getState | ( |  | ) | const

Gets the current state of the audio source.

Returns:
  PLAYING if the source is playing, STOPPED if the source is stopped, PAUSED if the source is paused and INITIAL otherwise.

const Vector3& gameplay::AudioSource::getVelocity | ( |  | ) | const

Gets the velocity of the audio source.

Returns:
  The velocity as a vector.

bool gameplay::AudioSource::isLooped | ( |  | ) | const

Determines whether the audio source is looped or not.

Returns:
  true if the audio source is looped, false if not.

bool gameplay::AudioSource::isStreamed | ( |  | ) | const

Determines whether the audio source is streaming or not.

Returns:
  true if the audio source is streaming, false if not.

void gameplay::AudioSource::pause | ( |  | ) |

Pauses the playing of the audio source.

void gameplay::AudioSource::play | ( |  | ) |

Plays the audio source.

void gameplay::AudioSource::resume | ( |  | ) |

Resumes playing of the audio source.

void gameplay::AudioSource::rewind | ( |  | ) |

Rewinds the audio source to the beginning.

void gameplay::AudioSource::setGain | ( | float | gain | ) |

Sets the gain/volume of the audio source.

Parameters:

  gain | The gain/volume of the source.

void gameplay::AudioSource::setLooped | ( | bool | looped | ) |

Sets the state of the audio source to be looping or not.

Parameters:

  looped | true to loop the sound, false to not loop it.

void gameplay::AudioSource::setPitch | ( | float | pitch | ) |

Sets the pitch of the audio source.

Parameters:

  pitch | The pitch of the source.

void gameplay::AudioSource::setVelocity | ( | const Vector3 & | velocity | ) |

Sets the velocity of the audio source.

Parameters:

  velocity | A vector representing the velocity.

void gameplay::AudioSource::setVelocity | ( | float | x,
|  | float | y,
|  | float | z
| ) |  |

Sets the velocity of the audio source.

Parameters:

  x | The x coordinate of the velocity.
  y | The y coordinate of the velocity.
  z | The z coordinate of the velocity.

void gameplay::AudioSource::stop | ( |  | ) |

Stops the playing of the audio source.

All Classes Functions Variables Typedefs Enumerations Enumerator