Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DynamicMusic Class Reference

This class allows to play music depending on a current "scene", scene changes are managed by the class. More...

#include <DynamicMusic.h>

Public Member Functions

 DynamicMusic (std::shared_ptr< IDevice > device)
 Creates a new dynamic music manager with the default silent scene (id: 0).
 
int addScene (std::shared_ptr< ISound > sound)
 Adds a new scene to the manager.
 
bool changeScene (int id)
 Changes to another scene.
 
int getScene ()
 Retrieves the scene currently selected.
 
bool addTransition (int init, int end, std::shared_ptr< ISound > sound)
 Adds a new transition between scenes.
 
void setFadeTime (double seconds)
 Sets the length of the crossfade transition (default 1 second).
 
double getFadeTime ()
 Gets the length of the crossfade transition (default 1 second).
 
bool resume ()
 Resumes a paused sound.
 
bool pause ()
 Pauses the current played back sound.
 
bool seek (double position)
 Seeks in the current played back sound.
 
double getPosition ()
 Retrieves the current playback position of a sound.
 
float getVolume ()
 Retrieves the volume of the scenes.
 
bool setVolume (float volume)
 Sets the volume for the scenes.
 
Status getStatus ()
 Returns the status of the current played back sound.
 
bool stop ()
 Stops any played back or paused sound and sets the dynamic music player to default silent state (scene 0)
 

Detailed Description

This class allows to play music depending on a current "scene", scene changes are managed by the class.

The default scene is silent and has id 0.

Constructor & Destructor Documentation

◆ DynamicMusic()

DynamicMusic::DynamicMusic ( std::shared_ptr< IDevice > device)

Creates a new dynamic music manager with the default silent scene (id: 0).

Parameters
deviceThe device that will be used to play sounds.

Member Function Documentation

◆ addScene()

int DynamicMusic::addScene ( std::shared_ptr< ISound > sound)

Adds a new scene to the manager.

Parameters
soundThe sound that will play when the scene is selected with the changeScene().
Returns
The identifier of the new scene.

◆ addTransition()

bool DynamicMusic::addTransition ( int init,
int end,
std::shared_ptr< ISound > sound )

Adds a new transition between scenes.

Parameters
initThe id of the initial scene that will allow the transition to play.
endThe id if the target scene for the transition.
soundThe sound that will play when the scene changes from init to end.
Returns
false if the init or end scenes don't exist.

◆ changeScene()

bool DynamicMusic::changeScene ( int id)

Changes to another scene.

Parameters
idThe id of the scene which should start playing the changeScene method.
Returns
  • true if the change has been scheduled succesfully.
  • false if there already is a transition in course or the scene selected doesnt exist.

◆ getFadeTime()

double DynamicMusic::getFadeTime ( )

Gets the length of the crossfade transition (default 1 second).

Returns
The length of the cressfade transition in seconds.

◆ getPosition()

double DynamicMusic::getPosition ( )

Retrieves the current playback position of a sound.

Returns
The playback position in seconds, or 0.0 if the handle is invalid.

◆ getScene()

int DynamicMusic::getScene ( )

Retrieves the scene currently selected.

Returns
The identifier of the current scene.

◆ getStatus()

Status DynamicMusic::getStatus ( )

Returns the status of the current played back sound.

Returns
  • STATUS_INVALID if the sound has stopped or the handle is . invalid
  • STATUS_PLAYING if the sound is currently played back.
  • STATUS_PAUSED if the sound is currently paused.
  • STATUS_STOPPED if the sound finished playing and is still kept in the device.
See also
Status

◆ getVolume()

float DynamicMusic::getVolume ( )

Retrieves the volume of the scenes.

Returns
The volume.

◆ pause()

bool DynamicMusic::pause ( )

Pauses the current played back sound.

Returns
  • true if the sound has been paused.
  • false if the sound isn't playing back or the handle is invalid.

◆ resume()

bool DynamicMusic::resume ( )

Resumes a paused sound.

Returns
  • true if the sound has been resumed.
  • false if the sound isn't paused or the handle is invalid.

◆ seek()

bool DynamicMusic::seek ( double position)

Seeks in the current played back sound.

Parameters
positionThe new position from where to play back, in seconds.
Returns
  • true if the handle is valid.
  • false if the handle is invalid.
Warning
Whether the seek works or not depends on the sound source.

◆ setFadeTime()

void DynamicMusic::setFadeTime ( double seconds)

Sets the length of the crossfade transition (default 1 second).

Parameters
secondsThe time in seconds.

◆ setVolume()

bool DynamicMusic::setVolume ( float volume)

Sets the volume for the scenes.

Parameters
volumeThe volume.
Returns
  • true if the handle is valid.
  • false if the handle is invalid.

◆ stop()

bool DynamicMusic::stop ( )

Stops any played back or paused sound and sets the dynamic music player to default silent state (scene 0)

Returns
  • true if the sound has been stopped.
  • false if the handle is invalid.

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