Class JoalAudioSource
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractAudio
-
- jmri.jmrit.audio.AbstractAudioSource
-
- jmri.jmrit.audio.JoalAudioSource
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,Audio
,PropertyChangeProvider
,AudioSource
,NamedBean
public class JoalAudioSource extends AbstractAudioSource
JOAL implementation of the Audio Source sub-class.For now, no system-specific implementations are forseen - this will remain internal-only
This software is based on or using the JOAL Library available from http://jogamp.org/joal/www/
JOAL is released under the BSD license. The full license terms follow:
Copyright (c) 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
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/interfaces inherited from class jmri.jmrit.audio.AbstractAudioSource
AbstractAudioSource.AudioSourceFadeThread, AbstractAudioSource.AudioSourceMoveThread
-
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.jmrit.audio.AudioSource
LOOP_CONTINUOUS, LOOP_NONE
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description JoalAudioSource(java.lang.String systemName)
Constructor for new JoalAudioSource with system nameJoalAudioSource(java.lang.String systemName, java.lang.String userName)
Constructor for new JoalAudioSource with system name and user name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
bindAudioBuffer(AudioBuffer audioBuffer)
Binds this AudioSource with the specified AudioBuffer.protected void
calculateGain()
Calculate the gain of this AudioSource based on distance from listener and fade levels.protected void
changePosition(javax.vecmath.Vector3f pos)
Change the current position of this source.protected void
cleanup()
Abstract method that concrete classes will implement to perform necessary cleanup routines.protected void
doFadeIn()
Fade in then play this AudioSource.protected void
doFadeOut()
Fade out then stop this AudioSource.protected void
doPause()
Stop playing the clip but retain the current position.protected void
doPlay()
Play the clip from the beginning.protected void
doResume()
Play the clip from the current position.protected void
doRewind()
Rewind clip to the beginning.protected void
doStop()
Stop playing the clip and rewind to the beginning.int
getState()
Provide generic access to internal state.int
numProcessedBuffers()
int
numQueuedBuffers()
Report the number of AudioBuffers queued to this source.boolean
queueAudioBuffer(AudioBuffer audioBuffer)
Queue a single AudioBuffer on this source.boolean
queueAudioBuffers(java.util.Queue<AudioBuffer> audioBuffers)
Queue a list of AudioBuffers on this source.void
setGain(float gain)
Set the gain of this AudioSource objectvoid
setMaximumDistance(float maximumDistance)
Set the current maximum distance setting.void
setOffset(long offset)
Set the offset in which to start playback of this AudioSource.void
setPitch(float pitch)
Set the pitch of this AudioSource objectvoid
setPositionRelative(boolean relative)
Sets the position of this AudioSource object to be relative to the position of the AudioListener object or absolute.void
setReferenceDistance(float referenceDistance)
Set the reference distance of this AudioSource object.void
setRollOffFactor(float rollOffFactor)
Set the roll-off factor of this AudioSource object.void
setVelocity(javax.vecmath.Vector3f vel)
Sets the velocity of this AudioSource objectvoid
stateChanged(int oldState)
Method used to update the current state of the Audio objectboolean
unqueueAudioBuffers()
Remove all processed AudioBuffers from this Source.-
Methods inherited from class jmri.jmrit.audio.AbstractAudioSource
calculateCurrentPosition, calculateFades, calculateLoops, doResetCurrentPosition, doTogglePause, doTogglePlay, fadeIn, fadeOut, getAssignedBuffer, getAssignedBufferName, getCurrentPosition, getDebugString, getFadeGain, getFadeIn, getFadeOut, getFading, getGain, getLastNumLoops, getMaximumDistance, getMaxLoops, getMinLoops, getNumLoops, getOffset, getPitch, getPosition, getQueuedBuffers, getReferenceDistance, getRollOffFactor, getSubType, getVelocity, isAudioAlive, isBound, isLooped, isPositionRelative, isQueued, pause, play, queueBuffer, queueBuffers, resetCurrentPosition, resume, rewind, setAssignedBuffer, setAssignedBuffer, setBound, setFadeIn, setFadeOut, setLooped, setMaxLoops, setMinLoops, setPosition, setPosition, setPosition, setQueued, stop, togglePause, togglePlay, unqueueBuffers
-
Methods inherited from class jmri.implementation.AbstractAudio
dispose, getBeanType, 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, 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
-
JoalAudioSource
public JoalAudioSource(java.lang.String systemName)
Constructor for new JoalAudioSource with system name- Parameters:
systemName
- AudioSource object system name (e.g. IAS1)
-
JoalAudioSource
public JoalAudioSource(java.lang.String systemName, java.lang.String userName)
Constructor for new JoalAudioSource with system name and user name- Parameters:
systemName
- AudioSource object system name (e.g. IAS1)userName
- AudioSource object user name
-
-
Method Detail
-
queueAudioBuffer
public boolean queueAudioBuffer(AudioBuffer audioBuffer)
Queue a single AudioBuffer on this source. (called from DefaultAudioFactory command queue)- Overrides:
queueAudioBuffer
in classAbstractAudioSource
- Parameters:
audioBuffer
- AudioBuffer to queue- Returns:
- True if successfully queued.
-
queueAudioBuffers
public boolean queueAudioBuffers(java.util.Queue<AudioBuffer> audioBuffers)
Queue a list of AudioBuffers on this source. (called from DefaultAudioFactory command queue)- Overrides:
queueAudioBuffers
in classAbstractAudioSource
- Parameters:
audioBuffers
- AudioBuffers to queue- Returns:
- True if successfully queued.
-
unqueueAudioBuffers
public boolean unqueueAudioBuffers()
Remove all processed AudioBuffers from this Source.- Overrides:
unqueueAudioBuffers
in classAbstractAudioSource
- Returns:
- True if successful.
-
numProcessedBuffers
public int numProcessedBuffers()
- Specified by:
numProcessedBuffers
in interfaceAudioSource
- Overrides:
numProcessedBuffers
in classAbstractAudioSource
-
numQueuedBuffers
public int numQueuedBuffers()
Report the number of AudioBuffers queued to this source.- Specified by:
numQueuedBuffers
in interfaceAudioSource
- Overrides:
numQueuedBuffers
in classAbstractAudioSource
- Returns:
- number of queued buffers.
-
bindAudioBuffer
boolean bindAudioBuffer(AudioBuffer audioBuffer)
Description copied from class:AbstractAudioSource
Binds this AudioSource with the specified AudioBuffer.Applies only to sub-types:
- Source
- Specified by:
bindAudioBuffer
in classAbstractAudioSource
- Parameters:
audioBuffer
- The AudioBuffer to bind to this AudioSource- Returns:
- true if successful
-
changePosition
protected void changePosition(javax.vecmath.Vector3f pos)
Description copied from class:AbstractAudioSource
Change the current position of this source.- Specified by:
changePosition
in classAbstractAudioSource
- Parameters:
pos
- new position
-
setPositionRelative
public void setPositionRelative(boolean relative)
Description copied from interface:AudioSource
Sets the position of this AudioSource object to be relative to the position of the AudioListener object or absolute.Applies only to sub-types:
- Source
- Specified by:
setPositionRelative
in interfaceAudioSource
- Overrides:
setPositionRelative
in classAbstractAudioSource
- Parameters:
relative
- position relative or absolute
-
setVelocity
public void setVelocity(javax.vecmath.Vector3f vel)
Description copied from interface:AudioSource
Sets the velocity of this AudioSource objectApplies only to sub-types:
- Listener
- Source
- Specified by:
setVelocity
in interfaceAudioSource
- Overrides:
setVelocity
in classAbstractAudioSource
- Parameters:
vel
- 3d velocity vector
-
setGain
public void setGain(float gain)
Description copied from interface:AudioSource
Set the gain of this AudioSource objectDefault value = 1.0f
Applies only to sub-types:
- Listener
- Source
- Specified by:
setGain
in interfaceAudioSource
- Overrides:
setGain
in classAbstractAudioSource
- Parameters:
gain
- the gain of this AudioSource
-
setPitch
public void setPitch(float pitch)
Description copied from interface:AudioSource
Set the pitch of this AudioSource objectValues are restricted from 0.5f to 2.0f, i.e. half to double
Default value = 1.0f
Applies only to sub-types:
- Source
- Specified by:
setPitch
in interfaceAudioSource
- Overrides:
setPitch
in classAbstractAudioSource
- Parameters:
pitch
- the pitch of this AudioSource
-
setReferenceDistance
public void setReferenceDistance(float referenceDistance)
Description copied from interface:AudioSource
Set the reference distance of this AudioSource object.Default value = 1.0f
The Reference Distance is one of the main parameters you have for controlling the way that sounds attenuate with distance. A Source with Reference Distance set to 5 (meters) will be at maximum volume while it is within 5 metere of the listener, and start to fade out as it moves further away. At 10 meters it will be at half volume, and at 20 meters at a quarter volume, etc ...
Applies only to sub-types:
- Source
- Specified by:
setReferenceDistance
in interfaceAudioSource
- Overrides:
setReferenceDistance
in classAbstractAudioSource
- Parameters:
referenceDistance
- the Reference Distance for this AudioSource
-
setOffset
public void setOffset(long offset)
Description copied from interface:AudioSource
Set the offset in which to start playback of this AudioSource.Default value = 0
Value is clamped between 0 and length of attached AudioBuffer
Applies only to sub-types:
- Source
- Specified by:
setOffset
in interfaceAudioSource
- Overrides:
setOffset
in classAbstractAudioSource
- Parameters:
offset
- the offset in samples marking the point to commence playback
-
setMaximumDistance
public void setMaximumDistance(float maximumDistance)
Description copied from interface:AudioSource
Set the current maximum distance setting.Default value = Audio.MAX_DISTANCE
The maximum distance is that where the volume of the sound would normally be zero.
Applies only to sub-types:
- Source
- Specified by:
setMaximumDistance
in interfaceAudioSource
- Overrides:
setMaximumDistance
in classAbstractAudioSource
- Parameters:
maximumDistance
- maximum distance of this source
-
setRollOffFactor
public void setRollOffFactor(float rollOffFactor)
Description copied from interface:AudioSource
Set the roll-off factor of this AudioSource object.Default value = 1.0f
Applies only to sub-types:
- Source
- Specified by:
setRollOffFactor
in interfaceAudioSource
- Overrides:
setRollOffFactor
in classAbstractAudioSource
- Parameters:
rollOffFactor
- roll-off factor
-
getState
public int getState()
Description copied from interface:NamedBean
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.
- Specified by:
getState
in interfaceNamedBean
- Overrides:
getState
in classAbstractAudio
- Returns:
- the state
-
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 interfaceAudio
- Overrides:
stateChanged
in classAbstractAudioSource
- Parameters:
oldState
- the former state
-
doPlay
protected void doPlay()
Description copied from class:AbstractAudioSource
Play the clip from the beginning. If looped, start looping.- Specified by:
doPlay
in classAbstractAudioSource
-
doStop
protected void doStop()
Description copied from class:AbstractAudioSource
Stop playing the clip and rewind to the beginning.- Specified by:
doStop
in classAbstractAudioSource
-
doPause
protected void doPause()
Description copied from class:AbstractAudioSource
Stop playing the clip but retain the current position.- Specified by:
doPause
in classAbstractAudioSource
-
doResume
protected void doResume()
Description copied from class:AbstractAudioSource
Play the clip from the current position.- Specified by:
doResume
in classAbstractAudioSource
-
doRewind
protected void doRewind()
Description copied from class:AbstractAudioSource
Rewind clip to the beginning.- Specified by:
doRewind
in classAbstractAudioSource
-
doFadeIn
protected void doFadeIn()
Description copied from class:AbstractAudioSource
Fade in then play this AudioSource.- Specified by:
doFadeIn
in classAbstractAudioSource
-
doFadeOut
protected void doFadeOut()
Description copied from class:AbstractAudioSource
Fade out then stop this AudioSource.- Specified by:
doFadeOut
in classAbstractAudioSource
-
cleanup
protected void cleanup()
Description copied from class:AbstractAudio
Abstract method that concrete classes will implement to perform necessary cleanup routines.This method is now included in dispose(). The caller can call dispose() to cleanup and deregister an audio object.
- Specified by:
cleanup
in classAbstractAudio
-
calculateGain
protected void calculateGain()
Description copied from class:AbstractAudioSource
Calculate the gain of this AudioSource based on distance from listener and fade levels.- Specified by:
calculateGain
in classAbstractAudioSource
-
-