Package com.jme3.audio
Class AudioNode
java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Node
com.jme3.audio.AudioNode
- All Implemented Interfaces:
- HasLocalTransform,- CloneableSmartAsset,- AudioSource,- Collidable,- Savable,- JmeCloneable,- Cloneable
An 
AudioNode is a scene Node which can play audio assets.
 An AudioNode is either positional or ambient, with positional being the
 default. Once a positional node is attached to the scene, its location and
 velocity relative to the Listener affect how it sounds when played.
 Positional nodes can only play monaural (single-channel) assets, not stereo
 ones.
 An ambient AudioNode plays in "headspace", meaning that the node's location
 and velocity do not affect how it sounds when played. Ambient audio nodes can
 play stereo assets.
 The "positional" property of an AudioNode can be set via
 setPositional(boolean).- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumDeprecated.- use AudioSource.Status insteadNested classes/interfaces inherited from class com.jme3.scene.SpatialSpatial.BatchHint, Spatial.CullHint, Spatial.DFSMode
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AudioKeyprotected intprotected AudioDataprotected Vector3fprotected Filterprotected floatprotected floatprotected booleanprotected floatprotected floatprotected floatprotected booleanprotected Vector3fprotected floatprotected booleanprotected Filterstatic final intprotected AudioSource.Statusprotected floatprotected Vector3fprotected booleanprotected floatFields inherited from class com.jme3.scene.SpatialbatchHint, controls, cullHint, frustrumIntersects, key, localLights, localOverrides, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_CHILD_LIGHTLIST, RF_LIGHTLIST, RF_MATPARAM_OVERRIDE, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldOverrides, worldTransform
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a newAudioNodewithout any audio data set.AudioNode(AssetManager assetManager, String name) Deprecated.AudioNode(AssetManager assetManager, String name, boolean stream) Deprecated.AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) Deprecated.AudioNode(AssetManager assetManager, String name, AudioData.DataType type) Creates a newAudioNodewith the given audio file.Creates a newAudioNodewith the given data and key.AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name) Deprecated.AudioRenderer parameter is ignored.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Creates a clone of the asset.voidcloneFields(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.intDo not use.floatfloatfloatfloatgetPitch()floatfloatprotected AudioRendererfloatgetType()Get the Type of the underlying AudioData to see if it's streamed or buffered.floatbooleanbooleanbooleanbooleanbooleanvoidpause()Pause the audio that was started withplay().voidplay()Start playing the audio.voidStart playing an instance of this audio.voidread(JmeImporter im) voidsetAudioData(AudioData audioData, AudioKey audioKey) Set the audio data to use for the audio.final voidsetChannel(int channel) Do not use.voidsetDirection(Vector3f direction) Set the direction of this audio node.voidsetDirectional(boolean directional) Set the audio node to be directional.voidsetDryFilter(Filter dryFilter) Set the dry filter to use for this audio node.voidsetInnerAngle(float innerAngle) Set the directional audio node cone inner angle.voidsetLooping(boolean loop) Set the looping mode for the audio node.voidsetMaxDistance(float maxDistance) Set the maximum distance for the attenuation of the audio node.voidsetOuterAngle(float outerAngle) Set the directional audio node cone outer angle.voidsetPitch(float pitch) Set the pitch of the audio, also the speed of playback.voidsetPositional(boolean positional) Set the audio node as positional.voidsetRefDistance(float refDistance) Set the reference playing distance for the audio node.voidsetReverbEnabled(boolean reverbEnabled) Set to true to enable reverberation effects for this audio node.voidsetReverbFilter(Filter reverbFilter) Set the reverb filter for this audio node.final voidsetStatus(AudioSource.Status status) Do not use.voidsetTimeOffset(float timeOffset) Set the time offset in the sound sample when to start playing.voidsetVelocity(Vector3f velocity) Set the velocity of the audio node.voidsetVelocityFromTranslation(boolean velocityFromTranslation) voidsetVolume(float volume) Set the volume of this audio node.voidstop()Stop playing the audio that was started withplay().toString()Returns the Spatial's name followed by the class of the spatial
 Example: "MyNode (com.jme3.scene.Spatial)"voidupdateGeometricStateupdates the light list, computes the world transforms, and computes the world bounds for this Spatial.voidupdateLogicalState(float tpf) updateLogicalStatecalls theupdate()method for all controls attached to this Spatial.voidwrite(JmeExporter ex) Methods inherited from class com.jme3.scene.NodeattachChild, attachChildAt, breadthFirstTraversal, clone, collideWith, deepClone, depthFirstTraversal, descendantMatches, descendantMatches, descendantMatches, detachAllChildren, detachChild, detachChildAt, detachChildNamed, getChild, getChild, getChildIndex, getChildren, getQuantity, getTriangleCount, getVertexCount, hasChild, oldDeepClone, setLightListRefresh, setLodLevel, setMaterial, setMatParamOverrideRefresh, setModelBound, setParent, setTransformRefresh, swapChildren, updateModelBound, updateWorldBoundMethods inherited from class com.jme3.scene.SpatialaddControl, addControlAt, addLight, addMatParamOverride, breadthFirstTraversal, center, checkCulling, clearMatParamOverrides, depthFirstTraversal, forceRefresh, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalMatParamOverrides, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldMatParamOverrides, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, jmeClone, localToWorld, lookAt, matches, move, move, oldClone, removeControl, removeControl, removeFromParent, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setUserData, updateMatParamOverrides, updateWorldLightList, updateWorldTransforms, worldToLocal
- 
Field Details- 
SAVABLE_VERSIONpublic static final int SAVABLE_VERSION- See Also:
 
- 
loopprotected boolean loop
- 
volumeprotected float volume
- 
pitchprotected float pitch
- 
timeOffsetprotected float timeOffset
- 
dryFilter
- 
audioKey
- 
data
- 
status
- 
channelprotected transient volatile int channel
- 
previousWorldTranslation
- 
velocity
- 
reverbEnabledprotected boolean reverbEnabled
- 
maxDistanceprotected float maxDistance
- 
refDistanceprotected float refDistance
- 
reverbFilter
- 
direction
- 
innerAngleprotected float innerAngle
- 
outerAngleprotected float outerAngle
- 
positionalprotected boolean positional
- 
velocityFromTranslationprotected boolean velocityFromTranslation
- 
lastTpfprotected float lastTpf
 
- 
- 
Constructor Details- 
AudioNodepublic AudioNode()Creates a newAudioNodewithout any audio data set.
- 
AudioNodeCreates a newAudioNodewith the given data and key.- Parameters:
- audioData- The audio data contains the audio track to play.
- audioKey- The audio key that was used to load the AudioData
 
- 
AudioNodeCreates a newAudioNodewith the given audio file.- Parameters:
- assetManager- The asset manager to use to load the audio file
- name- The filename of the audio file
- type- The type. If- AudioData.DataType.Stream- AudioData.DataType.Buffer
 
- 
AudioNode@Deprecated public AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) Deprecated.Creates a newAudioNodewith the given audio file.- Parameters:
- assetManager- The asset manager to use to load the audio file
- name- The filename of the audio file
- stream- If true, the audio will be streamed gradually from disk, otherwise, it will be buffered.
- streamCache- If stream is also true, then this specifies if the stream cache is used. When enabled, the audio stream will be read entirely but not decoded, allowing features such as seeking, looping and determining duration.
 
- 
AudioNodeDeprecated.Creates a newAudioNodewith the given audio file.- Parameters:
- assetManager- The asset manager to use to load the audio file
- name- The filename of the audio file
- stream- If true, the audio will be streamed gradually from disk, otherwise, it will be buffered.
 
- 
AudioNodeDeprecated.AudioRenderer parameter is ignored.Creates a newAudioNodewith the given audio file.- Parameters:
- audioRenderer- The audio renderer to use for playing. Cannot be null.
- assetManager- The asset manager to use to load the audio file
- name- The filename of the audio file
 
- 
AudioNodeDeprecated.Creates a newAudioNodewith the given audio file.- Parameters:
- assetManager- The asset manager to use to load the audio file
- name- The filename of the audio file
 
 
- 
- 
Method Details- 
getRenderer
- 
playpublic void play()Start playing the audio.
- 
playInstancepublic void playInstance()Start playing an instance of this audio. This method can be used to play the sameAudioNodemultiple times. Note that changes to the parameters of this AudioNode will not affect the instances already playing.
- 
stoppublic void stop()Stop playing the audio that was started withplay().
- 
pausepublic void pause()Pause the audio that was started withplay().
- 
setChannelpublic final void setChannel(int channel) Do not use.- Specified by:
- setChannelin interface- AudioSource
- Parameters:
- channel- the desired channel index, or -1 if stopped
 
- 
getChannelpublic int getChannel()Do not use.- Specified by:
- getChannelin interface- AudioSource
- Returns:
- the channel index, or -1 if stopped
 
- 
getDryFilter- Specified by:
- getDryFilterin interface- AudioSource
- Returns:
- The {#link Filter dry filter} that is set.
- See Also:
 
- 
setDryFilterSet the dry filter to use for this audio node. Whenreverbis used, the dry filter will only influence the "dry" portion of the audio, e.g. not the reverberated parts of the AudioNode playing. See the relevant documentation for theFilterto determine the effect.- Parameters:
- dryFilter- The filter to set, or null to disable dry filter.
 
- 
setAudioDataSet the audio data to use for the audio. Note that this method can only be called once, if for example the audio node was initialized without anAudioData.- Parameters:
- audioData- The audio data contains the audio track to play.
- audioKey- The audio key that was used to load the AudioData
 
- 
getAudioData- Specified by:
- getAudioDatain interface- AudioSource
- Returns:
- The AudioDataset previously withsetAudioData(com.jme3.audio.AudioData, com.jme3.audio.AudioKey)or any of the constructors that initialize the audio data.
 
- 
getStatus- Specified by:
- getStatusin interface- AudioSource
- Returns:
- The AudioNode.Statusof the audio node. The status will be changed when either theplay()orstop()methods are called.
 
- 
setStatusDo not use.- Specified by:
- setStatusin interface- AudioSource
- Parameters:
- status- the desired status
 
- 
getTypeGet the Type of the underlying AudioData to see if it's streamed or buffered. This is a shortcut to getAudioData().getType() Warning: Can return null!- Returns:
- The AudioData.DataTypeof the audio node.
 
- 
isLoopingpublic boolean isLooping()- Specified by:
- isLoopingin interface- AudioSource
- Returns:
- True if the audio will keep looping after it is done playing, otherwise, false.
- See Also:
 
- 
setLoopingpublic void setLooping(boolean loop) Set the looping mode for the audio node. The default is false.- Parameters:
- loop- True if the audio should keep looping after it is done playing.
 
- 
getPitchpublic float getPitch()- Specified by:
- getPitchin interface- AudioSource
- Returns:
- The pitch of the audio, also the speed of playback.
- See Also:
 
- 
setPitchpublic void setPitch(float pitch) Set the pitch of the audio, also the speed of playback. The value must be between 0.5 and 2.0.- Parameters:
- pitch- The pitch to set.
- Throws:
- IllegalArgumentException- If pitch is not between 0.5 and 2.0.
 
- 
getVolumepublic float getVolume()- Specified by:
- getVolumein interface- AudioSource
- Returns:
- The volume of this audio node.
- See Also:
 
- 
setVolumepublic void setVolume(float volume) Set the volume of this audio node. The volume is specified as gain. 1.0 is the default.- Parameters:
- volume- The volume to set.
- Throws:
- IllegalArgumentException- If volume is negative
 
- 
getTimeOffsetpublic float getTimeOffset()- Specified by:
- getTimeOffsetin interface- AudioSource
- Returns:
- the time offset in the sound sample when to start playing.
 
- 
setTimeOffsetpublic void setTimeOffset(float timeOffset) Set the time offset in the sound sample when to start playing.- Parameters:
- timeOffset- The time offset
- Throws:
- IllegalArgumentException- If timeOffset is negative
 
- 
getPlaybackTimepublic float getPlaybackTime()- Specified by:
- getPlaybackTimein interface- AudioSource
- Returns:
- the current playback position of the source in seconds.
 
- 
getPosition- Specified by:
- getPositionin interface- AudioSource
- Returns:
- The position of the audio source.
 
- 
getVelocity- Specified by:
- getVelocityin interface- AudioSource
- Returns:
- The velocity of the audio node.
- See Also:
 
- 
setVelocitySet the velocity of the audio node. The velocity is expected to be in meters. Does nothing if the audio node is not positional.- Parameters:
- velocity- The velocity to set.
- See Also:
 
- 
isReverbEnabledpublic boolean isReverbEnabled()- Specified by:
- isReverbEnabledin interface- AudioSource
- Returns:
- True if reverb is enabled, otherwise false.
- See Also:
 
- 
setReverbEnabledpublic void setReverbEnabled(boolean reverbEnabled) Set to true to enable reverberation effects for this audio node. Does nothing if the audio node is not positional.
 When enabled, the audio environment set withAudioRenderer.setEnvironment(com.jme3.audio.Environment)will apply a reverb effect to the audio playing from this audio node.- Parameters:
- reverbEnabled- True to enable reverb.
 
- 
getReverbFilter- Specified by:
- getReverbFilterin interface- AudioSource
- Returns:
- Filter for the reverberations of this audio node.
- See Also:
 
- 
setReverbFilterSet the reverb filter for this audio node.
 The reverb filter will influence the reverberations of the audio node playing. This only has an effect if reverb is enabled.- Parameters:
- reverbFilter- The reverb filter to set.
- See Also:
 
- 
getMaxDistancepublic float getMaxDistance()- Specified by:
- getMaxDistancein interface- AudioSource
- Returns:
- Maximum distance for this audio node.
- See Also:
 
- 
setMaxDistancepublic void setMaxDistance(float maxDistance) Set the maximum distance for the attenuation of the audio node. Does nothing if the audio node is not positional.
 The maximum distance is the distance beyond which the audio node will no longer be attenuated. Normal attenuation is logarithmic from refDistance (it reduces by half when the distance doubles). Max distance sets where this fall-off stops and the sound will never get any quieter than at that distance. If you want a sound to fall-off very quickly then set ref distance very short and leave this distance very long.- Parameters:
- maxDistance- The maximum playing distance.
- Throws:
- IllegalArgumentException- If maxDistance is negative
 
- 
getRefDistancepublic float getRefDistance()- Specified by:
- getRefDistancein interface- AudioSource
- Returns:
- The reference playing distance for the audio node.
- See Also:
 
- 
setRefDistancepublic void setRefDistance(float refDistance) Set the reference playing distance for the audio node. Does nothing if the audio node is not positional.
 The reference playing distance is the distance at which the audio node will be exactly half of its volume.- Parameters:
- refDistance- The reference playing distance.
- Throws:
- IllegalArgumentException- If refDistance is negative
 
- 
isDirectionalpublic boolean isDirectional()- Specified by:
- isDirectionalin interface- AudioSource
- Returns:
- True if the audio node is directional
- See Also:
 
- 
setDirectionalpublic void setDirectional(boolean directional) Set the audio node to be directional. Does nothing if the audio node is not positional.
 After setting directional, you should callsetDirection(com.jme3.math.Vector3f)to set the audio node's direction.- Parameters:
- directional- If the audio node is directional
 
- 
getDirection- Specified by:
- getDirectionin interface- AudioSource
- Returns:
- The direction of this audio node.
- See Also:
 
- 
setDirectionSet the direction of this audio node. Does nothing if the audio node is not directional.- Parameters:
- direction- a direction vector (alias created)
- See Also:
 
- 
getInnerAnglepublic float getInnerAngle()- Specified by:
- getInnerAnglein interface- AudioSource
- Returns:
- The directional audio node, cone inner angle.
- See Also:
 
- 
setInnerAnglepublic void setInnerAngle(float innerAngle) Set the directional audio node cone inner angle. Does nothing if the audio node is not directional.- Parameters:
- innerAngle- The cone inner angle.
 
- 
getOuterAnglepublic float getOuterAngle()- Specified by:
- getOuterAnglein interface- AudioSource
- Returns:
- The directional audio node, cone outer angle.
- See Also:
 
- 
setOuterAnglepublic void setOuterAngle(float outerAngle) Set the directional audio node cone outer angle. Does nothing if the audio node is not directional.- Parameters:
- outerAngle- The cone outer angle.
 
- 
isPositionalpublic boolean isPositional()- Specified by:
- isPositionalin interface- AudioSource
- Returns:
- True if the audio node is positional.
- See Also:
 
- 
setPositionalpublic void setPositional(boolean positional) Set the audio node as positional. The position, velocity, and distance parameters affect positional audio nodes. Set to false if the audio node should play in "headspace".- Parameters:
- positional- True if the audio node should be positional, otherwise false if it should be headspace.
 
- 
isVelocityFromTranslationpublic boolean isVelocityFromTranslation()
- 
setVelocityFromTranslationpublic void setVelocityFromTranslation(boolean velocityFromTranslation) 
- 
updateLogicalStatepublic void updateLogicalState(float tpf) Description copied from class:SpatialupdateLogicalStatecalls theupdate()method for all controls attached to this Spatial.- Overrides:
- updateLogicalStatein class- Node
- Parameters:
- tpf- Time per frame.
- See Also:
 
- 
updateGeometricStatepublic void updateGeometricState()Description copied from class:SpatialupdateGeometricStateupdates the light list, computes the world transforms, and computes the world bounds for this Spatial. Calling this when the Spatial is attached to a node will cause undefined results. User code should only call this method on Spatials having no parent.- Overrides:
- updateGeometricStatein class- Node
- See Also:
 
- 
cloneDescription copied from interface:CloneableSmartAssetCreates a clone of the asset. Please seeObject.clone()for more info on how this method should be implemented.- Specified by:
- clonein interface- CloneableSmartAsset
- Overrides:
- clonein class- Spatial
- Returns:
- A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated.
- See Also:
 
- 
cloneFieldsCalled internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
- cloneFieldsin interface- JmeCloneable
- Overrides:
- cloneFieldsin class- Node
- Parameters:
- cloner- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
- original- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- Node
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Node
- Throws:
- IOException
 
- 
toStringDescription copied from class:SpatialReturns the Spatial's name followed by the class of the spatial
 Example: "MyNode (com.jme3.scene.Spatial)"
 
-