Class AbstractAudioListener

All Implemented Interfaces:
Comparable<NamedBean>, Audio, PropertyChangeProvider, AudioListener, NamedBean
Direct Known Subclasses:
JavaSoundAudioListener, JoalAudioListener, NullAudioListener

public abstract class AbstractAudioListener extends AbstractAudio implements AudioListener
Base implementation of the AudioListener class.

Specific implementations will extend this base class.


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

  • Constructor Details

    • AbstractAudioListener

      public AbstractAudioListener(String systemName)
      Abstract constructor for new AudioListener with system name
      Parameters:
      systemName - AudioListener object system name (e.g. IAL)
    • AbstractAudioListener

      public AbstractAudioListener(String systemName, String userName)
      Abstract constructor for new AudioListener with system name and user name
      Parameters:
      systemName - AudioListener object system name (e.g. IAL)
      userName - AudioListener object user name
  • Method Details

    • getSubType

      public char getSubType()
      Description copied from interface: Audio
      An Audio object can represent one of a number of subtypes of object.

      This method enables us to determine which of those subtypes this particular instance is and be able to process accordingly.

      Current supported subtypes are:

      • B = Buffer
      • L = Listener
      • S = Source
      Specified by:
      getSubType in interface Audio
      Returns:
      subType char
    • setPosition

      public void setPosition(javax.vecmath.Vector3f pos)
      Description copied from interface: AudioListener
      Sets the position of this AudioListener object

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      setPosition in interface AudioListener
      Parameters:
      pos - 3d position vector
    • setPosition

      public void setPosition(float x, float y, float z)
      Description copied from interface: AudioListener
      Sets the position of this AudioListener object in x, y and z planes

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      setPosition in interface AudioListener
      Parameters:
      x - x-coordinate
      y - y-coordinate
      z - z-coordinate
    • setPosition

      public void setPosition(float x, float y)
      Description copied from interface: AudioListener
      Sets the position of this AudioListener object in x and y planes with z plane position fixed at zero

      Equivalent to setPosition(x, y, 0.0f)

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      setPosition in interface AudioListener
      Parameters:
      x - x-coordinate
      y - y-coordinate
    • getPosition

      public javax.vecmath.Vector3f getPosition()
      Description copied from interface: AudioListener
      Returns the position of this AudioListener object as a 3-dimensional vector.

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      getPosition in interface AudioListener
      Returns:
      3d position vector
    • getCurrentPosition

      public javax.vecmath.Vector3f getCurrentPosition()
      Description copied from interface: AudioListener
      Returns the current position of this AudioListener object as a 3-dimensional vector.

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      getCurrentPosition in interface AudioListener
      Returns:
      3d position vector
    • setVelocity

      public void setVelocity(javax.vecmath.Vector3f vel)
      Description copied from interface: AudioListener
      Sets the velocity of this AudioListener object

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      setVelocity in interface AudioListener
      Parameters:
      vel - 3d velocity vector
    • getVelocity

      public javax.vecmath.Vector3f getVelocity()
      Description copied from interface: AudioListener
      Returns the velocity of this AudioListener object Applies only to sub-types: - Listener - Source
      Specified by:
      getVelocity in interface AudioListener
      Returns:
      3d velocity vector
    • calculateCurrentPosition

      protected void calculateCurrentPosition()
      Method to calculate current position based on velocity
    • resetCurrentPosition

      public void resetCurrentPosition()
      Description copied from interface: AudioListener
      Method to reset the current position of this AudioListener object to the initial position as defined by setPosition.

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      resetCurrentPosition in interface AudioListener
    • doResetCurrentPosition

      protected void doResetCurrentPosition()
      Method to reset the current position
    • changePosition

      protected abstract void changePosition(javax.vecmath.Vector3f pos)
      Method to change the current position of this source
      Parameters:
      pos - new position
    • setOrientation

      public void setOrientation(javax.vecmath.Vector3f at, javax.vecmath.Vector3f up)
      Description copied from interface: AudioListener
      Set the orientation of this AudioListener object

      Applies only to sub-types:

      • Listener
      Specified by:
      setOrientation in interface AudioListener
      Parameters:
      at - 3d vector representing the position
      up - 3d vector representing the look-at point
    • getOrientation

      public javax.vecmath.Vector3f getOrientation(int which)
      Description copied from interface: AudioListener
      Return the orientation of this AudioListener object

      Applies only to sub-types:

      • Listener
      Specified by:
      getOrientation in interface AudioListener
      Parameters:
      which - the orientation vector to return: == AT - position; == UP - look-at point
      Returns:
      vector representing the chosen orientation vector
    • getCurrentOrientation

      public javax.vecmath.Vector3f getCurrentOrientation(int which)
      Description copied from interface: AudioListener
      Return the current orientation of this AudioListener object

      Applies only to sub-types:

      • Listener
      Specified by:
      getCurrentOrientation in interface AudioListener
      Parameters:
      which - the orientation vector to return: == AT - position; == UP - look-at point
      Returns:
      vector representing the chosen orientation vector
    • setGain

      public void setGain(float gain)
      Description copied from interface: AudioListener
      Set the gain of this AudioListener object

      Applicable values 0.0f to 1.0f

      When applied to Listeners, has the effect of altering the master gain (or volume)

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      setGain in interface AudioListener
      Parameters:
      gain - new gain value - range 0.0f to 1.0f
    • getGain

      public float getGain()
      Description copied from interface: AudioListener
      Return the current gain setting

      Applies only to sub-types:

      • Listener
      • Source
      Specified by:
      getGain in interface AudioListener
      Returns:
      float gain
    • setMetersPerUnit

      public void setMetersPerUnit(float metersPerUnit)
      Description copied from interface: AudioListener
      Method to set the Meters per unit ratio for all distance calculations.

      Default value = 1.0f (i.e. 1 unit == 1 metre)

      Typical alternative values:

      • 0.3048f (i.e. 1 unit == 1 foot)
      • 0.9144f (i.e. 1 unit == 1 yard)

      Applies only to sub-types:

      • Listener
      Specified by:
      setMetersPerUnit in interface AudioListener
      Parameters:
      metersPerUnit - Meters per unit ratio
    • getMetersPerUnit

      public float getMetersPerUnit()
      Description copied from interface: AudioListener
      Retrieve the current Meters per unit ratio to use for all distance calculations.

      Default value = 1.0f (i.e. 1 unit == 1 metre)

      Typical alternative values:

      • 0.3048f (i.e. 1 unit == 1 foot)
      • 0.9144f (i.e. 1 unit == 1 yard)

      Applies only to sub-types:

      • Listener
      Specified by:
      getMetersPerUnit in interface AudioListener
      Returns:
      Meters per unit ratio
    • stateChanged

      public void stateChanged(int oldState)
      Description copied from interface: Audio
      Method used to update the current state of the Audio object
      Specified by:
      stateChanged in interface Audio
      Parameters:
      oldState - the former state