public interface Sound extends Disposable
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 dispose()
method when you're done using the Sound.
Sound instances are created via a call to Audio.newSound(FileHandle)
.
Calling the play()
or play(float)
method will return a long which is an id to that instance of the sound. You
can use this id to modify the playback of that sound instance.
Note: any values provided will not be clamped, it is the developer's responsibility to do so
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases all the resources.
|
long |
loop()
Plays the sound, looping.
|
long |
loop(float volume)
Plays the sound, looping.
|
long |
loop(float volume,
float pitch,
float pan)
Plays the sound, looping.
|
void |
pause()
Pauses all instances of this sound.
|
void |
pause(long soundId)
Pauses the sound instance with the given id as returned by
play() or play(float) . |
long |
play()
Plays the sound.
|
long |
play(float volume)
Plays the sound.
|
long |
play(float volume,
float pitch,
float pan)
Plays the sound.
|
void |
resume()
Resumes all paused instances of this sound.
|
void |
resume(long soundId)
Resumes the sound instance with the given id as returned by
play() or play(float) . |
void |
setLooping(long soundId,
boolean looping)
Sets the sound instance with the given id to be looping.
|
void |
setPan(long soundId,
float pan,
float volume)
Sets the panning and volume of the sound instance with the given id as returned by
play() or play(float) . |
void |
setPitch(long soundId,
float pitch)
Changes the pitch multiplier of the sound instance with the given id as returned by
play() or play(float) . |
void |
setPriority(long soundId,
int priority)
Sets the priority of a sound currently being played back.
|
void |
setVolume(long soundId,
float volume)
Changes the volume of the sound instance with the given id as returned by
play() or play(float) . |
void |
stop()
Stops playing all instances of this sound.
|
void |
stop(long soundId)
Stops the sound instance with the given id as returned by
play() or play(float) . |
long play()
long play(float volume)
volume
- the volume in the range [0,1]long play(float volume, float pitch, float pan)
volume
- the volume in the range [0,1]pitch
- the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0pan
- panning in the range -1 (full left) to 1 (full right). 0 is center position.long loop()
long loop(float volume)
stop(long)
using the returned id.volume
- the volume in the range [0, 1]long loop(float volume, float pitch, float pan)
stop(long)
using the returned id.volume
- the volume in the range [0,1]pitch
- the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0pan
- panning in the range -1 (full left) to 1 (full right). 0 is center position.void stop()
void pause()
void resume()
void dispose()
dispose
in interface Disposable
void stop(long soundId)
play()
or play(float)
. If the sound is no longer
playing, this has no effect.soundId
- the sound idvoid pause(long soundId)
play()
or play(float)
. If the sound is no
longer playing, this has no effect.soundId
- the sound idvoid resume(long soundId)
play()
or play(float)
. If the sound is not
paused, this has no effect.soundId
- the sound idvoid setLooping(long soundId, boolean looping)
soundId
- the sound idlooping
- whether to loop or not.void setPitch(long soundId, float pitch)
play()
or play(float)
.
If the sound is no longer playing, this has no effect.soundId
- the sound idpitch
- the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0void setVolume(long soundId, float volume)
play()
or play(float)
. If the
sound is no longer playing, this has no effect.soundId
- the sound idvolume
- the volume in the range 0 (silent) to 1 (max volume).void setPan(long soundId, float pan, float volume)
play()
or play(float)
.
If the sound is no longer playing, this has no effect.soundId
- the sound idpan
- panning in the range -1 (full left) to 1 (full right). 0 is center position.volume
- the volume in the range [0,1].void setPriority(long soundId, int priority)
Copyright © 2015. All rights reserved.