Class Listener

java.lang.Object
com.jme3.audio.Listener

public class Listener extends Object
Represents the audio listener in the 3D sound scene. The listener defines the point of view from which sound is heard, influencing spatial audio effects like panning and Doppler shift.
  • Constructor Details

    • Listener

      public Listener()
      Constructs a new Listener with default parameters.
    • Listener

      public Listener(Listener source)
      Constructs a new Listener by copying the properties of another Listener.
      Parameters:
      source - The Listener to copy the properties from.
  • Method Details

    • setRenderer

      public void setRenderer(AudioRenderer renderer)
      Sets the AudioRenderer associated with this listener. The renderer is responsible for applying the listener's parameters to the audio output.
      Parameters:
      renderer - The AudioRenderer to associate with.
    • getVolume

      public float getVolume()
      Gets the current volume of the listener.
      Returns:
      The current volume.
    • setVolume

      public void setVolume(float volume)
      Sets the volume of the listener. If an AudioRenderer is set, it will be notified of the volume change.
      Parameters:
      volume - The new volume.
    • getLocation

      public Vector3f getLocation()
      Gets the current location of the listener in world space.
      Returns:
      The listener's location as a Vector3f.
    • getRotation

      public Quaternion getRotation()
      Gets the current rotation of the listener in world space.
      Returns:
      The listener's rotation as a Quaternion.
    • getVelocity

      public Vector3f getVelocity()
      Gets the current velocity of the listener. This is used for Doppler effect calculations.
      Returns:
      The listener's velocity as a Vector3f.
    • getLeft

      public Vector3f getLeft()
      Gets the left direction vector of the listener. This vector is derived from the listener's rotation.
      Returns:
      The listener's left direction as a Vector3f.
    • getUp

      public Vector3f getUp()
      Gets the up direction vector of the listener. This vector is derived from the listener's rotation.
      Returns:
      The listener's up direction as a Vector3f.
    • getDirection

      public Vector3f getDirection()
      Gets the forward direction vector of the listener. This vector is derived from the listener's rotation.
      Returns:
      The listener's forward direction.
    • setLocation

      public void setLocation(Vector3f location)
      Sets the location of the listener in world space. If an AudioRenderer is set, it will be notified of the position change.
      Parameters:
      location - The new location of the listener.
    • setRotation

      public void setRotation(Quaternion rotation)
      Sets the rotation of the listener in world space. If an AudioRenderer is set, it will be notified of the rotation change.
      Parameters:
      rotation - The new rotation of the listener.
    • setVelocity

      public void setVelocity(Vector3f velocity)
      Sets the velocity of the listener. This is used for Doppler effect calculations. If an AudioRenderer is set, it will be notified of the velocity change.
      Parameters:
      velocity - The new velocity of the listener.