SFXSound
A sound controller that directly plays a single sound file.
Public Functions
float
Get the total play time (in seconds) of the sound data attached to the sound.
float
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.
Public Functions
getDuration()
Get the total play time (in seconds) of the sound data attached to the sound.
note:Be aware that for looped sounds, this will not return the total playback time of the sound.
getPosition()
Get the current playback position in seconds.
The current play cursor offset.
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.
True if the sound is ready for playback.
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). |