public abstract class Sound extends Leaf
Sound Data
1) querying the sound's duration (Sound.DURATION_UNKNOWN will be returned),
2) looping over a range of the streaming data; and
3) restart a previously played portion of the data.
Depending on the implementation of the AudioDevice used, streamed, non- cached data may not be fully spatialized.
Initial Gain
Loop
A sound can be looped a specified number of times after it is activated before it is completed. The loop count value explicitly sets the number of times the sound is looped. Any non-negative number is a valid value. A value of zero denotes that the looped section is not repeated, but is played only once. A value of -1 denotes that the loop is repeated indefinitely.
Changing loop count of a sound after the sound has been started will not dynamically affect the loop count currently used by the sound playing. The new loop count will be used the next time the sound is enabled.
Release Flag
Continuous Flag
Enable Sound
Setting the enable flag to true during construction acts as a request to start the sound playing "as soon as it can" be started. This could be close to immediately in limited cases, but several conditions, detailed below, must be met for a sound to be ready to be played.
Mute Sound
Pause Sound
Setting the enable flag to true during construction acts as a request to start the sound playing "as soon as it can" be started. This could be close to immediately in limited cases, but several conditions, detailed below, must be met for a sound to be ready to be played.
Scheduling Bounds
Scheduling Bounding Leaf
Prioritize Sound
Sounds with a lower priority than sound that can not be played due to lack of channels will be played. For example, assume we have eight channels available for playing sounds. After ordering four sounds, we begin playing them in order, checking if the number of channels required to play a given sound are actually available before the sound is played. Furthermore, say the first sound needs three channels to play, the second sound needs four channels, the third sound needs three channels and the fourth sound needs only one channel. The first and second sounds can be started because they require seven of the eight available channels. The third sound can not be audibly started because it requires three channels and only one is still available. Consequently, the third sound starts playing 'silently.' The fourth sound can and will be started since it only requires one channel. The third sound will be made audible when three channels become available (i.e., when the first or second sound finishes playing).
Sounds given the same priority are ordered randomly. If the application wants a specific ordering, it must assign unique priorities to each sound.
Methods to determine what audio output resources are required for playing a Sound node on a particular AudioDevice and to determine the currently available audio output resources are described in the AudioDevice class.
Duration
Number of Channels used on Audio Device to Play Sound
Preparing a Sound to be Played
1) the Sound node has non-null sound data associated with it
2) the Sound node is live
3) there is an active View in the Universe and
4) there is an initialized AudioDevice associated with the
PhysicalEnvironment.
Depending on the type of MediaContainer the sound data is and on the implementation of the AudioDevice used, sound data preparation could consist of opening, attaching, loading, or copying into memory the associated sound data. The query method, isReady() returns true when the sound is fully preprocessed so that it is playable (audibly if active, silently if not active).
Playing Status
1) enabled/started
2) activated
3) not muted
4) not paused
While these conditions are meet, the sound is potentially audible and the method isPlaying() will return a status of true.
isPlaying returns false but isPlayingSilently returns true if a sound:
1) is enabled before it is activated; it is begun playing silently.
2) is enabled then deactivated while playing; it continues playing silently
3) is enabled while it mute state is true
When the sound finishes playing it's sound data (including all loops), it is implicitly disabled.
AudioDevice
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_CHANNELS_USED_READ
Specifies that this node allows access to its number of channels
used by this sound.
|
static int |
ALLOW_CONT_PLAY_READ
Specifies that this node allows access to its object's continuous
play information.
|
static int |
ALLOW_CONT_PLAY_WRITE
Specifies that this node allows writing to its object's continuous
play information.
|
static int |
ALLOW_DURATION_READ
Specifies that this node allows access to its object's sound duration
information.
|
static int |
ALLOW_ENABLE_READ
Specifies that this node allows access to its object's sound on
information.
|
static int |
ALLOW_ENABLE_WRITE
Specifies that this node allows writing to its object's sound on
information.
|
static int |
ALLOW_INITIAL_GAIN_READ
Specifies that this node allows access to its object's initial gain
information.
|
static int |
ALLOW_INITIAL_GAIN_WRITE
Specifies that this node allows writing to its object's initial gain
information.
|
static int |
ALLOW_IS_PLAYING_READ
Specifies that this node allows access to its object's sound audibly
playing or playing silently status.
|
static int |
ALLOW_IS_READY_READ
Specifies that this node allows access to its object's sound status
denoting if it is ready to be played 'immediately'.
|
static int |
ALLOW_LOOP_READ
Specifies that this node allows access to its object's loop
information.
|
static int |
ALLOW_LOOP_WRITE
Specifies that this node allows writing to its object's loop
information.
|
static int |
ALLOW_MUTE_READ
Specifies that this node allows access to its object's mute flag
information.
|
static int |
ALLOW_MUTE_WRITE
Specifies that this node allows writing to its object's mute flag
information.
|
static int |
ALLOW_PAUSE_READ
Specifies that this node allows access to its object's pause flag
information.
|
static int |
ALLOW_PAUSE_WRITE
Specifies that this node allows writing to its object's pause flag
information.
|
static int |
ALLOW_PRIORITY_READ
Specifies that this node allows read access to its priority order
value.
|
static int |
ALLOW_PRIORITY_WRITE
Specifies that this node allows write access to its priority order
value.
|
static int |
ALLOW_RATE_SCALE_FACTOR_READ
Specifies that this node allows access to its object's sample rate scale
factor information.
|
static int |
ALLOW_RATE_SCALE_FACTOR_WRITE
Specifies that this node allows writing to its object's sample rate scale
factor information.
|
static int |
ALLOW_RELEASE_READ
Specifies that this node allows access to its object's release flag
information.
|
static int |
ALLOW_RELEASE_WRITE
Specifies that this node allows writing to its object's release flag
information.
|
static int |
ALLOW_SCHEDULING_BOUNDS_READ
Specifies that this node allows read access to its scheduling bounds
information.
|
static int |
ALLOW_SCHEDULING_BOUNDS_WRITE
Specifies that this node allows write access to its scheduling bounds
information.
|
static int |
ALLOW_SOUND_DATA_READ
Specifies that this node allows access to its object's sound data
information.
|
static int |
ALLOW_SOUND_DATA_WRITE
Specifies that this node allows writing to its object's sound data
information.
|
static int |
DURATION_UNKNOWN
Denotes that the sound's duration could not be calculated.
|
static int |
INFINITE_LOOPS
When used as a loop count sound will loop an infinite number of time
until explicitly stopped (setEnabled(false)).
|
static float |
NO_FILTER
Denotes that there is no filter value associated with object's distance
or angular attenuation array.
|
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
Constructor and Description |
---|
Sound()
Constructs and initializes a new Sound node using default
parameters.
|
Sound(MediaContainer soundData,
float initialGain)
Constructs and initializes a new Sound node object using the provided
data and gain parameter values, and defaults for all other fields.
|
Sound(MediaContainer soundData,
float initialGain,
int loopCount,
boolean release,
boolean continuous,
boolean enable,
Bounds region,
float priority)
Constructs and initializes a new Sound node using provided parameter
values.
|
Sound(MediaContainer soundData,
float initialGain,
int loopCount,
boolean release,
boolean continuous,
boolean enable,
Bounds region,
float priority,
float rateFactor)
Constructs and initializes a new Sound node using provided parameter
values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getContinuousEnable()
Retrieves sound's continuous play flag.
|
long |
getDuration()
Get the Sound's duration
|
boolean |
getEnable()
Retrieves sound's enabled flag.
|
float |
getInitialGain()
Get the overall gain applied to the sound data associated with source.
|
int |
getLoop()
Retrieves loop count for this sound
|
boolean |
getMute()
Retrieves sound Mute state.
|
int |
getNumberOfChannelsUsed()
Retrieves number of channels that are being used to render this sound
on the audio device associated with the Virtual Universe's primary view.
|
int |
getNumberOfChannelsUsed(View view)
Retrieves number of channels that are being used to render this sound
on the audio device associated with given view.
|
boolean |
getPause()
Retrieves the value of the Pause state flag.
|
float |
getPriority()
Retrieves sound's priority value.
|
float |
getRateScaleFactor()
Retrieves Sample Rate.
|
boolean |
getReleaseEnable()
Retrieves the release flag for sound associated with sound.
|
BoundingLeaf |
getSchedulingBoundingLeaf()
Retrieves the Sound node's scheduling bounding leaf.
|
Bounds |
getSchedulingBounds()
Retrieves the Sound node's scheduling bounds.
|
MediaContainer |
getSoundData()
Retrieves description/data associated with this sound source.
|
boolean |
isPlaying()
Retrieves sound's play status.
|
boolean |
isPlaying(View view)
Retrieves sound's play status.
|
boolean |
isPlayingSilently()
Retrieves sound's silent status.
|
boolean |
isPlayingSilently(View view)
Retrieves sound's silent status.
|
boolean |
isReady()
Retrieves sound's 'ready' status.
|
boolean |
isReady(View view)
Retrieves sound's 'ready' status.
|
void |
setContinuousEnable(boolean state)
Enables or disables continuous play flag.
|
void |
setEnable(boolean state)
Enable or disable sound.
|
void |
setInitialGain(float amplitude)
Set the overall gain scale factor applied to data associated with this
source to increase or decrease its overall amplitude.
|
void |
setLoop(int loopCount)
Sets a sound's loop count.
|
void |
setMute(boolean state)
Set mute state flag.
|
void |
setPause(boolean state)
Pauses or resumes (paused) playing sound.
|
void |
setPriority(float priority)
Set sound's priority value.
|
void |
setRateScaleFactor(float scaleFactor)
Sets Sample Rate.
|
void |
setReleaseEnable(boolean state)
Enables or disables the release flag for the sound associated with
this sound.
|
void |
setSchedulingBoundingLeaf(BoundingLeaf region)
Set the Sound's scheduling region to the specified bounding leaf.
|
void |
setSchedulingBounds(Bounds region)
Set the Sound's scheduling region to the specified bounds.
|
void |
setSoundData(MediaContainer soundData)
Sets fields that define the sound source data of this node.
|
void |
updateNodeReferences(NodeReferenceTable referenceTable)
Callback used to allow a node to check if any scene graph objects
referenced
by that node have been duplicated via a call to
cloneTree . |
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString
public static final int ALLOW_SOUND_DATA_READ
public static final int ALLOW_SOUND_DATA_WRITE
public static final int ALLOW_INITIAL_GAIN_READ
public static final int ALLOW_INITIAL_GAIN_WRITE
public static final int ALLOW_LOOP_READ
public static final int ALLOW_LOOP_WRITE
public static final int ALLOW_RELEASE_READ
public static final int ALLOW_RELEASE_WRITE
public static final int ALLOW_CONT_PLAY_READ
public static final int ALLOW_CONT_PLAY_WRITE
public static final int ALLOW_ENABLE_READ
public static final int ALLOW_ENABLE_WRITE
public static final int ALLOW_SCHEDULING_BOUNDS_READ
public static final int ALLOW_SCHEDULING_BOUNDS_WRITE
public static final int ALLOW_PRIORITY_READ
public static final int ALLOW_PRIORITY_WRITE
public static final int ALLOW_DURATION_READ
public static final int ALLOW_IS_READY_READ
public static final int ALLOW_IS_PLAYING_READ
public static final int ALLOW_CHANNELS_USED_READ
public static final int ALLOW_MUTE_READ
public static final int ALLOW_MUTE_WRITE
public static final int ALLOW_PAUSE_READ
public static final int ALLOW_PAUSE_WRITE
public static final int ALLOW_RATE_SCALE_FACTOR_READ
public static final int ALLOW_RATE_SCALE_FACTOR_WRITE
public static final float NO_FILTER
public static final int DURATION_UNKNOWN
public static final int INFINITE_LOOPS
public Sound()
public Sound(MediaContainer soundData, float initialGain)
soundData
- description of JMF source data used by this sound sourceinitialGain
- overall amplitude scale factor applied to sound sourcepublic Sound(MediaContainer soundData, float initialGain, int loopCount, boolean release, boolean continuous, boolean enable, Bounds region, float priority)
soundData
- description of JMF source data used by this sound sourceinitialGain
- overall amplitude scale factor applied to sound sourceloopCount
- number of times sound is looped when playedrelease
- flag specifying whether the sound is to be played
to end when stoppedcontinuous
- flag specifying whether the sound silently plays
when disabledenable
- flag specifying whether the sound is enabledregion
- scheduling boundspriority
- defines playback priority if too many sounds startedpublic Sound(MediaContainer soundData, float initialGain, int loopCount, boolean release, boolean continuous, boolean enable, Bounds region, float priority, float rateFactor)
soundData
- description of JMF source data used by this sound sourceinitialGain
- overall amplitude scale factor applied to sound sourceloopCount
- number of times sound is looped when playedrelease
- flag specifying whether the sound is to be played
to end when stoppedcontinuous
- flag specifying whether the sound silently plays
when disabledenable
- flag specifying whether the sound is enabledregion
- scheduling boundspriority
- defines playback priority if too many sounds startedrateFactor
- defines playback sample rate scale factorpublic void setSoundData(MediaContainer soundData)
soundData
- description of JMF source data used by this sound sourceCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic MediaContainer getSoundData()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setInitialGain(float amplitude)
amplitude
- (gain) scale factorCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic float getInitialGain()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setLoop(int loopCount)
loopCount
- number of times sound is looped during playCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic int getLoop()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setReleaseEnable(boolean state)
state
- release flagCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean getReleaseEnable()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setContinuousEnable(boolean state)
state
- denotes if deactivated sound silently continues playingCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean getContinuousEnable()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setEnable(boolean state)
state
- enable (on/off) flag denotes if active sound is heardCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean getEnable()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setSchedulingBounds(Bounds region)
region
- the bounds that contains the Sound's new scheduling
region.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic Bounds getSchedulingBounds()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setSchedulingBoundingLeaf(BoundingLeaf region)
region
- the bounding leaf node used to specify the Sound
node's new scheduling region.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic BoundingLeaf getSchedulingBoundingLeaf()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setPriority(float priority)
priority
- value used to order sound's importance for playback.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic float getPriority()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic long getDuration()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isReady()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isReady(View view)
view
- the view on which to query the ready status.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isPlaying()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isPlaying(View view)
view
- the view on which to query the isPlaying status.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isPlayingSilently()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean isPlayingSilently(View view)
view
- the view on which to query the isPlayingSilently status.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic int getNumberOfChannelsUsed()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic int getNumberOfChannelsUsed(View view)
view
- the view on which to query the number of channels used.CapabilityNotSetException
- if appropriate capability ispublic void setMute(boolean state)
state
- flagCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean getMute()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setPause(boolean state)
state
- pause flagCapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic boolean getPause()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void setRateScaleFactor(float scaleFactor)
scaleFactor
- %%% describe this.CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic float getRateScaleFactor()
CapabilityNotSetException
- if appropriate capability is
not set and this object is part of live or compiled scene graphpublic void updateNodeReferences(NodeReferenceTable referenceTable)
cloneTree
.
This method is called by cloneTree
after all nodes in
the sub-graph have been duplicated. The cloned Leaf node's method
will be called and the Leaf node can then look up any object references
by using the getNewObjectReference
method found in the
NodeReferenceTable
object. If a match is found, a
reference to the corresponding object in the newly cloned sub-graph
is returned. If no corresponding reference is found, either a
DanglingReferenceException is thrown or a reference to the original
object is returned depending on the value of the
allowDanglingReferences
parameter passed in the
cloneTree
call.
NOTE: Applications should not call this method directly. It should only be called by the cloneTree method.
updateNodeReferences
in class SceneGraphObject
referenceTable
- a NodeReferenceTableObject that contains the
getNewObjectReference
method needed to search for
new object instances.NodeReferenceTable
,
Node.cloneTree()
,
DanglingReferenceException
Copyright © 2016–2022 SciJava. All rights reserved.