|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.implementation.AbstractNamedBean
jmri.implementation.AbstractAudio
jmri.jmrit.audio.AbstractAudioSource
public abstract class AbstractAudioSource
Base implementation of the AudioSource class.
Specific implementations will extend this base class.
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 | |
|---|---|
protected static class |
AbstractAudioSource.AudioSourceFadeThread
An internal class used to create a new thread to monitor and maintain fade in and fade out levels. |
protected static class |
AbstractAudioSource.AudioSourceMoveThread
An internal class used to create a new thread to monitor and maintain current source position with respect to velocity. |
| Field Summary |
|---|
| Fields inherited from class jmri.implementation.AbstractNamedBean |
|---|
mSystemName, mUserName |
| Fields inherited from interface jmri.jmrit.audio.AudioSource |
|---|
LOOP_CONTINUOUS, LOOP_NONE |
| 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_RESET_POSITION, CMD_RESUME, CMD_REWIND, CMD_STOP, 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 |
|---|
INCONSISTENT, UNKNOWN |
| Constructor Summary | |
|---|---|
AbstractAudioSource(String systemName)
Abstract constructor for new AudioSource with system name |
|
AbstractAudioSource(String systemName,
String userName)
Abstract constructor for new AudioSource with system name and user name |
|
| Method Summary | |
|---|---|
protected void |
calculateCurrentPosition()
Method to calculate current position based on velocity |
protected void |
calculateFades()
Method used to calculate the fade gains |
protected abstract void |
calculateGain()
Method to calculate the gain of this AudioSource based on distance from listener and fade levels |
protected void |
calculateLoops()
Method to calculate the number of times to loop playback of this sound |
protected abstract void |
changePosition(Vector3f pos)
Method to change the current position of this source |
protected abstract void |
doFadeIn()
Fade in then play this AudioSource |
protected abstract void |
doFadeOut()
Fade out then stop this AudioSource |
protected abstract void |
doPause()
Stop playing the clip but retain the current position |
protected abstract void |
doPlay()
Play the clip from the beginning. |
protected void |
doResetCurrentPosition()
Method to reset the current position |
protected abstract void |
doResume()
Play the clip from the current position |
protected abstract void |
doRewind()
Rewind clip to the beginning |
protected abstract void |
doStop()
Stop playing the clip and rewind to the beginning |
protected void |
doTogglePause()
Toggle the current playing status. |
protected void |
doTogglePlay()
Toggle the current playing status. |
void |
fadeIn()
Method to fade in and then play this AudioSource Object Applies only to sub-types: Source |
void |
fadeOut()
Method to fade out and then stop this AudioSource Object only when it is already playing. |
AudioBuffer |
getAssignedBuffer()
Returns linked AudioBuffer object Applies only to sub-types: Source |
String |
getAssignedBufferName()
Return system name of linked AudioBuffer object Applies only to sub-types: Source |
Vector3f |
getCurrentPosition()
Returns the current position of this AudioSource object as a 3-dimensional vector. |
float |
getDopplerFactor()
Retrieve the doppler factor of this source Default value = 1.0f Only calculated for JoalAudioSources Applies only to sub-types: Source |
protected float |
getFadeGain()
Used to return the current calculated fade gain for this AudioSource |
int |
getFadeIn()
Retrieve the length of time in milliseconds to fade this source in Default value = 1000 Applies only to sub-types: Source |
int |
getFadeOut()
Retrieve the length of time in milliseconds to fade this source in Default value = 1000 Applies only to sub-types: Source |
protected int |
getFading()
Return the current fading status |
float |
getGain()
Return the currently stored gain setting Default value = 1.0f Applies only to sub-types: Listener Source |
float |
getMaximumDistance()
Return 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. |
int |
getMaxLoops()
Returns the maximum number of times that this AudioSource will loop, or LOOP_CONTINUOUS for infinite looping. |
int |
getMinLoops()
Returns the minimum number of times that this AudioSource will loop, or LOOP_CONTINUOUS for infinite looping. |
int |
getNumLoops()
The number of times that this AudioSource should loop, or LOOP_CONTINUOUS for infinite looping. |
float |
getPitch()
Return the current pitch setting Values are restricted from 0.5f to 2.0f, i.e. half to double Default value = 1.0f Applies only to sub-types: Source |
Vector3f |
getPosition()
Returns the position of this AudioSource object as a 3-dimensional vector. |
float |
getReferenceDistance()
Return the current reference distance setting Default value = 1.0f Applies only to sub-types: Source |
float |
getRollOffFactor()
Return the roll-off factor of this AudioSource object Default value = 1.0f Applies only to sub-types: Source |
char |
getSubType()
An Audio object can represent one of a number of subtypes of object. |
Vector3f |
getVelocity()
Returns the velocity of this AudioSource object Applies only to sub-types: Listener Source |
boolean |
isBound()
Method to return if this AudioSource has been bound to an AudioBuffer Applies only to sub-types: Source |
boolean |
isLooped()
Returns a boolean if this AudioSource object will loop or not Applies only to sub-types: Source |
boolean |
isPositionRelative()
Returns a boolean value that determines if the position of this AudioSource object is relative to the position of the AudioListener object or absolute. |
void |
pause()
Method to pause playing this AudioSource Object Applies only to sub-types: Source |
void |
play()
Method to start playing this AudioSource Object If this AudioSource is already playing, this command is ignored. |
void |
resetCurrentPosition()
Method to reset the current position of this AudioSource object to the initial position as defined by setPosition. |
void |
resume()
Method to resume playing this AudioSource Object Applies only to sub-types: Source |
void |
rewind()
Method to rewind this AudioSource Object Applies only to sub-types: Source |
void |
setAssignedBuffer(AudioBuffer audioBuffer)
Sets the linked AudioBuffer object Applies only to sub-types: Source |
void |
setAssignedBuffer(String bufferSystemName)
Sets the system name of the linked AudioBuffer object Applies only to sub-types: Source |
protected void |
setBound(boolean bound)
Method to define if this AudioSource has been bound to an AudioBuffer |
void |
setDopplerFactor(float dopplerFactor)
Set the doppler factor of this source Default value = 1.0f Only calculated for JoalAudioSources Applies only to sub-types: Source |
void |
setFadeIn(int fadeInTime)
Set the length of time in milliseconds to fade this source in Default value = 1000 Applies only to sub-types: Source |
void |
setFadeOut(int fadeOutTime)
Set the length of time in milliseconds to fade this source in Default value = 1000 Applies only to sub-types: Source |
void |
setGain(float gain)
Set the gain of this AudioSource object Default value = 1.0f Applies only to sub-types: Listener Source |
void |
setLooped(boolean loop)
Sets this AudioSource object to loop infinitely or not. |
void |
setMaximumDistance(float maximumDistance)
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. |
void |
setMaxLoops(int loops)
The maximum number of times that this AudioSource should loop. |
void |
setMinLoops(int loops)
The minimum number of times that this AudioSource should loop. |
void |
setPitch(float pitch)
Set the pitch of this AudioSource object Values are restricted from 0.5f to 2.0f, i.e. half to double Default value = 1.0f Applies only to sub-types: Source |
void |
setPosition(float x,
float y)
Sets the position of this AudioSource 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 |
void |
setPosition(float x,
float y,
float z)
Sets the position of this AudioSource object in x, y and z planes Applies only to sub-types: Listener Source |
void |
setPosition(Vector3f pos)
Sets the position of this AudioSource object Applies only to sub-types: Listener Source |
void |
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 Default value = 1.0f Applies only to sub-types: Source |
void |
setVelocity(Vector3f vel)
Sets the velocity of this AudioSource object Applies only to sub-types: Listener Source |
void |
stateChanged(int oldState)
Method used to update the current state of the Audio object |
void |
stop()
Method to stop playing this AudioSource Object Applies only to sub-types: Source |
void |
togglePause()
Method to toggle playback of this AudioSource Object retaining postition Applies only to sub-types: Source |
void |
togglePlay()
Method to toggle playback of this AudioSource Object reseting position Applies only to sub-types: Source |
String |
toString()
|
| Methods inherited from class jmri.implementation.AbstractAudio |
|---|
cleanUp, getState, roundDecimal, roundDecimal, setState |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractAudioSource(String systemName)
systemName - AudioSource object system name (e.g. IAS1)
public AbstractAudioSource(String systemName,
String userName)
systemName - AudioSource object system name (e.g. IAS1)userName - AudioSource object user name| Method Detail |
|---|
public char getSubType()
AudioThis method enables us to determine which of those subtypes this particular instance is and be able to process accordingly.
Current supported subtypes are:
getSubType in interface Audiopublic void setAssignedBuffer(AudioBuffer audioBuffer)
AudioSourceApplies only to sub-types:
setAssignedBuffer in interface AudioSourceaudioBuffer - the AudioBuffer object to bind to this AudioSourcepublic void setAssignedBuffer(String bufferSystemName)
AudioSourceApplies only to sub-types:
setAssignedBuffer in interface AudioSourcebufferSystemName - the SystemName of the AudioBuffer (i.e. IAB1) to bind
to this AudioSourcepublic AudioBuffer getAssignedBuffer()
AudioSourceApplies only to sub-types:
getAssignedBuffer in interface AudioSourcepublic String getAssignedBufferName()
AudioSourceApplies only to sub-types:
getAssignedBufferName in interface AudioSourcepublic void setPosition(Vector3f pos)
AudioSourceApplies only to sub-types:
setPosition in interface AudioSourcepos - 3d position vector
public void setPosition(float x,
float y,
float z)
AudioSourceApplies only to sub-types:
setPosition in interface AudioSourcex - x-coordinatey - y-coordinatez - z-coordinate
public void setPosition(float x,
float y)
AudioSourceEquivalent to setPosition(x, y, 0.0f)
Applies only to sub-types:
setPosition in interface AudioSourcex - x-coordinatey - y-coordinatepublic Vector3f getPosition()
AudioSourceApplies only to sub-types:
getPosition in interface AudioSourcepublic Vector3f getCurrentPosition()
AudioSourceApplies only to sub-types:
getCurrentPosition in interface AudioSourcepublic void setPositionRelative(boolean relative)
AudioSourceApplies only to sub-types:
setPositionRelative in interface AudioSourcerelative - position relative or absolutepublic boolean isPositionRelative()
AudioSourceApplies only to sub-types:
isPositionRelative in interface AudioSourcepublic void setVelocity(Vector3f vel)
AudioSourceApplies only to sub-types:
setVelocity in interface AudioSourcevel - 3d velocity vectorpublic Vector3f getVelocity()
AudioSourceApplies only to sub-types:
getVelocity in interface AudioSourceprotected void calculateCurrentPosition()
public void resetCurrentPosition()
AudioSourceApplies only to sub-types:
resetCurrentPosition in interface AudioSourceprotected void doResetCurrentPosition()
protected abstract void changePosition(Vector3f pos)
pos - new positionpublic void setGain(float gain)
AudioSourceDefault value = 1.0f
Applies only to sub-types:
setGain in interface AudioSourcegain - the gain of this AudioSourcepublic float getGain()
AudioSourceDefault value = 1.0f
Applies only to sub-types:
getGain in interface AudioSourceprotected abstract void calculateGain()
public void setPitch(float pitch)
AudioSourceValues are restricted from 0.5f to 2.0f, i.e. half to double
Default value = 1.0f
Applies only to sub-types:
setPitch in interface AudioSourcepitch - the pitch of this AudioSourcepublic float getPitch()
AudioSourceValues are restricted from 0.5f to 2.0f, i.e. half to double
Default value = 1.0f
Applies only to sub-types:
getPitch in interface AudioSourcepublic void setReferenceDistance(float referenceDistance)
AudioSourceDefault value = 1.0f
The Reference Distance is one of the main parameters you have for controlling the way that sounds attenutate 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:
setReferenceDistance in interface AudioSourcereferenceDistance - the Reference Distance for this AudioSourcepublic float getReferenceDistance()
AudioSourceDefault value = 1.0f
Applies only to sub-types:
getReferenceDistance in interface AudioSourcepublic void setMaximumDistance(float maximumDistance)
AudioSourceDefault value = Audio.MAX_DISTANCE
The maximum distance is that where the volume of the sound would normally be zero.
Applies only to sub-types:
setMaximumDistance in interface AudioSourcemaximumDistance - maximum distance of this sourcepublic float getMaximumDistance()
AudioSourceDefault value = Audio.MAX_DISTANCE
The maximum distance is that where the volume of the sound would normally be zero.
Applies only to sub-types:
getMaximumDistance in interface AudioSourcepublic void setRollOffFactor(float rollOffFactor)
AudioSourceDefault value = 1.0f
Applies only to sub-types:
setRollOffFactor in interface AudioSourcerollOffFactor - roll-off factorpublic float getRollOffFactor()
AudioSourceDefault value = 1.0f
Applies only to sub-types:
getRollOffFactor in interface AudioSourcepublic void setLooped(boolean loop)
AudioSourceWhen loop == false, sets the min and max number of loops to zero.
Applies only to sub-types:
setLooped in interface AudioSourceloop - infinite loop settingpublic boolean isLooped()
AudioSourceApplies only to sub-types:
isLooped in interface AudioSourcepublic void setMinLoops(int loops)
AudioSourceWhen set to 1, the sound will loop once (i.e. play through twice).
When set to LOOP_CONTINUOUS, determines that this AudioSource object should loop indefinitely until explicitly stopped.
Default value = 0
Applies only to sub-types:
setMinLoops in interface AudioSourceloops - minimum number of loopspublic int getMinLoops()
AudioSourceDefault value = 0
Applies only to sub-types:
getMinLoops in interface AudioSourcepublic void setMaxLoops(int loops)
AudioSourceWhen set to 1, the sound will loop once (i.e. play through twice).
When set to LOOP_CONTINUOUS, determines that this AudioSource object should loop indefinitely until explicitly stopped.
Default value = 0
Applies only to sub-types:
setMaxLoops in interface AudioSourceloops - maximum number of loopsprotected void calculateLoops()
public int getMaxLoops()
AudioSourceDefault value = 0
Applies only to sub-types:
getMaxLoops in interface AudioSourcepublic int getNumLoops()
AudioSourceWhen the minimum and maximum number of loops are different, each call to this method will return a different random number that lies between the two settings:
minimum <= number of loops <= maximumDefault value = 0
Applies only to sub-types:
getNumLoops in interface AudioSourcepublic void setFadeIn(int fadeInTime)
AudioSourceDefault value = 1000
Applies only to sub-types:
setFadeIn in interface AudioSourcefadeInTime - fade-in time in millisecondspublic int getFadeIn()
AudioSourceDefault value = 1000
Applies only to sub-types:
getFadeIn in interface AudioSourcepublic void setFadeOut(int fadeOutTime)
AudioSourceDefault value = 1000
Applies only to sub-types:
setFadeOut in interface AudioSourcefadeOutTime - fade-out time in millisecondspublic int getFadeOut()
AudioSourceDefault value = 1000
Applies only to sub-types:
getFadeOut in interface AudioSourcepublic void setDopplerFactor(float dopplerFactor)
AudioSourceDefault value = 1.0f
Only calculated for JoalAudioSources
Applies only to sub-types:
setDopplerFactor in interface AudioSourcedopplerFactor - factor to apply in doppler calculationspublic float getDopplerFactor()
AudioSourceDefault value = 1.0f
Only calculated for JoalAudioSources
Applies only to sub-types:
getDopplerFactor in interface AudioSourceprotected float getFadeGain()
protected void calculateFades()
protected void setBound(boolean bound)
bound - True if bound to an AudioBufferrpublic boolean isBound()
AudioSourceApplies only to sub-types:
isBound in interface AudioSourcepublic void stateChanged(int oldState)
Audio
stateChanged in interface Audiopublic void play()
AudioSourceIf this AudioSource is already playing, this command is ignored.
Applies only to sub-types:
play in interface AudioSourceprotected abstract void doPlay()
public void stop()
AudioSourceApplies only to sub-types:
stop in interface AudioSourceprotected abstract void doStop()
public void togglePlay()
AudioSourceApplies only to sub-types:
togglePlay in interface AudioSourceprotected void doTogglePlay()
public void pause()
AudioSourceApplies only to sub-types:
pause in interface AudioSourceprotected abstract void doPause()
public void resume()
AudioSourceApplies only to sub-types:
resume in interface AudioSourceprotected abstract void doResume()
public void togglePause()
AudioSourceApplies only to sub-types:
togglePause in interface AudioSourceprotected void doTogglePause()
public void rewind()
AudioSourceApplies only to sub-types:
rewind in interface AudioSourceprotected abstract void doRewind()
public void fadeIn()
AudioSourceApplies only to sub-types:
fadeIn in interface AudioSourceprotected abstract void doFadeIn()
public void fadeOut()
AudioSourceIf not playing, command is ignored.
Applies only to sub-types:
fadeOut in interface AudioSourceprotected abstract void doFadeOut()
protected int getFading()
public String toString()
toString in class AbstractAudio
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||