-
Notifications
You must be signed in to change notification settings - Fork 5
Sound Listener
Hangman edited this page Apr 27, 2025
·
5 revisions
The listener determines the sound output from spatial sound sources by its position, orientation and speed.
SoundListener listener = audio.getListener();
These values can, but do not have to be set.
In a 3D game in first person view, you probably want the listener to always contain the values of the camera, so make sure to update the listener every frame.
There are separate convenience methods for this.
listener.setPosition(position);
listener.setOrientation(at, up);
listener.setSpeed(speed);
// you can also method-chain it:
listener.setPosition(position).setOrientation(at, up).setSpeed(speed);
// convenience methods when using a libGDX Camera
listener.setPosition(camera);
listener.setOrientation(camera);
The speed attribute is only used for the Doppler effect, if you don't want that, just leave it alone.