APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.backends.lwjgl.audio

public Class OpenALSound

extends Object
implements Sound
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.audio.Sound, com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.backends.lwjgl.audio.Wav.Sound, com.badlogic.gdx.backends.lwjgl.audio.Mp3.Sound, com.badlogic.gdx.backends.lwjgl.audio.Ogg.Sound
Imports
java.nio.Buffer, .ByteBuffer, .ByteOrder, com.badlogic.gdx.audio.Sound

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private final OpenALLwjglAudio
private int
private int
private float
private int
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.audio.Sound.dispose.

Releases all the resources.

public float
duration()

Returns the length of the sound in seconds.

public int
getChannels()

Returns the number of channels of the sound (1 for mono, 2 for stereo).

public int
getRate()

Returns the original sample rate of the sound in Hz.

public String
public long
loop()

Implements com.badlogic.gdx.audio.Sound.loop.

Plays the sound, looping.

public long
loop(float volume)

Implements com.badlogic.gdx.audio.Sound.loop.

Plays the sound, looping.

public long
loop(float volume, float pitch, float pan)

Implements com.badlogic.gdx.audio.Sound.loop.

Plays the sound, looping.

public void
pause()

Implements com.badlogic.gdx.audio.Sound.pause.

Pauses all instances of this sound.

public void
pause(long soundId)

Implements com.badlogic.gdx.audio.Sound.pause.

Pauses the sound instance with the given id as returned by play() or play(float).

public long
play()

Implements com.badlogic.gdx.audio.Sound.play.

Plays the sound.

public long
play(float volume)

Implements com.badlogic.gdx.audio.Sound.play.

Plays the sound.

public long
play(float volume, float pitch, float pan)

Implements com.badlogic.gdx.audio.Sound.play.

Plays the sound.

public void
resume()

Implements com.badlogic.gdx.audio.Sound.resume.

Resumes all paused instances of this sound.

public void
resume(long soundId)

Implements com.badlogic.gdx.audio.Sound.resume.

Resumes the sound instance with the given id as returned by play() or play(float).

public void
setLooping(long soundId, boolean looping)

Implements com.badlogic.gdx.audio.Sound.setLooping.

Sets the sound instance with the given id to be looping.

public void
setPan(long soundId, float pan, float volume)

Implements com.badlogic.gdx.audio.Sound.setPan.

Sets the panning and volume of the sound instance with the given id as returned by play() or play(float).

public void
setPitch(long soundId, float pitch)

Implements com.badlogic.gdx.audio.Sound.setPitch.

Changes the pitch multiplier of the sound instance with the given id as returned by play() or play(float).

public void
setType(String
The type of audio, such as mp3, ogg or wav.
type
)

pack-priv void
setup(byte[]
Byte array of raw PCM data to be played.
pcm
,
int
The number of channels for the sound. Most commonly 1 (for mono) or 2 (for stereo).
channels
,
int
The number of bits in each sample. Normally 16. Can also be 8, 32 or sometimes 64.
bitDepth
,
int
The number of samples to be played each second. Commonly 44100; can be anything within reason.
sampleRate
)

Prepare our sound for playback!

public void
setVolume(long soundId, float volume)

Implements com.badlogic.gdx.audio.Sound.setVolume.

Changes the volume of the sound instance with the given id as returned by play() or play(float).

public void
stop()

Implements com.badlogic.gdx.audio.Sound.stop.

Stops playing all instances of this sound.

public void
stop(long soundId)

Implements com.badlogic.gdx.audio.Sound.stop.

Stops the sound instance with the given id as returned by play() or play(float).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

audioback to summary
private final OpenALLwjglAudio audio
bufferIDback to summary
private int bufferID
channelsback to summary
private int channels
durationback to summary
private float duration
sampleRateback to summary
private int sampleRate
typeback to summary
private String type

Constructor Detail

OpenALSoundback to summary
public OpenALSound(OpenALLwjglAudio audio)

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.audio.Sound.dispose.

Doc from com.badlogic.gdx.audio.Sound.dispose.

Releases all the resources.

durationback to summary
public float duration()

Returns the length of the sound in seconds.

getChannelsback to summary
public int getChannels()

Returns the number of channels of the sound (1 for mono, 2 for stereo).

getRateback to summary
public int getRate()

Returns the original sample rate of the sound in Hz.

getTypeback to summary
public String getType()
loopback to summary
public long loop()

Implements com.badlogic.gdx.audio.Sound.loop.

Doc from com.badlogic.gdx.audio.Sound.loop.

Plays the sound, looping. If the sound is already playing, it will be played again, concurrently.

loopback to summary
public long loop(float volume)

Implements com.badlogic.gdx.audio.Sound.loop.

Doc from com.badlogic.gdx.audio.Sound.loop.

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 stop(long) using the returned id.

Annotations
@Override
loopback to summary
public long loop(float volume, float pitch, float pan)

Implements com.badlogic.gdx.audio.Sound.loop.

Doc from com.badlogic.gdx.audio.Sound.loop.

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 stop(long) using the returned id. Note that (with the exception of the web backend) panning only works for mono sounds, not for stereo sounds!

Annotations
@Override
pauseback to summary
public void pause()

Implements com.badlogic.gdx.audio.Sound.pause.

Doc from com.badlogic.gdx.audio.Sound.pause.

Pauses all instances of this sound.

Annotations
@Override
pauseback to summary
public void pause(long soundId)

Implements com.badlogic.gdx.audio.Sound.pause.

Doc from com.badlogic.gdx.audio.Sound.pause.

Pauses the sound instance with the given id as returned by play() or play(float). If the sound is no longer playing, this has no effect.

Annotations
@Override
playback to summary
public long play()

Implements com.badlogic.gdx.audio.Sound.play.

Doc from com.badlogic.gdx.audio.Sound.play.

Plays the sound. If the sound is already playing, it will be played again, concurrently.

playback to summary
public long play(float volume)

Implements com.badlogic.gdx.audio.Sound.play.

Doc from com.badlogic.gdx.audio.Sound.play.

Plays the sound. If the sound is already playing, it will be played again, concurrently.

playback to summary
public long play(float volume, float pitch, float pan)

Implements com.badlogic.gdx.audio.Sound.play.

Doc from com.badlogic.gdx.audio.Sound.play.

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!

Annotations
@Override
resumeback to summary
public void resume()

Implements com.badlogic.gdx.audio.Sound.resume.

Doc from com.badlogic.gdx.audio.Sound.resume.

Resumes all paused instances of this sound.

Annotations
@Override
resumeback to summary
public void resume(long soundId)

Implements com.badlogic.gdx.audio.Sound.resume.

Doc from com.badlogic.gdx.audio.Sound.resume.

Resumes the sound instance with the given id as returned by play() or play(float). If the sound is not paused, this has no effect.

Annotations
@Override
setLoopingback to summary
public void setLooping(long soundId, boolean looping)

Implements com.badlogic.gdx.audio.Sound.setLooping.

Doc from com.badlogic.gdx.audio.Sound.setLooping.

Sets the sound instance with the given id to be looping. If the sound is no longer playing this has no effect.s

Annotations
@Override
setPanback to summary
public void setPan(long soundId, float pan, float volume)

Implements com.badlogic.gdx.audio.Sound.setPan.

Doc from com.badlogic.gdx.audio.Sound.setPan.

Sets the panning and volume of the sound instance with the given id as returned by play() or play(float). If the sound is no longer playing, this has no effect. Note that panning only works for mono sounds, not for stereo sounds!

Annotations
@Override
setPitchback to summary
public void setPitch(long soundId, float pitch)

Implements com.badlogic.gdx.audio.Sound.setPitch.

Doc from com.badlogic.gdx.audio.Sound.setPitch.

Changes the pitch multiplier of the sound instance with the given id as returned by play() or play(float). If the sound is no longer playing, this has no effect.

Annotations
@Override
setTypeback to summary
public void setType(String type)
Parameters
type:String

The type of audio, such as mp3, ogg or wav.

setupback to summary
pack-priv void setup(byte[] pcm, int channels, int bitDepth, int sampleRate)

Prepare our sound for playback!

Parameters
pcm:byte[]

Byte array of raw PCM data to be played.

channels:int

The number of channels for the sound. Most commonly 1 (for mono) or 2 (for stereo).

bitDepth:int

The number of bits in each sample. Normally 16. Can also be 8, 32 or sometimes 64.

sampleRate:int

The number of samples to be played each second. Commonly 44100; can be anything within reason.

setVolumeback to summary
public void setVolume(long soundId, float volume)

Implements com.badlogic.gdx.audio.Sound.setVolume.

Doc from com.badlogic.gdx.audio.Sound.setVolume.

Changes the volume of the sound instance with the given id as returned by play() or play(float). If the sound is no longer playing, this has no effect.

Annotations
@Override
stopback to summary
public void stop()

Implements com.badlogic.gdx.audio.Sound.stop.

Doc from com.badlogic.gdx.audio.Sound.stop.

Stops playing all instances of this sound.

stopback to summary
public void stop(long soundId)

Implements com.badlogic.gdx.audio.Sound.stop.

Doc from com.badlogic.gdx.audio.Sound.stop.

Stops the sound instance with the given id as returned by play() or play(float). If the sound is no longer playing, this has no effect.

Annotations
@Override