Main   Class List   Namespace List   Wiki

SFXSound Class Reference
[Sound]

A sound controller that directly plays a single sound file. More...

Inheritance diagram for SFXSound:
Inheritance graph
[legend]

List of all members.

Public Member Functions

float getDuration ()
 Get the total play time (in seconds) of the sound data attached to the sound.
float getPosition ()
 Get the current playback position in seconds.
bool isReady ()
 Test whether the sound data associated with the sound has been fully loaded and is ready for playback.
void setPosition (float position)
 Set the current playback position in seconds.

Detailed Description

A sound controller that directly plays a single sound file.

When playing individual audio files, SFXSounds are implicitly created by the sound system.

Each sound source has an associated play cursor that can be queried and explicitly positioned by the user. The cursor is a floating-point value measured in seconds.

For streamed sources, playback may not be continuous in case the streaming queue is interrupted.

Note:
This class cannot be instantiated directly by the user but rather is implicitly created by the sound system when sfxCreateSource() or sfxPlayOnce() is called on a SFXProfile instance.

Sounds and Voices

To actually emit an audible signal, a sound must allocate a resource on the sound device through which the sound data is being played back. This resource is called 'voice'.

As with other types of resources, the availability of these resources may be restricted, i.e. a given sound device will usually only support a fixed number of voices that are playing at the same time. Since, however, there may be arbitrary many SFXSounds instantiated and playing at the same time, this needs to be solved.

See also:
SFXDescription::priority

Member Function Documentation

float SFXSound::getDuration (  ) 

Get the total play time (in seconds) of the sound data attached to the sound.

Returns:
Note:
Be aware that for looped sounds, this will not return the total playback time of the sound.
float SFXSound::getPosition (  ) 

Get the current playback position in seconds.

Returns:
The current play cursor offset.
bool SFXSound::isReady (  ) 

Test whether the sound data associated with the sound has been fully loaded and is ready for playback.

For streamed sounds, this will be false during playback when the stream queue for the sound is starved and waiting for data. For buffered sounds, only an initial loading phase will potentially cause isReady to return false.

Returns:
True if the sound is ready for playback.
void SFXSound::setPosition ( float  position  ) 

Set the current playback position in seconds.

If the source is currently playing, playback will jump to the new position. If playback is stopped or paused, playback will resume at the given position when play() is called.

Parameters:
position The new position of the play cursor (in seconds).


Copyright © GarageGames, LLC. All Rights Reserved.