Class AbstractAudioSource
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractAudio
-
- jmri.jmrit.audio.AbstractAudioSource
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,Audio
,PropertyChangeProvider
,AudioSource
,NamedBean
- Direct Known Subclasses:
JavaSoundAudioSource
,JoalAudioSource
,NullAudioSource
public abstract class AbstractAudioSource extends AbstractAudio implements AudioSource
Base implementation of the AudioSource 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 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.-
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 AbstractAudioSource(java.lang.String systemName)
Abstract constructor for new AudioSource with system nameAbstractAudioSource(java.lang.String systemName, java.lang.String userName)
Abstract constructor for new AudioSource with system name and user name
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract boolean
bindAudioBuffer(AudioBuffer buffer)
Binds this AudioSource with the specified AudioBuffer.protected void
calculateCurrentPosition()
Calculate current position based on velocity.protected void
calculateFades()
Calculate the fade gains.protected abstract void
calculateGain()
Calculate the gain of this AudioSource based on distance from listener and fade levels.protected void
calculateLoops()
Calculate the number of times to loop playback of this sound.protected abstract void
changePosition(javax.vecmath.Vector3f pos)
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()
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 Objectvoid
fadeOut()
Method to fade out and then stop this AudioSource Object only when it is already playing.AudioBuffer
getAssignedBuffer()
Returns linked AudioBuffer objectjava.lang.String
getAssignedBufferName()
Return system name of linked AudioBuffer objectjavax.vecmath.Vector3f
getCurrentPosition()
Returns the current position of this AudioSource object as a 3-dimensional vector.java.lang.String
getDebugString()
Get debug info about this audio 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 inint
getFadeOut()
Retrieve the length of time in milliseconds to fade this source inprotected int
getFading()
Get the current fading status.float
getGain()
Return the currently stored gain settingint
getLastNumLoops()
Get the last value returned byAudioSource.getNumLoops()
float
getMaximumDistance()
Return the current maximum distance setting.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.long
getOffset()
Return the offset in which to start playback of this AudioSource.float
getPitch()
Return the current pitch settingjavax.vecmath.Vector3f
getPosition()
Returns the position of this AudioSource object as a 3-dimensional vector.java.util.Queue<AudioBuffer>
getQueuedBuffers()
float
getReferenceDistance()
Return the current reference distance settingfloat
getRollOffFactor()
Get the roll-off factor of this AudioSource object.char
getSubType()
An Audio object can represent one of a number of subtypes of object.javax.vecmath.Vector3f
getVelocity()
Returns the velocity of this AudioSource objectboolean
isAudioAlive()
boolean
isBound()
Method to return if this AudioSource has been bound to an AudioBufferboolean
isLooped()
Check if this AudioSource object will loop or not.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.boolean
isQueued()
Method to return if this AudioSource has AudioBuffers queued to itint
numProcessedBuffers()
int
numQueuedBuffers()
void
pause()
Method to pause playing this AudioSource Objectvoid
play()
Method to start playing this AudioSource Objectboolean
queueAudioBuffer(AudioBuffer audioBuffer)
boolean
queueAudioBuffers(java.util.Queue<AudioBuffer> audioBuffers)
boolean
queueBuffer(AudioBuffer audioBuffer)
boolean
queueBuffers(java.util.Queue<AudioBuffer> audioBuffers)
Queues the linked AudioBuffer object to this Source's buffer queuevoid
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 Objectvoid
rewind()
Method to rewind this AudioSource Objectvoid
setAssignedBuffer(java.lang.String bufferSystemName)
Sets the system name of the linked AudioBuffer objectvoid
setAssignedBuffer(AudioBuffer audioBuffer)
Sets the linked AudioBuffer objectprotected void
setBound(boolean bound)
Method to define if this AudioSource has been bound to an AudioBuffer.void
setFadeIn(int fadeInTime)
Set the length of time in milliseconds to fade this source invoid
setFadeOut(int fadeOutTime)
Set the length of time in milliseconds to fade this source invoid
setGain(float gain)
Set the gain of this AudioSource objectvoid
setLooped(boolean loop)
Sets this AudioSource object to loop infinitely or not.void
setMaximumDistance(float maximumDistance)
Set the current maximum distance setting.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
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
setPosition(float x, float y)
Sets the position of this AudioSource object in x and y planes with z plane position fixed at zerovoid
setPosition(float x, float y, float z)
Sets the position of this AudioSource object in x, y and z planesvoid
setPosition(javax.vecmath.Vector3f pos)
Sets the position 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.protected void
setQueued(boolean queued)
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 objectvoid
stop()
Method to stop playing this AudioSource Objectvoid
togglePause()
Method to toggle playback of this AudioSource Object retaining postitionvoid
togglePlay()
Method to toggle playback of this AudioSource Object reseting positionboolean
unqueueAudioBuffers()
boolean
unqueueBuffers()
-
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
-
AbstractAudioSource
public AbstractAudioSource(java.lang.String systemName)
Abstract constructor for new AudioSource with system name- Parameters:
systemName
- AudioSource object system name (e.g. IAS1)
-
AbstractAudioSource
public AbstractAudioSource(java.lang.String systemName, java.lang.String userName)
Abstract constructor for new AudioSource with system name and user name- Parameters:
systemName
- AudioSource object system name (e.g. IAS1)userName
- AudioSource object user name
-
-
Method Detail
-
isAudioAlive
public boolean isAudioAlive()
-
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 interfaceAudio
- Returns:
- subType char
-
queueBuffers
public boolean queueBuffers(java.util.Queue<AudioBuffer> audioBuffers)
Description copied from interface:AudioSource
Queues the linked AudioBuffer object to this Source's buffer queueApplies only to sub-types:
- Source
- Specified by:
queueBuffers
in interfaceAudioSource
- Parameters:
audioBuffers
- the AudioBuffer object to enqueue to this AudioSource- Returns:
- true if successfully queued audioBuffers; false otherwise
-
queueBuffer
public boolean queueBuffer(AudioBuffer audioBuffer)
- Specified by:
queueBuffer
in interfaceAudioSource
-
unqueueBuffers
public boolean unqueueBuffers()
- Specified by:
unqueueBuffers
in interfaceAudioSource
-
getQueuedBuffers
public java.util.Queue<AudioBuffer> getQueuedBuffers()
-
setAssignedBuffer
public void setAssignedBuffer(AudioBuffer audioBuffer)
Description copied from interface:AudioSource
Sets the linked AudioBuffer objectApplies only to sub-types:
- Source
- Specified by:
setAssignedBuffer
in interfaceAudioSource
- Parameters:
audioBuffer
- the AudioBuffer object to bind to this AudioSource
-
setAssignedBuffer
public void setAssignedBuffer(java.lang.String bufferSystemName)
Description copied from interface:AudioSource
Sets the system name of the linked AudioBuffer objectApplies only to sub-types:
- Source
- Specified by:
setAssignedBuffer
in interfaceAudioSource
- Parameters:
bufferSystemName
- the SystemName of the AudioBuffer (i.e. IAB1) to bind to this AudioSource
-
getAssignedBuffer
public AudioBuffer getAssignedBuffer()
Description copied from interface:AudioSource
Returns linked AudioBuffer objectApplies only to sub-types:
- Source
- Specified by:
getAssignedBuffer
in interfaceAudioSource
- Returns:
- AudioBuffer the AudioBuffer object bound to this AudioSource
-
getAssignedBufferName
public java.lang.String getAssignedBufferName()
Description copied from interface:AudioSource
Return system name of linked AudioBuffer objectApplies only to sub-types:
- Source
- Specified by:
getAssignedBufferName
in interfaceAudioSource
- Returns:
- sysName the SystemName of the AudioBuffer bound to this AudioSource
-
setPosition
public void setPosition(javax.vecmath.Vector3f pos)
Description copied from interface:AudioSource
Sets the position of this AudioSource objectApplies only to sub-types:
- Listener
- Source
- Specified by:
setPosition
in interfaceAudioSource
- Parameters:
pos
- 3d position vector
-
setPosition
public void setPosition(float x, float y, float z)
Description copied from interface:AudioSource
Sets the position of this AudioSource object in x, y and z planesApplies only to sub-types:
- Listener
- Source
- Specified by:
setPosition
in interfaceAudioSource
- Parameters:
x
- x-coordinatey
- y-coordinatez
- z-coordinate
-
setPosition
public void setPosition(float x, float y)
Description copied from interface:AudioSource
Sets the position of this AudioSource 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:
setPosition
in interfaceAudioSource
- Parameters:
x
- x-coordinatey
- y-coordinate
-
getPosition
public javax.vecmath.Vector3f getPosition()
Description copied from interface:AudioSource
Returns the position of this AudioSource object as a 3-dimensional vector.Applies only to sub-types:
- Listener
- Source
- Specified by:
getPosition
in interfaceAudioSource
- Returns:
- 3d position vector
-
getCurrentPosition
public javax.vecmath.Vector3f getCurrentPosition()
Description copied from interface:AudioSource
Returns the current position of this AudioSource object as a 3-dimensional vector.Applies only to sub-types:
- Listener
- Source
- Specified by:
getCurrentPosition
in interfaceAudioSource
- Returns:
- 3d position vector
-
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
- Parameters:
relative
- position relative or absolute
-
isPositionRelative
public boolean isPositionRelative()
Description copied from interface:AudioSource
Returns a boolean value that determines if the position of this AudioSource object is relative to the position of the AudioListener object or absolute.Applies only to sub-types:
- Source
- Specified by:
isPositionRelative
in interfaceAudioSource
- Returns:
- boolean position relative
-
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
- Parameters:
vel
- 3d velocity vector
-
getVelocity
public javax.vecmath.Vector3f getVelocity()
Description copied from interface:AudioSource
Returns the velocity of this AudioSource objectApplies only to sub-types:
- Listener
- Source
- Specified by:
getVelocity
in interfaceAudioSource
- Returns:
- 3d velocity vector
-
calculateCurrentPosition
protected void calculateCurrentPosition()
Calculate current position based on velocity.
-
resetCurrentPosition
public void resetCurrentPosition()
Description copied from interface:AudioSource
Method to reset the current position of this AudioSource object to the initial position as defined by setPosition.Applies only to sub-types:
- Listener
- Source
- Specified by:
resetCurrentPosition
in interfaceAudioSource
-
doResetCurrentPosition
protected void doResetCurrentPosition()
Reset the current position.
-
changePosition
protected abstract void changePosition(javax.vecmath.Vector3f pos)
Change the current position of this source.- Parameters:
pos
- new position
-
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
- Parameters:
gain
- the gain of this AudioSource
-
getGain
public float getGain()
Description copied from interface:AudioSource
Return the currently stored gain settingDefault value = 1.0f
Applies only to sub-types:
- Listener
- Source
- Specified by:
getGain
in interfaceAudioSource
- Returns:
- gain setting of this AudioSource
-
calculateGain
protected abstract void calculateGain()
Calculate the gain of this AudioSource based on distance from listener and fade levels.
-
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
- Parameters:
pitch
- the pitch of this AudioSource
-
getPitch
public float getPitch()
Description copied from interface:AudioSource
Return the current pitch settingValues 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:
getPitch
in interfaceAudioSource
- Returns:
- 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
- Parameters:
referenceDistance
- the Reference Distance for this AudioSource
-
getReferenceDistance
public float getReferenceDistance()
Description copied from interface:AudioSource
Return the current reference distance settingDefault value = 1.0f
Applies only to sub-types:
- Source
- Specified by:
getReferenceDistance
in interfaceAudioSource
- Returns:
- Reference Distance of 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
- Parameters:
offset
- the offset in samples marking the point to commence playback
-
getOffset
public long getOffset()
Description copied from interface:AudioSource
Return the offset in which to start playback of this AudioSource.Default value = 0
Applies only to sub-types:
- Source
- Specified by:
getOffset
in interfaceAudioSource
- Returns:
- 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
- Parameters:
maximumDistance
- maximum distance of this source
-
getMaximumDistance
public float getMaximumDistance()
Description copied from interface:AudioSource
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.
Applies only to sub-types:
- Source
- Specified by:
getMaximumDistance
in interfaceAudioSource
- Returns:
- the maximum distance
-
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
- Parameters:
rollOffFactor
- roll-off factor
-
getRollOffFactor
public float getRollOffFactor()
Description copied from interface:AudioSource
Get the roll-off factor of this AudioSource object.Default value = 1.0f
Applies only to sub-types:
- Source
- Specified by:
getRollOffFactor
in interfaceAudioSource
- Returns:
- the roll-off factor
-
setLooped
public void setLooped(boolean loop)
Description copied from interface:AudioSource
Sets this AudioSource object to loop infinitely or not.When loop == false, sets the min and max number of loops to zero.
Applies only to sub-types:
- Source
- Specified by:
setLooped
in interfaceAudioSource
- Parameters:
loop
- infinite loop setting
-
isLooped
public boolean isLooped()
Description copied from interface:AudioSource
Check if this AudioSource object will loop or not.Applies only to sub-types:
- Source
- Specified by:
isLooped
in interfaceAudioSource
- Returns:
- boolean loop
-
setMinLoops
public void setMinLoops(int loops)
Description copied from interface:AudioSource
The minimum number of times that this AudioSource should loop.When 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:
- Source
- Specified by:
setMinLoops
in interfaceAudioSource
- Parameters:
loops
- minimum number of loops
-
getMinLoops
public int getMinLoops()
Description copied from interface:AudioSource
Returns the minimum number of times that this AudioSource will loop, or LOOP_CONTINUOUS for infinite looping.Default value = 0
Applies only to sub-types:
- Source
- Specified by:
getMinLoops
in interfaceAudioSource
- Returns:
- number of loops
-
setMaxLoops
public void setMaxLoops(int loops)
Description copied from interface:AudioSource
The maximum number of times that this AudioSource should loop.When 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:
- Source
- Specified by:
setMaxLoops
in interfaceAudioSource
- Parameters:
loops
- maximum number of loops
-
calculateLoops
protected void calculateLoops()
Calculate the number of times to loop playback of this sound.
-
getMaxLoops
public int getMaxLoops()
Description copied from interface:AudioSource
Returns the maximum number of times that this AudioSource will loop, or LOOP_CONTINUOUS for infinite looping.Default value = 0
Applies only to sub-types:
- Source
- Specified by:
getMaxLoops
in interfaceAudioSource
- Returns:
- maximum number of loops
-
getNumLoops
public int getNumLoops()
Description copied from interface:AudioSource
The number of times that this AudioSource should loop, or LOOP_CONTINUOUS for infinite looping.When 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 <= maximum
Default value = 0Applies only to sub-types:
- Source
- Specified by:
getNumLoops
in interfaceAudioSource
- Returns:
- number of loops
-
getLastNumLoops
public int getLastNumLoops()
Description copied from interface:AudioSource
Get the last value returned byAudioSource.getNumLoops()
- Specified by:
getLastNumLoops
in interfaceAudioSource
- Returns:
- the number of loops
-
setFadeIn
public void setFadeIn(int fadeInTime)
Description copied from interface:AudioSource
Set the length of time in milliseconds to fade this source inDefault value = 1000
Applies only to sub-types:
- Source
- Specified by:
setFadeIn
in interfaceAudioSource
- Parameters:
fadeInTime
- fade-in time in milliseconds
-
getFadeIn
public int getFadeIn()
Description copied from interface:AudioSource
Retrieve the length of time in milliseconds to fade this source inDefault value = 1000
Applies only to sub-types:
- Source
- Specified by:
getFadeIn
in interfaceAudioSource
- Returns:
- fade-in time in milliseconds
-
setFadeOut
public void setFadeOut(int fadeOutTime)
Description copied from interface:AudioSource
Set the length of time in milliseconds to fade this source inDefault value = 1000
Applies only to sub-types:
- Source
- Specified by:
setFadeOut
in interfaceAudioSource
- Parameters:
fadeOutTime
- fade-out time in milliseconds
-
getFadeOut
public int getFadeOut()
Description copied from interface:AudioSource
Retrieve the length of time in milliseconds to fade this source inDefault value = 1000
Applies only to sub-types:
- Source
- Specified by:
getFadeOut
in interfaceAudioSource
- Returns:
- fade-in time in milliseconds
-
getFadeGain
protected float getFadeGain()
Used to return the current calculated fade gain for this AudioSource.- Returns:
- current fade gain
-
calculateFades
protected void calculateFades()
Calculate the fade gains.
-
queueAudioBuffers
public boolean queueAudioBuffers(java.util.Queue<AudioBuffer> audioBuffers)
-
queueAudioBuffer
public boolean queueAudioBuffer(AudioBuffer audioBuffer)
-
unqueueAudioBuffers
public boolean unqueueAudioBuffers()
-
numQueuedBuffers
public int numQueuedBuffers()
- Specified by:
numQueuedBuffers
in interfaceAudioSource
-
numProcessedBuffers
public int numProcessedBuffers()
- Specified by:
numProcessedBuffers
in interfaceAudioSource
-
bindAudioBuffer
abstract boolean bindAudioBuffer(AudioBuffer buffer)
Binds this AudioSource with the specified AudioBuffer.Applies only to sub-types:
- Source
- Parameters:
buffer
- The AudioBuffer to bind to this AudioSource- Returns:
- true if successful
-
setBound
protected void setBound(boolean bound)
Method to define if this AudioSource has been bound to an AudioBuffer.- Parameters:
bound
- True if bound to an AudioBufferr
-
setQueued
protected void setQueued(boolean queued)
-
isBound
public boolean isBound()
Description copied from interface:AudioSource
Method to return if this AudioSource has been bound to an AudioBufferApplies only to sub-types:
- Source
- Specified by:
isBound
in interfaceAudioSource
- Returns:
- True if bound to an AudioBuffer
-
isQueued
public boolean isQueued()
Description copied from interface:AudioSource
Method to return if this AudioSource has AudioBuffers queued to itApplies only to sub-types:
- Source
- Specified by:
isQueued
in interfaceAudioSource
- Returns:
- True if AudioBuffers are queued.
-
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
- Parameters:
oldState
- the former state
-
play
public void play()
Description copied from interface:AudioSource
Method to start playing this AudioSource ObjectIf this AudioSource is already playing, this command is ignored.
Applies only to sub-types:
- Source
- Specified by:
play
in interfaceAudioSource
-
doPlay
protected abstract void doPlay()
Play the clip from the beginning. If looped, start looping.
-
stop
public void stop()
Description copied from interface:AudioSource
Method to stop playing this AudioSource ObjectApplies only to sub-types:
- Source
- Specified by:
stop
in interfaceAudioSource
-
doStop
protected abstract void doStop()
Stop playing the clip and rewind to the beginning.
-
togglePlay
public void togglePlay()
Description copied from interface:AudioSource
Method to toggle playback of this AudioSource Object reseting positionApplies only to sub-types:
- Source
- Specified by:
togglePlay
in interfaceAudioSource
-
doTogglePlay
protected void doTogglePlay()
Toggle the current playing status. Will always start at/return to the beginning of the sample.
-
pause
public void pause()
Description copied from interface:AudioSource
Method to pause playing this AudioSource ObjectApplies only to sub-types:
- Source
- Specified by:
pause
in interfaceAudioSource
-
doPause
protected abstract void doPause()
Stop playing the clip but retain the current position.
-
resume
public void resume()
Description copied from interface:AudioSource
Method to resume playing this AudioSource ObjectApplies only to sub-types:
- Source
- Specified by:
resume
in interfaceAudioSource
-
doResume
protected abstract void doResume()
Play the clip from the current position.
-
togglePause
public void togglePause()
Description copied from interface:AudioSource
Method to toggle playback of this AudioSource Object retaining postitionApplies only to sub-types:
- Source
- Specified by:
togglePause
in interfaceAudioSource
-
doTogglePause
protected void doTogglePause()
Toggle the current playing status. Will retain the playback position of the sample.
-
rewind
public void rewind()
Description copied from interface:AudioSource
Method to rewind this AudioSource ObjectApplies only to sub-types:
- Source
- Specified by:
rewind
in interfaceAudioSource
-
doRewind
protected abstract void doRewind()
Rewind clip to the beginning.
-
fadeIn
public void fadeIn()
Description copied from interface:AudioSource
Method to fade in and then play this AudioSource ObjectApplies only to sub-types:
- Source
- Specified by:
fadeIn
in interfaceAudioSource
-
doFadeIn
protected abstract void doFadeIn()
Fade in then play this AudioSource.
-
fadeOut
public void fadeOut()
Description copied from interface:AudioSource
Method to fade out and then stop this AudioSource Object only when it is already playing.If not playing, command is ignored.
Applies only to sub-types:
- Source
- Specified by:
fadeOut
in interfaceAudioSource
-
doFadeOut
protected abstract void doFadeOut()
Fade out then stop this AudioSource.
-
getFading
protected int getFading()
Get the current fading status.- Returns:
- fading status
-
getDebugString
@Nonnull public java.lang.String getDebugString()
Description copied from interface:AudioSource
Get debug info about this audio source. AbstractAudioSource overrides this to get more debug info. It was previously the method toString().- Specified by:
getDebugString
in interfaceAudioSource
- Returns:
- a string with debug info or the result of the method toString()
-
-