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 |
|---|---|
| public void | |
| public long | Returns: the id of the sound instance if successful, or -1 on failure.Plays the sound, looping. |
| public long | Returns: the id of the sound instance if successful, or -1 on failure.the volume in the range [0, 1] volume)Plays the sound, looping. |
| public long | Returns: the id of the sound instance if successful, or -1 on failure.the volume in the range [0,1] volume, float the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0 pitch, float panning in the range -1 (full left) to 1 (full right). 0 is center position. pan)Plays the sound, looping. |
| public void | |
| public void | pause(long
the sound id soundId)Pauses the sound instance with the given id as returned by |
| public long | |
| public long | Returns: the id of the sound instance if successful, or -1 on failure.the volume in the range [0,1] volume)Plays the sound. |
| public long | Returns: the id of the sound instance if successful, or -1 on failure.the volume in the range [0,1] volume, float the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0 pitch, float panning in the range -1 (full left) to 1 (full right). 0 is center position. pan)Plays the sound. |
| public void | |
| public void | resume(long
the sound id soundId)Resumes the sound instance with the given id as returned by |
| public void | setLooping(long
the sound id soundId, boolean whether to loop or not. looping)Sets the sound instance with the given id to be looping. |
| public void | setPan(long
the sound id soundId, float panning in the range -1 (full left) to 1 (full right). 0 is center position. pan, float the volume in the range [0,1]. volume)Sets the panning and volume of the sound instance with the given id as returned by |
| public void | setPitch(long
the sound id soundId, float the pitch multiplier, 1 == default, >1 == faster, <1 == slower, the value has to be between 0.5 and 2.0 pitch)Changes the pitch multiplier of the sound instance with the given id as returned by |
| public void | setVolume(long
the sound id soundId, float the volume in the range 0 (silent) to 1 (max volume). volume)Changes the volume of the sound instance with the given id as returned by |
| public void | |
| public void | stop(long
the sound id soundId)Stops the sound instance with the given id as returned by |
| dispose | back to summary |
|---|---|
| public void dispose() Redeclares com. Releases all the resources. | |
| loop | back to summary |
|---|---|
| public long loop() Plays the sound, looping. If the sound is already playing, it will be played again, concurrently.
| |
| loop | back to summary |
|---|---|
| public long loop(float volume) Plays the sound, looping. If the sound is already playing, it will be played again, concurrently. You need to stop the
sound via a call to
| |
| loop | back to summary |
|---|---|
| public long loop(float volume, float pitch, float pan) Plays the sound, looping. If the sound is already playing, it will be played again, concurrently. You need to stop the
sound via a call to
| |
| pause | back to summary |
|---|---|
| public void pause() Pauses all instances of this sound. | |
| pause | back to summary |
|---|---|
| public void pause(long soundId) Pauses the sound instance with the given id as returned by
| |
| play | back to summary |
|---|---|
| public long play() Plays the sound. If the sound is already playing, it will be played again, concurrently.
| |
| play | back to summary |
|---|---|
| public long play(float volume) Plays the sound. If the sound is already playing, it will be played again, concurrently.
| |
| play | back to summary |
|---|---|
| public long play(float volume, float pitch, float pan) Plays the sound. If the sound is already playing, it will be played again, concurrently. Note that (with the exception of the web backend) panning only works for mono sounds, not for stereo sounds!
| |
| resume | back to summary |
|---|---|
| public void resume() Resumes all paused instances of this sound. | |
| resume | back to summary |
|---|---|
| public void resume(long soundId) Resumes the sound instance with the given id as returned by
| |
| setLooping | back to summary |
|---|---|
| public void setLooping(long soundId, boolean looping) Sets the sound instance with the given id to be looping. If the sound is no longer playing this has no effect.s
| |
| setPan | back to summary |
|---|---|
| public void setPan(long soundId, float pan, float volume) Sets the panning and volume of the sound instance with the given id as returned by
| |
| setPitch | back to summary |
|---|---|
| public void setPitch(long soundId, float pitch) Changes the pitch multiplier of the sound instance with the given id as returned by
| |
| setVolume | back to summary |
|---|---|
| public void setVolume(long soundId, float volume) Changes the volume of the sound instance with the given id as returned by
| |
| stop | back to summary |
|---|---|
| public void stop() Stops playing all instances of this sound. | |
| stop | back to summary |
|---|---|
| public void stop(long soundId) Stops the sound instance with the given id as returned by
| |