A Sound is a short audio clip that can be played numerous times in parallel. It's completely loaded into memory so only load small audio files. Call the {@link #dispose()} method when you're done using the Sound.
Sound instances are created via a call to {@link Audio#newSound(FileHandle)}.
Calling the {@link #play()} or {@link #play(float)} method will return a long which is an id to that instance of the sound. Youcan use this id to modify the playback of that sound instance.
@author badlogicgames@gmail.comSound Data
1) querying the sound's duration (Sound.DURATION_UNKNOWN will be returned),
2) looping over a range of the streaming data; and
3) restart a previously played portion of the data.
Depending on the implementation of the AudioDevice used, streamed, non- cached data may not be fully spatialized.
Initial Gain
Loop
A sound can be looped a specified number of times after it is activated before it is completed. The loop count value explicitly sets the number of times the sound is looped. Any non-negative number is a valid value. A value of zero denotes that the looped section is not repeated, but is played only once. A value of -1 denotes that the loop is repeated indefinitely.
Changing loop count of a sound after the sound has been started will not dynamically affect the loop count currently used by the sound playing. The new loop count will be used the next time the sound is enabled.
Release Flag
Continuous Flag
Enable Sound
Setting the enable flag to true during construction acts as a request to start the sound playing "as soon as it can" be started. This could be close to immediately in limited cases, but several conditions, detailed below, must be met for a sound to be ready to be played.
Mute Sound
Pause Sound
Setting the enable flag to true during construction acts as a request to start the sound playing "as soon as it can" be started. This could be close to immediately in limited cases, but several conditions, detailed below, must be met for a sound to be ready to be played.
Scheduling Bounds
Scheduling Bounding Leaf
Prioritize Sound
Sounds with a lower priority than sound that can not be played due to lack of channels will be played. For example, assume we have eight channels available for playing sounds. After ordering four sounds, we begin playing them in order, checking if the number of channels required to play a given sound are actually available before the sound is played. Furthermore, say the first sound needs three channels to play, the second sound needs four channels, the third sound needs three channels and the fourth sound needs only one channel. The first and second sounds can be started because they require seven of the eight available channels. The third sound can not be audibly started because it requires three channels and only one is still available. Consequently, the third sound starts playing 'silently.' The fourth sound can and will be started since it only requires one channel. The third sound will be made audible when three channels become available (i.e., when the first or second sound finishes playing).
Sounds given the same priority are ordered randomly. If the application wants a specific ordering, it must assign unique priorities to each sound.
Methods to determine what audio output resources are required for playing a Sound node on a particular AudioDevice and to determine the currently available audio output resources are described in the AudioDevice class.
Duration
Number of Channels used on Audio Device to Play Sound
Preparing a Sound to be Played
1) the Sound node has non-null sound data associated with it
2) the Sound node is live
3) there is an active View in the Universe and
4) there is an initialized AudioDevice associated with the PhysicalEnvironment.
Depending on the type of MediaContainer the sound data is and on the implementation of the AudioDevice used, sound data preparation could consist of opening, attaching, loading, or copying into memory the associated sound data. The query method, isReady() returns true when the sound is fully preprocessed so that it is playable (audibly if active, silently if not active).
Playing Status
1) enabled/started
2) activated
3) not muted
4) not paused
While these conditions are meet, the sound is potentially audible and the method isPlaying() will return a status of true.
isPlaying returns false but isPlayingSilently returns true if a sound:
1) is enabled before it is activated; it is begun playing silently.
2) is enabled then deactivated while playing; it continues playing silently
3) is enabled while it mute state is true
When the sound finishes playing it's sound data (including all loops), it is implicitly disabled.
@see AudioDevice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|