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

public abstract Class OpenALMusic

extends Object
implements Music
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.audio.Music, com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.backends.lwjgl3.audio.Wav.Music, com.badlogic.gdx.backends.lwjgl3.audio.Mp3.Music, com.badlogic.gdx.backends.lwjgl3.audio.Ogg.Music
Imports
java.nio.Buffer, .ByteBuffer, .IntBuffer, org.lwjgl.BufferUtils, org.lwjgl.openal.AL11, com.badlogic.gdx.audio.Music, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.math.MathUtils, com.badlogic.gdx.utils.FloatArray, .GdxRuntimeException

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private final OpenALLwjgl3Audio
private static final int
private IntBuffer
private static final int
protected final FileHandle
private int
private boolean
private boolean
private float
private Music.OnCompletionListener
private float
private float
private FloatArray
private int
private int
private static final ByteBuffer
private static final byte[]
private float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.audio.Music.dispose.

Needs to be called when the Music is no longer needed.

private boolean
fill(int bufferID)

public int
public float
getPosition()

Implements com.badlogic.gdx.audio.Music.getPosition.

Returns the playback position in seconds.

public int
public int
public float
public boolean
public boolean
protected void
loop()

By default, does just the same as reset().

public void
pause()

Implements com.badlogic.gdx.audio.Music.pause.

Pauses the play back.

public void
play()

Implements com.badlogic.gdx.audio.Music.play.

Starts the play back of the music stream.

public abstract int
read(byte[] buffer)

Fills as much of the buffer as possible and returns the number of bytes filled.

public abstract void
reset()

Resets the stream to the beginning.

public void
setLooping(boolean isLooping)

Implements com.badlogic.gdx.audio.Music.setLooping.

Sets whether the music stream is looping.

public void
setOnCompletionListener(Music.OnCompletionListener listener)

Implements com.badlogic.gdx.audio.Music.setOnCompletionListener.

Register a callback to be invoked when the end of a music stream has been reached during playback.

public void
setPan(float pan, float volume)

Implements com.badlogic.gdx.audio.Music.setPan.

Sets the panning and volume of this music stream.

public void
setPosition(float position)

Implements com.badlogic.gdx.audio.Music.setPosition.

Set the playback position in seconds.

protected void
setup(int
The number of channels for the music. 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, 64.
bitDepth
,
int
The number of samples to be played each second. Commonly 44100; can be anything within reason.
sampleRate
)

Prepare our music for playback!

public void
setVolume(float
Must be > 0.
volume
)

Implements com.badlogic.gdx.audio.Music.setVolume.

Sets the volume of this music stream.

public void
stop()

Implements com.badlogic.gdx.audio.Music.stop.

Stops a playing or paused Music instance.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

audioback to summary
private final OpenALLwjgl3Audio audio
bufferCountback to summary
private static final int bufferCount
buffersback to summary
private IntBuffer buffers
bufferSizeback to summary
private static final int bufferSize
fileback to summary
protected final FileHandle file
formatback to summary
private int format
isLoopingback to summary
private boolean isLooping
isPlayingback to summary
private boolean isPlaying
maxSecondsPerBufferback to summary
private float maxSecondsPerBuffer
onCompletionListenerback to summary
private Music.OnCompletionListener onCompletionListener
panback to summary
private float pan
renderedSecondsback to summary
private float renderedSeconds
renderedSecondsQueueback to summary
private FloatArray renderedSecondsQueue
sampleRateback to summary
private int sampleRate
sourceIDback to summary
private int sourceID
tempBufferback to summary
private static final ByteBuffer tempBuffer
tempBytesback to summary
private static final byte[] tempBytes
volumeback to summary
private float volume

Constructor Detail

OpenALMusicback to summary
public OpenALMusic(OpenALLwjgl3Audio audio, FileHandle file)

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.audio.Music.dispose.

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

Needs to be called when the Music is no longer needed.

fillback to summary
private boolean fill(int bufferID)
getChannelsback to summary
public int getChannels()
getPositionback to summary
public float getPosition()

Implements com.badlogic.gdx.audio.Music.getPosition.

Doc from com.badlogic.gdx.audio.Music.getPosition.

Returns the playback position in seconds.

getRateback to summary
public int getRate()
getSourceIdback to summary
public int getSourceId()
getVolumeback to summary
public float getVolume()

Implements com.badlogic.gdx.audio.Music.getVolume.

isLoopingback to summary
public boolean isLooping()

Implements com.badlogic.gdx.audio.Music.isLooping.

isPlayingback to summary
public boolean isPlaying()

Implements com.badlogic.gdx.audio.Music.isPlaying.

loopback to summary
protected void loop()

By default, does just the same as reset(). Used to add special behaviour in Ogg.Music.

pauseback to summary
public void pause()

Implements com.badlogic.gdx.audio.Music.pause.

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

Pauses the play back. If the music stream has not been started yet or has finished playing a call to this method will be ignored.

playback to summary
public void play()

Implements com.badlogic.gdx.audio.Music.play.

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

Starts the play back of the music stream. In case the stream was paused this will resume the play back. In case the music stream is finished playing this will restart the play back.

readback to summary
public abstract int read(byte[] buffer)

Fills as much of the buffer as possible and returns the number of bytes filled. Returns <= 0 to indicate the end of the stream.

resetback to summary
public abstract void reset()

Resets the stream to the beginning.

setLoopingback to summary
public void setLooping(boolean isLooping)

Implements com.badlogic.gdx.audio.Music.setLooping.

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

Sets whether the music stream is looping. This can be called at any time, whether the stream is playing.

setOnCompletionListenerback to summary
public void setOnCompletionListener(Music.OnCompletionListener listener)

Implements com.badlogic.gdx.audio.Music.setOnCompletionListener.

Doc from com.badlogic.gdx.audio.Music.setOnCompletionListener.

Register a callback to be invoked when the end of a music stream has been reached during playback.

setPanback to summary
public void setPan(float pan, float volume)

Implements com.badlogic.gdx.audio.Music.setPan.

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

Sets the panning and volume of this music stream.

setPositionback to summary
public void setPosition(float position)

Implements com.badlogic.gdx.audio.Music.setPosition.

Doc from com.badlogic.gdx.audio.Music.setPosition.

Set the playback position in seconds.

setupback to summary
protected void setup(int channels, int bitDepth, int sampleRate)

Prepare our music for playback!

Parameters
channels:int

The number of channels for the music. 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, 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(float volume)

Implements com.badlogic.gdx.audio.Music.setVolume.

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

Sets the volume of this music stream. The volume must be given in the range [0,1] with 0 being silent and 1 being the maximum volume.

Parameters
volume:float

Must be > 0.

stopback to summary
public void stop()

Implements com.badlogic.gdx.audio.Music.stop.

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

Stops a playing or paused Music instance. Next time play() is invoked the Music will start from the beginning.

updateback to summary
public void update()