|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.scene.Spatial
com.jme3.scene.Node
com.jme3.audio.AudioNode
public class AudioNode
An AudioNode
is used in jME3 for playing audio files.
First, an AudioNode
is loaded from file, and then assigned
to an audio node for playback. Once the audio node is attached to the
scene, its location will influence the position it is playing from relative
to the Listener
.
An audio node can also play in "headspace", meaning its location
or velocity does not influence how it is played.
The "positional" property of an AudioNode can be set via
setPositional(boolean)
.
Nested Class Summary | |
---|---|
static class |
AudioNode.Status
Status indicates the current status of the audio node. |
Nested classes/interfaces inherited from class com.jme3.scene.Spatial |
---|
Spatial.BatchHint, Spatial.CullHint |
Field Summary | |
---|---|
protected AudioKey |
audioKey
|
protected int |
channel
|
protected AudioData |
data
|
protected Vector3f |
direction
|
protected Filter |
dryFilter
|
protected float |
innerAngle
|
protected boolean |
loop
|
protected float |
maxDistance
|
protected float |
outerAngle
|
protected float |
pitch
|
protected boolean |
positional
|
protected float |
refDistance
|
protected boolean |
reverbEnabled
|
protected Filter |
reverbFilter
|
protected AudioNode.Status |
status
|
protected float |
timeOffset
|
protected Vector3f |
velocity
|
protected float |
volume
|
Fields inherited from class com.jme3.scene.Node |
---|
children |
Fields inherited from class com.jme3.scene.Spatial |
---|
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_LIGHTLIST, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldTransform |
Constructor Summary | |
---|---|
AudioNode()
Creates a new AudioNode without any audio data set. |
|
AudioNode(AssetManager assetManager,
java.lang.String name)
Creates a new AudioNode with the given audio file. |
|
AudioNode(AssetManager assetManager,
java.lang.String name,
boolean stream)
Creates a new AudioNode with the given audio file. |
|
AudioNode(AssetManager assetManager,
java.lang.String name,
boolean stream,
boolean streamCache)
Creates a new AudioNode with the given audio file. |
|
AudioNode(AudioData audioData,
AudioKey audioKey)
Creates a new AudioNode with the given data and key. |
|
AudioNode(AudioRenderer audioRenderer,
AssetManager assetManager,
java.lang.String name)
Deprecated. AudioRenderer parameter is ignored. |
Method Summary | |
---|---|
AudioNode |
clone()
Creates a clone of the asset. |
AudioData |
getAudioData()
|
int |
getChannel()
Do not use. |
Vector3f |
getDirection()
|
Filter |
getDryFilter()
|
float |
getInnerAngle()
|
float |
getMaxDistance()
|
float |
getOuterAngle()
|
float |
getPitch()
|
float |
getRefDistance()
|
protected AudioRenderer |
getRenderer()
|
Filter |
getReverbFilter()
|
AudioNode.Status |
getStatus()
|
float |
getTimeOffset()
|
Vector3f |
getVelocity()
|
float |
getVolume()
|
boolean |
isDirectional()
|
boolean |
isLooping()
|
boolean |
isPositional()
|
boolean |
isReverbEnabled()
|
void |
pause()
Pause the audio that was started with play() . |
void |
play()
Start playing the audio. |
void |
playInstance()
Start playing an instance of this audio. |
void |
read(JmeImporter im)
|
void |
setAudioData(AudioData audioData,
AudioKey audioKey)
Set the audio data to use for the audio. |
void |
setChannel(int channel)
Do not use. |
void |
setDirection(Vector3f direction)
Set the direction of this audio node. |
void |
setDirectional(boolean directional)
Set the audio node to be directional. |
void |
setDryFilter(Filter dryFilter)
Set the dry filter to use for this audio node. |
void |
setInnerAngle(float innerAngle)
Set the directional audio node cone inner angle. |
void |
setLooping(boolean loop)
Set the looping mode for the audio node. |
void |
setMaxDistance(float maxDistance)
Set the maximum distance for the attenuation of the audio node. |
void |
setOuterAngle(float outerAngle)
Set the directional audio node cone outer angle. |
void |
setPitch(float pitch)
Set the pitch of the audio, also the speed of playback. |
void |
setPositional(boolean positional)
Set the audio node as positional. |
void |
setRefDistance(float refDistance)
Set the reference playing distance for the audio node. |
void |
setReverbEnabled(boolean reverbEnabled)
Set to true to enable reverberation effects for this audio node. |
void |
setReverbFilter(Filter reverbFilter)
Set the reverb filter for this audio node. |
void |
setStatus(AudioNode.Status status)
Do not use. |
void |
setTimeOffset(float timeOffset)
Set the time offset in the sound sample when to start playing. |
void |
setVelocity(Vector3f velocity)
Set the velocity of the audio node. |
void |
setVolume(float volume)
Set the volume of this audio node. |
void |
stop()
Stop playing the audio that was started with play() . |
java.lang.String |
toString()
Returns the Spatial's name followed by the class of the spatial Example: "MyNode (com.jme3.scene.Spatial) |
void |
updateGeometricState()
updateGeometricState updates the lightlist,
computes the world transforms, and computes the world bounds
for this Spatial. |
void |
write(JmeExporter ex)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean loop
protected float volume
protected float pitch
protected float timeOffset
protected Filter dryFilter
protected AudioKey audioKey
protected transient AudioData data
protected transient volatile AudioNode.Status status
protected transient volatile int channel
protected Vector3f velocity
protected boolean reverbEnabled
protected float maxDistance
protected float refDistance
protected Filter reverbFilter
protected Vector3f direction
protected float innerAngle
protected float outerAngle
protected boolean positional
Constructor Detail |
---|
public AudioNode()
AudioNode
without any audio data set.
public AudioNode(AudioData audioData, AudioKey audioKey)
AudioNode
with the given data and key.
audioData
- The audio data contains the audio track to play.audioKey
- The audio key that was used to load the AudioDatapublic AudioNode(AssetManager assetManager, java.lang.String name, boolean stream, boolean streamCache)
AudioNode
with the given audio file.
assetManager
- The asset manager to use to load the audio filename
- The filename of the audio filestream
- 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.public AudioNode(AssetManager assetManager, java.lang.String name, boolean stream)
AudioNode
with the given audio file.
assetManager
- The asset manager to use to load the audio filename
- The filename of the audio filestream
- If true, the audio will be streamed gradually from disk,
otherwise, it will be buffered.public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, java.lang.String name)
AudioNode
with the given audio file.
audioRenderer
- The audio renderer to use for playing. Cannot be null.assetManager
- The asset manager to use to load the audio filename
- The filename of the audio filepublic AudioNode(AssetManager assetManager, java.lang.String name)
AudioNode
with the given audio file.
assetManager
- The asset manager to use to load the audio filename
- The filename of the audio fileMethod Detail |
---|
protected AudioRenderer getRenderer()
public void play()
public void playInstance()
AudioNode
multiple times. Note
that changes to the parameters of this AudioNode will not effect the
instances already playing.
public void stop()
play()
.
public void pause()
play()
.
public final void setChannel(int channel)
public int getChannel()
public Filter getDryFilter()
setDryFilter(com.jme3.audio.Filter)
public void setDryFilter(Filter dryFilter)
reverb
is 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 relevent documentation for the Filter
to determine
the effect.
dryFilter
- The filter to set, or null to disable dry filter.public void setAudioData(AudioData audioData, AudioKey audioKey)
AudioData
.
audioData
- The audio data contains the audio track to play.audioKey
- The audio key that was used to load the AudioDatapublic AudioData getAudioData()
AudioData
set previously with
setAudioData(com.jme3.audio.AudioData, com.jme3.audio.AudioKey)
or any of the constructors that initialize the audio data.public AudioNode.Status getStatus()
AudioNode.Status
of the audio node.
The status will be changed when either the play()
or stop()
methods are called.public final void setStatus(AudioNode.Status status)
public boolean isLooping()
setLooping(boolean)
public void setLooping(boolean loop)
loop
- True if the audio should keep looping after it is done playing.public float getPitch()
setPitch(float)
public void setPitch(float pitch)
pitch
- The pitch to set.
java.lang.IllegalArgumentException
- If pitch is not between 0.5 and 2.0.public float getVolume()
setVolume(float)
public void setVolume(float volume)
volume
- The volume to set.
java.lang.IllegalArgumentException
- If volume is negativepublic float getTimeOffset()
public void setTimeOffset(float timeOffset)
timeOffset
- The time offset
java.lang.IllegalArgumentException
- If timeOffset is negativepublic Vector3f getVelocity()
setVelocity(com.jme3.math.Vector3f)
public void setVelocity(Vector3f velocity)
velocity
- The velocity to set.setPositional(boolean)
public boolean isReverbEnabled()
setReverbEnabled(boolean)
public void setReverbEnabled(boolean reverbEnabled)
AudioRenderer.setEnvironment(com.jme3.audio.Environment)
will apply a reverb effect to the audio playing from this audio node.
reverbEnabled
- True to enable reverb.public Filter getReverbFilter()
setReverbFilter(com.jme3.audio.Filter)
public void setReverbFilter(Filter reverbFilter)
reverbFilter
- The reverb filter to set.setDryFilter(com.jme3.audio.Filter)
public float getMaxDistance()
setMaxDistance(float)
public void setMaxDistance(float maxDistance)
maxDistance
- The maximum playing distance.
java.lang.IllegalArgumentException
- If maxDistance is negativepublic float getRefDistance()
setRefDistance(float)
public void setRefDistance(float refDistance)
refDistance
- The reference playing distance.
java.lang.IllegalArgumentException
- If refDistance is negativepublic boolean isDirectional()
setDirectional(boolean)
public void setDirectional(boolean directional)
setDirection(com.jme3.math.Vector3f)
to set the audio node's direction.
directional
- If the audio node is directionalpublic Vector3f getDirection()
setDirection(com.jme3.math.Vector3f)
public void setDirection(Vector3f direction)
direction
- setDirectional(boolean)
public float getInnerAngle()
setInnerAngle(float)
public void setInnerAngle(float innerAngle)
innerAngle
- The cone inner angle.public float getOuterAngle()
setOuterAngle(float)
public void setOuterAngle(float outerAngle)
outerAngle
- The cone outer angle.public boolean isPositional()
setPositional(boolean)
public void setPositional(boolean positional)
positional
- True if the audio node should be positional, otherwise
false if it should be headspace.public void updateGeometricState()
Spatial
updateGeometricState
updates the lightlist,
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.
updateGeometricState
in class Node
Spatial.getWorldLightList()
,
Spatial.getWorldTransform()
,
Spatial.getWorldBound()
public AudioNode clone()
CloneableSmartAsset
Object.clone()
for more info on how this method
should be implemented.
clone
in interface CloneableSmartAsset
clone
in class Spatial
Mesh.cloneForAnim()
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
write
in class Node
java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
read
in class Node
java.io.IOException
public java.lang.String toString()
Spatial
toString
in class Spatial
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |