Class AbstractAudioListener
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractAudio
-
- jmri.jmrit.audio.AbstractAudioListener
-
- All Implemented Interfaces:
java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractAudioListener.AudioListenerMoveThreadAn internal class used to create a new thread to monitor and maintain current listener position with respect to velocity.-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.Audio
AT, BUFFER, CMD_BIND_BUFFER, CMD_FADE_IN, CMD_FADE_OUT, CMD_INIT_FACTORY, CMD_LOAD_SOUND, CMD_PAUSE, CMD_PAUSE_TOGGLE, CMD_PLAY, CMD_PLAY_TOGGLE, CMD_QUEUE_BUFFERS, CMD_RESET_POSITION, CMD_RESUME, CMD_REWIND, CMD_STOP, CMD_UNQUEUE_BUFFERS, DECIMAL_PLACES, FADE_IN, FADE_NONE, FADE_OUT, LISTENER, MAX_DISTANCE, SOURCE, STATE_EMPTY, STATE_INITIAL, STATE_LOADED, STATE_MOVING, STATE_PLAYING, STATE_POSITIONED, STATE_STOPPED, UP
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description AbstractAudioListener(java.lang.String systemName)Abstract constructor for new AudioListener with system nameAbstractAudioListener(java.lang.String systemName, java.lang.String userName)Abstract constructor for new AudioListener with system name and user name
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcalculateCurrentPosition()Method to calculate current position based on velocityprotected abstract voidchangePosition(javax.vecmath.Vector3f pos)Method to change the current position of this sourceprotected voiddoResetCurrentPosition()Method to reset the current positionjavax.vecmath.Vector3fgetCurrentOrientation(int which)Return the current orientation of this AudioListener objectjavax.vecmath.Vector3fgetCurrentPosition()Returns the current position of this AudioListener object as a 3-dimensional vector.floatgetGain()Return the current gain settingfloatgetMetersPerUnit()Retrieve the current Meters per unit ratio to use for all distance calculations.javax.vecmath.Vector3fgetOrientation(int which)Return the orientation of this AudioListener objectjavax.vecmath.Vector3fgetPosition()Returns the position of this AudioListener object as a 3-dimensional vector.chargetSubType()An Audio object can represent one of a number of subtypes of object.javax.vecmath.Vector3fgetVelocity()Returns the velocity of this AudioListener object Applies only to sub-types: - Listener - SourcevoidresetCurrentPosition()Method to reset the current position of this AudioListener object to the initial position as defined by setPosition.voidsetGain(float gain)Set the gain of this AudioListener objectvoidsetMetersPerUnit(float metersPerUnit)Method to set the Meters per unit ratio for all distance calculations.voidsetOrientation(javax.vecmath.Vector3f at, javax.vecmath.Vector3f up)Set the orientation of this AudioListener objectvoidsetPosition(float x, float y)Sets the position of this AudioListener object in x and y planes with z plane position fixed at zerovoidsetPosition(float x, float y, float z)Sets the position of this AudioListener object in x, y and z planesvoidsetPosition(javax.vecmath.Vector3f pos)Sets the position of this AudioListener objectvoidsetVelocity(javax.vecmath.Vector3f vel)Sets the velocity of this AudioListener objectvoidstateChanged(int oldState)Method used to update the current state of the Audio object-
Methods inherited from class jmri.implementation.AbstractAudio
cleanup, dispose, getBeanType, getState, getUsageReport, roundDecimal, roundDecimal, setState
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getState, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setState, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
AbstractAudioListener
public AbstractAudioListener(java.lang.String systemName)
Abstract constructor for new AudioListener with system name- Parameters:
systemName- AudioListener object system name (e.g. IAL)
-
AbstractAudioListener
public AbstractAudioListener(java.lang.String systemName, java.lang.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 Detail
-
getSubType
public char getSubType()
Description copied from interface:AudioAn 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:
getSubTypein interfaceAudio- Returns:
- subType char
-
setPosition
public void setPosition(javax.vecmath.Vector3f pos)
Description copied from interface:AudioListenerSets the position of this AudioListener objectApplies only to sub-types:
- Listener
- Source
- Specified by:
setPositionin interfaceAudioListener- Parameters:
pos- 3d position vector
-
setPosition
public void setPosition(float x, float y, float z)
Description copied from interface:AudioListenerSets the position of this AudioListener object in x, y and z planesApplies only to sub-types:
- Listener
- Source
- Specified by:
setPositionin interfaceAudioListener- Parameters:
x- x-coordinatey- y-coordinatez- z-coordinate
-
setPosition
public void setPosition(float x, float y)
Description copied from interface:AudioListenerSets the position of this AudioListener object in x and y planes with z plane position fixed at zeroEquivalent to setPosition(x, y, 0.0f)
Applies only to sub-types:
- Listener
- Source
- Specified by:
setPositionin interfaceAudioListener- Parameters:
x- x-coordinatey- y-coordinate
-
getPosition
public javax.vecmath.Vector3f getPosition()
Description copied from interface:AudioListenerReturns the position of this AudioListener object as a 3-dimensional vector.Applies only to sub-types:
- Listener
- Source
- Specified by:
getPositionin interfaceAudioListener- Returns:
- 3d position vector
-
getCurrentPosition
public javax.vecmath.Vector3f getCurrentPosition()
Description copied from interface:AudioListenerReturns the current position of this AudioListener object as a 3-dimensional vector.Applies only to sub-types:
- Listener
- Source
- Specified by:
getCurrentPositionin interfaceAudioListener- Returns:
- 3d position vector
-
setVelocity
public void setVelocity(javax.vecmath.Vector3f vel)
Description copied from interface:AudioListenerSets the velocity of this AudioListener objectApplies only to sub-types:
- Listener
- Source
- Specified by:
setVelocityin interfaceAudioListener- Parameters:
vel- 3d velocity vector
-
getVelocity
public javax.vecmath.Vector3f getVelocity()
Description copied from interface:AudioListenerReturns the velocity of this AudioListener object Applies only to sub-types: - Listener - Source- Specified by:
getVelocityin interfaceAudioListener- Returns:
- 3d velocity vector
-
calculateCurrentPosition
protected void calculateCurrentPosition()
Method to calculate current position based on velocity
-
resetCurrentPosition
public void resetCurrentPosition()
Description copied from interface:AudioListenerMethod 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:
resetCurrentPositionin interfaceAudioListener
-
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:AudioListenerSet the orientation of this AudioListener objectApplies only to sub-types:
- Listener
- Specified by:
setOrientationin interfaceAudioListener- Parameters:
at- 3d vector representing the positionup- 3d vector representing the look-at point
-
getOrientation
public javax.vecmath.Vector3f getOrientation(int which)
Description copied from interface:AudioListenerReturn the orientation of this AudioListener objectApplies only to sub-types:
- Listener
- Specified by:
getOrientationin interfaceAudioListener- 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:AudioListenerReturn the current orientation of this AudioListener objectApplies only to sub-types:
- Listener
- Specified by:
getCurrentOrientationin interfaceAudioListener- 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:AudioListenerSet the gain of this AudioListener objectApplicable 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:
setGainin interfaceAudioListener- Parameters:
gain- new gain value - range 0.0f to 1.0f
-
getGain
public float getGain()
Description copied from interface:AudioListenerReturn the current gain settingApplies only to sub-types:
- Listener
- Source
- Specified by:
getGainin interfaceAudioListener- Returns:
- float gain
-
setMetersPerUnit
public void setMetersPerUnit(float metersPerUnit)
Description copied from interface:AudioListenerMethod 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:
setMetersPerUnitin interfaceAudioListener- Parameters:
metersPerUnit- Meters per unit ratio
-
getMetersPerUnit
public float getMetersPerUnit()
Description copied from interface:AudioListenerRetrieve 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:
getMetersPerUnitin interfaceAudioListener- Returns:
- Meters per unit ratio
-
stateChanged
public void stateChanged(int oldState)
Description copied from interface:AudioMethod used to update the current state of the Audio object- Specified by:
stateChangedin interfaceAudio- Parameters:
oldState- the former state
-
-