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

public Class OpenALLwjgl3Audio

extends Object
implements Lwjgl3Audio
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.backends.lwjgl3.audio.Lwjgl3Audio, com.badlogic.gdx.Audio, com.badlogic.gdx.utils.Disposable
Static Imports
org.lwjgl.openal.AL10.*, org.lwjgl.openal.ALC10.*, .EXTDisconnect.ALC_CONNECTED, .EnumerateAllExt.ALC_ALL_DEVICES_SPECIFIER

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private IntArray
pack-priv long
pack-priv long
private final int
private final int
private ObjectMap<String, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALMusic>>
private ObjectMap<String, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALSound>>
private IntArray
private int
pack-priv Array<OpenALMusic>
private long
pack-priv boolean
private Thread
private String
private OpenALSound[]
private LongMap<Integer>
private IntMap<Long>

Constructor Summary

AccessConstructor and Description
public
public
OpenALLwjgl3Audio(int simultaneousSources, int deviceBufferCount, int deviceBufferSize)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

public void
forget(OpenALSound sound)

Removes the disposed sound from the least recently played list

pack-priv void
freeBuffer(int bufferID)

pack-priv void
freeSource(int sourceID)

public String[]
getAvailableOutputDevices()

Implements com.badlogic.gdx.Audio.getAvailableOutputDevices.

This function returns a list of fully qualified Output device names.

public long
getSoundId(int sourceId)

public int
getSourceId(long soundId)

public AudioDevice
newAudioDevice(int sampleRate, final boolean isMono)

Implements com.badlogic.gdx.Audio.newAudioDevice.

Creates a new AudioDevice either in mono or stereo mode.

public AudioRecorder
newAudioRecorder(int samplingRate, boolean isMono)

Implements com.badlogic.gdx.Audio.newAudioRecorder.

Creates a new AudioRecorder.

public OpenALMusic
newMusic(FileHandle file)

Implements com.badlogic.gdx.Audio.newMusic.

Creates a new Music instance which is used to play back a music stream from a file.

public OpenALSound
newSound(FileHandle file)

Implements com.badlogic.gdx.Audio.newSound.

Creates a new Sound which is used to play back audio effects such as gun shots or explosions.

public OpenALSound
newSound(FileHandle file, String extension)

pack-priv int
obtainSource(boolean isMusic)

public void
pauseSound(long soundId)

pack-priv void
pauseSourcesWithBuffer(int bufferID)

public void
public void
public void
resumeSound(long soundId)

pack-priv void
protected void
retain(OpenALSound sound, boolean stop)

Retains a list of the most recently played sounds and stops the sound played least recently if necessary for a new sound to play

public void
setSoundGain(long soundId, float volume)

public void
setSoundLooping(long soundId, boolean looping)

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

public void
setSoundPitch(long soundId, float pitch)

public void
stopSound(long soundId)

pack-priv void
stopSourcesWithBuffer(int bufferID)

public boolean
switchOutputDevice(String deviceIdentifier)

Implements com.badlogic.gdx.Audio.switchOutputDevice.

Sets a new OutputDevice.

private boolean
switchOutputDevice(String deviceIdentifier, boolean setPreferred)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allSourcesback to summary
private IntArray allSources
contextback to summary
pack-priv long context
deviceback to summary
pack-priv long device
deviceBufferCountback to summary
private final int deviceBufferCount
deviceBufferSizeback to summary
private final int deviceBufferSize
extensionToMusicClassback to summary
private ObjectMap<String, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALMusic>> extensionToMusicClass
extensionToSoundClassback to summary
private ObjectMap<String, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALSound>> extensionToSoundClass
idleSourcesback to summary
private IntArray idleSources
mostRecetSoundback to summary
private int mostRecetSound
musicback to summary
pack-priv Array<OpenALMusic> music
nextSoundIdback to summary
private long nextSoundId
noDeviceback to summary
pack-priv boolean noDevice
observerThreadback to summary
private Thread observerThread
preferredOutputDeviceback to summary
private String preferredOutputDevice
recentSoundsback to summary
private OpenALSound[] recentSounds
soundIdToSourceback to summary
private LongMap<Integer> soundIdToSource
sourceToSoundIdback to summary
private IntMap<Long> sourceToSoundId

Constructor Detail

OpenALLwjgl3Audioback to summary
public OpenALLwjgl3Audio()
OpenALLwjgl3Audioback to summary
public OpenALLwjgl3Audio(int simultaneousSources, int deviceBufferCount, int deviceBufferSize)

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Doc from com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

Annotations
@Override
forgetback to summary
public void forget(OpenALSound sound)

Removes the disposed sound from the least recently played list

freeBufferback to summary
pack-priv void freeBuffer(int bufferID)
freeSourceback to summary
pack-priv void freeSource(int sourceID)
getAvailableOutputDevicesback to summary
public String[] getAvailableOutputDevices()

Implements com.badlogic.gdx.Audio.getAvailableOutputDevices.

Doc from com.badlogic.gdx.Audio.getAvailableOutputDevices.

This function returns a list of fully qualified Output device names. This function is only implemented on desktop and web. Note that on gwt the GwtApplicationConfiguration#fetchAvailableOutputDevices attribute needs to be set to true for asking the user for permission! On all other platforms it will return an empty array. It will also return an empty array on error. The names returned need os dependent preprocessing before exposing to a user.

Annotations
@Override
getSoundIdback to summary
public long getSoundId(int sourceId)
getSourceIdback to summary
public int getSourceId(long soundId)
newAudioDeviceback to summary
public AudioDevice newAudioDevice(int sampleRate, final boolean isMono)

Implements com.badlogic.gdx.Audio.newAudioDevice.

Doc from com.badlogic.gdx.Audio.newAudioDevice.

Creates a new AudioDevice either in mono or stereo mode. The AudioDevice has to be disposed via its AudioDevice#dispose() method when it is no longer used.

newAudioRecorderback to summary
public AudioRecorder newAudioRecorder(int samplingRate, boolean isMono)

Implements com.badlogic.gdx.Audio.newAudioRecorder.

Doc from com.badlogic.gdx.Audio.newAudioRecorder.

Creates a new AudioRecorder. The AudioRecorder has to be disposed after it is no longer used.

newMusicback to summary
public OpenALMusic newMusic(FileHandle file)

Implements com.badlogic.gdx.Audio.newMusic.

Doc from com.badlogic.gdx.Audio.newMusic.

Creates a new Music instance which is used to play back a music stream from a file. Currently supported formats are WAV, MP3 and OGG. The Music instance has to be disposed if it is no longer used via the Music#dispose() method. Music instances are automatically paused when ApplicationListener#pause() is called and resumed when ApplicationListener#resume() is called.

newSoundback to summary
public OpenALSound newSound(FileHandle file)

Implements com.badlogic.gdx.Audio.newSound.

Doc from com.badlogic.gdx.Audio.newSound.

Creates a new Sound which is used to play back audio effects such as gun shots or explosions. The Sound's audio data is retrieved from the file specified via the FileHandle. Note that the complete audio data is loaded into RAM. You should therefore not load big audio files with this methods. The current upper limit for decoded audio is 1 MB.

Currently supported formats are WAV, MP3 and OGG.

The Sound has to be disposed if it is no longer used via the Sound#dispose() method.

newSoundback to summary
public OpenALSound newSound(FileHandle file, String extension)
obtainSourceback to summary
pack-priv int obtainSource(boolean isMusic)
pauseSoundback to summary
public void pauseSound(long soundId)
pauseSourcesWithBufferback to summary
pack-priv void pauseSourcesWithBuffer(int bufferID)
registerMusicback to summary
public void registerMusic(String extension, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALMusic> soundSupplier)
registerSoundback to summary
public void registerSound(String extension, BiFunction<OpenALLwjgl3Audio, FileHandle, OpenALSound> soundSupplier)
resumeSoundback to summary
public void resumeSound(long soundId)
resumeSourcesWithBufferback to summary
pack-priv void resumeSourcesWithBuffer(int bufferID)
retainback to summary
protected void retain(OpenALSound sound, boolean stop)

Retains a list of the most recently played sounds and stops the sound played least recently if necessary for a new sound to play

setSoundGainback to summary
public void setSoundGain(long soundId, float volume)
setSoundLoopingback to summary
public void setSoundLooping(long soundId, boolean looping)
setSoundPanback to summary
public void setSoundPan(long soundId, float pan, float volume)
setSoundPitchback to summary
public void setSoundPitch(long soundId, float pitch)
stopSoundback to summary
public void stopSound(long soundId)
stopSourcesWithBufferback to summary
pack-priv void stopSourcesWithBuffer(int bufferID)
switchOutputDeviceback to summary
public boolean switchOutputDevice(String deviceIdentifier)

Implements com.badlogic.gdx.Audio.switchOutputDevice.

Doc from com.badlogic.gdx.Audio.switchOutputDevice.

Sets a new OutputDevice. The identifier can be retrieved from Audio#getAvailableOutputDevices(). If null is passed, it will switch to auto.

Annotations
@Override
switchOutputDeviceback to summary
private boolean switchOutputDevice(String deviceIdentifier, boolean setPreferred)
updateback to summary
public void update()

Implements com.badlogic.gdx.backends.lwjgl3.audio.Lwjgl3Audio.update.

Annotations
@Override