Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LWJGL/lwjgl3/llms.txt

Use this file to discover all available pages before exploring further.

LWJGL 3 provides bindings for four audio libraries, ranging from the standard OpenAL cross-platform audio API to the comprehensive FMOD audio engine. Whether you need simple positional 3D sound effects or a full music and mixing solution, there is a binding to suit your needs.
The current stable release is 3.4.2. All audio bindings are optional modules. Add only those you need using the LWJGL build configurator.

OpenAL

Maven artifact: org.lwjgl:lwjgl-openal
Key classes: AL10, AL11, ALC10, ALC11, EXTThreadLocalContext, SOFTDirectChannels
OpenAL is the standard cross-platform 3D positional audio API, analogous to OpenGL for graphics. It models sound sources in 3D space with a listener position, enabling distance attenuation, Doppler effects, and directional filtering out of the box. LWJGL exposes the full core API through per-version classes.
ClassAPI coverage
AL10OpenAL 1.0 — buffers, sources, listener, gain, pitch
AL11OpenAL 1.1 — alSource3i, alGetSourcei64 extensions
ALC10ALC (audio context) 1.0 — device enumeration and context creation
ALC11ALC 1.1 — alcCaptureOpenDevice for audio capture
Basic usage pattern:
// Open the default device and create a context
long device = ALC10.alcOpenDevice((ByteBuffer) null);
ALCCapabilities alcCaps = ALC.createCapabilities(device);
long context = ALC10.alcCreateContext(device, (IntBuffer) null);
ALC10.alcMakeContextCurrent(context);
AL.createCapabilities(alcCaps);

// Generate a buffer, fill it with PCM data, and attach to a source
int buffer = AL10.alGenBuffers();
AL10.alBufferData(buffer, AL10.AL_FORMAT_STEREO16, pcmData, sampleRate);
int source = AL10.alGenSources();
AL10.alSourcei(source, AL10.AL_BUFFER, buffer);
AL10.alSourcePlay(source);
Use the org.lwjgl.openal.AL and org.lwjgl.openal.ALC capability classes to check for extensions before calling optional entry points such as EFX (environmental audio effects).

OpenAL Soft

Note: OpenAL Soft is a software implementation of the OpenAL 3D audio API — it is not a separate LWJGL artifact. When you add org.lwjgl:lwjgl-openal, LWJGL bundles the OpenAL Soft native library as the default OpenAL implementation on platforms where a system OpenAL is not present. OpenAL Soft is LGPL-licensed, cross-platform, and actively maintained. It supports HRTF-based binaural audio, multiple backends (PulseAudio, ALSA, WASAPI, Core Audio), and many AL extensions not found in older system OpenAL implementations.
LWJGL’s bundled OpenAL Soft native JARs (lwjgl-openal-natives-*.jar) are what provide the actual audio implementation at runtime on most platforms. You do not need to install a system OpenAL separately.

FMOD

Maven artifact: org.lwjgl:lwjgl-fmod
Key classes: FMOD, FMODSystem, FMODSound, FMODChannel, FMODChannelGroup, FMODSTUDIO
FMOD is a professional-grade, end-to-end audio engine used in thousands of commercial games. The LWJGL binding exposes both the low-level FMOD Core API and the higher-level FMOD Studio API for adaptive and interactive audio authoring.
API layerDescription
FMOD CoreDirect sound playback, DSP effects chains, channel mixing, and 3D positioning
FMOD StudioEvent-driven audio with live parameter control, authored in the FMOD Studio tool
Licensing: FMOD is a proprietary library. Using it in a commercial product requires a license from Firelight Technologies. Review the FMOD licensing page before shipping. The LWJGL binding itself is BSD-licensed, but the FMOD native libraries are not.You must supply the FMOD native libraries yourself — they are not bundled in LWJGL’s Maven artifacts.
Feature highlights:
  • Supports MP3, OGG, WAV, FLAC, AIFF, XMA, and many proprietary formats
  • Built-in DSP: reverb, compressor, parametric EQ, convolution reverb
  • 3D audio with occlusion, obstruction, and geometry support
  • Low-latency output targeting 2 ms on supported hardware
  • Live mixing and real-time parameter tweaking via FMOD Studio

Opus

Maven artifact: org.lwjgl:lwjgl-opus
Key classes: Opus, OpusEncoder, OpusDecoder, OpusMSEncoder
Opus is a totally open, royalty-free, highly versatile audio codec standardized by the IETF (RFC 6716). It targets bitrates from 6 kb/s to 510 kb/s and handles both speech and music with low latency — making it ideal for game voice chat, streaming, and compressed audio assets.
FeatureDetail
Bitrate range6 – 510 kb/s
Sample rates8, 12, 16, 24, 48 kHz
Frame sizes2.5 ms – 120 ms
ChannelsMono, stereo, and multichannel (Opus Multistream)
LicenseBSD / royalty-free
Typical encode/decode cycle:
// Encoder setup
int[] error = new int[1];
long encoder = Opus.opus_encoder_create(48000, 2, Opus.OPUS_APPLICATION_AUDIO, error);
// Encode a frame of 960 stereo 16-bit samples (20 ms at 48 kHz)
int packetBytes = Opus.opus_encode(encoder, pcmFrame, 960, outputBuffer, outputBuffer.capacity());

// Decoder setup
long decoder = Opus.opus_decoder_create(48000, 2, error);
int samplesDecoded = Opus.opus_decode(decoder, packet, pcmOut, 960, 0);
For networked voice chat, target OPUS_APPLICATION_VOIP and a 20 ms frame size at 48 kHz. For compressed music assets that play back from disk, use OPUS_APPLICATION_AUDIO with a higher bitrate (128–192 kb/s).

Choosing an Audio Backend

Use caseRecommended binding
Simple 3D positional sound effectsOpenAL (org.lwjgl:lwjgl-openal)
Binaural HRTF audioOpenAL via OpenAL Soft (bundled)
Professional adaptive/interactive musicFMOD (org.lwjgl:lwjgl-fmod)
Voice chat or audio streaming over a networkOpus (org.lwjgl:lwjgl-opus)
Decoding Ogg Vorbis for background musicstb_vorbis (org.lwjgl:lwjgl-stb)

Build docs developers (and LLMs) love