Class JavaSoundAudioSource
- All Implemented Interfaces:
Comparable<NamedBean>,Audio,PropertyChangeProvider,AudioSource,NamedBean
For now, no system-specific implementations are foreseen - this will remain internal-only
For more information about the JavaSound API, visit http://java.sun.com/products/java-media/sound/
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.AudioSourceMoveThreadNested 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, registerFields 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, UPFields inherited from interface jmri.jmrit.audio.AudioSource
LOOP_CONTINUOUS, LOOP_NONEFields 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
ConstructorsConstructorDescriptionJavaSoundAudioSource(String systemName) Constructor for new JavaSoundAudioSource with system nameJavaSoundAudioSource(String systemName, String userName) Constructor for new JavaSoundAudioSource with system name and user name -
Method Summary
Modifier and TypeMethodDescription(package private) booleanbindAudioBuffer(AudioBuffer audioBuffer) Binds this AudioSource with the specified AudioBuffer.protected voidCalculate the gain of this AudioSource based on distance from listener and fade levels.protected voidCalculate the panning of this Source between fully left (-1.0f) and fully right (1.0f)protected voidInternal method used to calculate the pitch.protected voidchangePosition(javax.vecmath.Vector3f pos) Change the current position of this source.protected voidcleanup()Abstract method that concrete classes will implement to perform necessary cleanup routines.protected voiddoFadeIn()Fade in then play this AudioSource.protected voidFade out then stop this AudioSource.protected voiddoPause()Stop playing the clip but retain the current position.protected voiddoPlay()Play the clip from the beginning.protected voiddoResume()Play the clip from the current position.protected voiddoRewind()Rewind clip to the beginning.protected voiddoStop()Stop playing the clip and rewind to the beginning.intgetState()Provide generic access to internal state.voidsetGain(float gain) Set the gain of this AudioSource objectvoidsetOffset(long offset) Set the offset in which to start playback of this AudioSource.voidsetPitch(float pitch) Set the pitch of this AudioSource objectvoidsetReferenceDistance(float referenceDistance) Set the reference distance of this AudioSource object.voidstateChanged(int oldState) Method used to update the current state of the Audio objectMethods inherited from class jmri.jmrit.audio.AbstractAudioSource
attachSourcesToEffects, calculateCurrentPosition, calculateFades, calculateLoops, detachSourcesToEffects, 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, numProcessedBuffers, numQueuedBuffers, pause, play, queueAudioBuffer, queueAudioBuffers, queueBuffer, queueBuffers, resetCurrentPosition, resume, rewind, setAssignedBuffer, setAssignedBuffer, setBound, setFadeIn, setFadeOut, setLooped, setMaximumDistance, setMaxLoops, setMinLoops, setPosition, setPosition, setPosition, setPositionRelative, setQueued, setRollOffFactor, setVelocity, stop, togglePause, togglePlay, unqueueAudioBuffers, unqueueBuffersMethods inherited from class jmri.implementation.AbstractAudio
dispose, getBeanType, getUsageReport, roundDecimal, roundDecimal, setStateMethods 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, vetoableChangeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setState, setUserName, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
JavaSoundAudioSource
Constructor for new JavaSoundAudioSource with system name- Parameters:
systemName- AudioSource object system name (e.g. IAS1)
-
JavaSoundAudioSource
Constructor for new JavaSoundAudioSource with system name and user name- Parameters:
systemName- AudioSource object system name (e.g. IAS1)userName- AudioSource object user name
-
-
Method Details
-
bindAudioBuffer
Description copied from class:AbstractAudioSourceBinds this AudioSource with the specified AudioBuffer.Applies only to sub-types:
- Source
- Specified by:
bindAudioBufferin classAbstractAudioSource- Parameters:
audioBuffer- The AudioBuffer to bind to this AudioSource- Returns:
- true if successful
-
changePosition
Description copied from class:AbstractAudioSourceChange the current position of this source.- Specified by:
changePositionin classAbstractAudioSource- Parameters:
pos- new position
-
setGain
Description copied from interface:AudioSourceSet the gain of this AudioSource objectDefault value = 1.0f
Applies only to sub-types:
- Listener
- Source
- Specified by:
setGainin interfaceAudioSource- Overrides:
setGainin classAbstractAudioSource- Parameters:
gain- the gain of this AudioSource
-
setPitch
Description copied from interface:AudioSourceSet 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:
setPitchin interfaceAudioSource- Overrides:
setPitchin classAbstractAudioSource- Parameters:
pitch- the pitch of this AudioSource
-
setReferenceDistance
Description copied from interface:AudioSourceSet 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:
setReferenceDistancein interfaceAudioSource- Overrides:
setReferenceDistancein classAbstractAudioSource- Parameters:
referenceDistance- the Reference Distance for this AudioSource
-
setOffset
Description copied from interface:AudioSourceSet 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:
setOffsetin interfaceAudioSource- Overrides:
setOffsetin classAbstractAudioSource- Parameters:
offset- the offset in samples marking the point to commence playback
-
getState
Description copied from interface:NamedBeanProvide 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:
getStatein interfaceNamedBean- Overrides:
getStatein classAbstractAudio- Returns:
- the state
-
stateChanged
Description copied from interface:AudioMethod used to update the current state of the Audio object- Specified by:
stateChangedin interfaceAudio- Overrides:
stateChangedin classAbstractAudioSource- Parameters:
oldState- the former state
-
doPlay
Description copied from class:AbstractAudioSourcePlay the clip from the beginning. If looped, start looping.- Specified by:
doPlayin classAbstractAudioSource
-
doStop
Description copied from class:AbstractAudioSourceStop playing the clip and rewind to the beginning.- Specified by:
doStopin classAbstractAudioSource
-
doPause
Description copied from class:AbstractAudioSourceStop playing the clip but retain the current position.- Specified by:
doPausein classAbstractAudioSource
-
doResume
Description copied from class:AbstractAudioSourcePlay the clip from the current position.- Specified by:
doResumein classAbstractAudioSource
-
doRewind
Description copied from class:AbstractAudioSourceRewind clip to the beginning.- Specified by:
doRewindin classAbstractAudioSource
-
doFadeIn
Description copied from class:AbstractAudioSourceFade in then play this AudioSource.- Specified by:
doFadeInin classAbstractAudioSource
-
doFadeOut
Description copied from class:AbstractAudioSourceFade out then stop this AudioSource.- Specified by:
doFadeOutin classAbstractAudioSource
-
cleanup
Description copied from class:AbstractAudioAbstract 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:
cleanupin classAbstractAudio
-
calculatePan
Calculate the panning of this Source between fully left (-1.0f) and fully right (1.0f)Calculated internally from the relative positions of this source and the listener.
-
calculateGain
Description copied from class:AbstractAudioSourceCalculate the gain of this AudioSource based on distance from listener and fade levels.- Specified by:
calculateGainin classAbstractAudioSource
-
calculatePitch
Internal method used to calculate the pitch.
-