Class BaseAudioClip
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
org.web3d.vrml.renderer.common.nodes.BaseTimeControlledNode
org.web3d.vrml.renderer.common.nodes.sound.BaseAudioClip
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLAudioClipNodeType
,VRMLChildNodeType
,VRMLExternalNodeType
,VRMLNodeType
,VRMLSingleExternalNodeType
,VRMLTimeControlledNodeType
,VRMLTimeDependentNodeType
,VRMLTimeListener
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
NRAudioClip
,OGLAudioClip
public class BaseAudioClip
extends BaseTimeControlledNode
implements VRMLSingleExternalNodeType, VRMLTimeListener, VRMLTimeDependentNodeType, VRMLAudioClipNodeType
AudioClip node implementation.
- Version:
- $Revision: 1.23 $
- Author:
- Guy Carpenter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static VRMLFieldDeclaration[]
Array of VRMLFieldDeclarationsHashmap between a field name and its indexprotected String
exposedField SFString description ""protected double
duration of most recently loaded clipprotected boolean
eventOut SFBool isActiveprotected boolean
eventOut SFBool isPausedprotected float
exposedField SFFloat pitch, default 1.0protected String[]
exposedField MFString urlFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeControlledNode
FIELD_ELAPSED_TIME, FIELD_LOOP, FIELD_PAUSE_TIME, FIELD_RESUME_TIME, FIELD_START_TIME, FIELD_STOP_TIME, LAST_TIME_INDEX, vfElapsedTime, vfLoop, vfPauseTime, vfResumeTime, vfStartTime, vfStopTime
Fields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
vrmlClock
Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
Fields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to this node instance for the content state changes.void
addSoundStateListener
(VRMLSoundStateListener listener) Add a listener to this node instance.void
addUrlListener
(VRMLUrlListener listener) Add a listener to this node instance.void
Notification that the rendering of the event model is complete and that rendering is about to begin.boolean
checkValidContentType
(String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node.void
copy
(VRMLNodeType node) Copies all of the field values from the passed nodes into our own node.protected void
Send a notification to the registered listeners that the content state has been changed.protected void
Send a notification to the registered listeners that a field has been changed.protected void
fireUrlChanged
(int index) Send a notification to the registered listeners that a field has been changed.Accessor method to get current value of field descriptiondouble
Accessor method to get current value of field durationgetFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.boolean
Accessor method to get current value of field isActiveint
Ask the state of the load of this node.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.float
getPitch()
Accessor method to get current value of field pitch, default value is1
.int
Get the primary type of this node.int[]
Get the secondary type of this node.String[]
getUrl()
Get the list of URLs requested by this node.Get the world URL so set for this node.void
Remove a listener from this node instance for the content state changes.void
Remove a listener from this node instance.void
removeUrlListener
(VRMLUrlListener listener) Remove a listener from this node instance.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setContent
(String mimetype, Object content) Set the content of this node to the given object.void
setDescription
(String newDescription) Set a new description string for this node.void
setDuration
(double newDuration) Accessor method to set a new value for field attribute durationvoid
setIsActive
(boolean newIsActive) Set a new value for isActive.void
setLoadedURI
(String URI) Notify the node which URL was used to load the content.void
setLoadState
(int state) Set the load state of the node.void
setLoop
(boolean loop) Set the loop variable.void
setPitch
(float newPitch) Sets a new value for this node's pitch.void
setStartTime
(double newStartTime) Set a new value for the start time.void
setStopTime
(double newStopTime) Set a new value for the stop time.void
Sets the URL to a new value.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
Set the value of the field at the given index as a string.void
Set the value of the field at the given index as an array of strings.void
setVRMLClock
(VRMLClock clk) Set the vrmlClock that this time dependent node will be running with.void
setWorldUrl
(String url) Set the world URL so that any relative URLs may be corrected to the fully qualified version.void
timeClick
(long time) Notification that the time is now this value.Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeControlledNode
copy, getLoop, getStartTime, getStopTime, setPauseTime, setResumeTime, setValue, setValue
Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
Methods inherited from interface org.web3d.vrml.nodes.VRMLTimeControlledNodeType
getLoop, getStartTime, getStopTime
-
Field Details
-
fieldDecl
Array of VRMLFieldDeclarations -
fieldMap
-
vfDescription
exposedField SFString description "" -
vfIsActive
protected boolean vfIsActiveeventOut SFBool isActive -
vfIsPaused
protected boolean vfIsPausedeventOut SFBool isPaused -
vfPitch
protected float vfPitchexposedField SFFloat pitch, default 1.0 -
vfDuration
protected double vfDurationduration of most recently loaded clip -
vfUrl
exposedField MFString url
-
-
Constructor Details
-
BaseAudioClip
public BaseAudioClip()Constructor creates a default audioclip node.
-
-
Method Details
-
copy
Copies all of the field values from the passed nodes into our own node.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a compatible node
-
setStartTime
public void setStartTime(double newStartTime) Set a new value for the start time. If the sensor is active then it is ignored (as per the spec).- Specified by:
setStartTime
in interfaceVRMLTimeControlledNodeType
- Overrides:
setStartTime
in classBaseTimeControlledNode
- Parameters:
newStartTime
- The new start time
-
setStopTime
public void setStopTime(double newStopTime) Set a new value for the stop time. If the sensor is active and the stop time is less than the current start time, it is ignored. If the stop time is less that now, it is set to now.- Specified by:
setStopTime
in interfaceVRMLTimeControlledNodeType
- Overrides:
setStopTime
in classBaseTimeControlledNode
- Parameters:
newStopTime
- The new stop time
-
setDescription
Set a new description string for this node.- Specified by:
setDescription
in interfaceVRMLAudioClipNodeType
- Parameters:
newDescription
- The new description string.
-
setIsActive
public void setIsActive(boolean newIsActive) Set a new value for isActive. This may be called by the containing Sound node when non-looped audio has finished playing- Specified by:
setIsActive
in interfaceVRMLAudioClipNodeType
- Parameters:
newIsActive
- New active state for this node.
-
setPitch
Sets a new value for this node's pitch. The value must be > 0.- Specified by:
setPitch
in interfaceVRMLAudioClipNodeType
- Parameters:
newPitch
- New value for pitch.- Throws:
InvalidFieldValueException
- Pitch is <= 0
-
setDuration
public void setDuration(double newDuration) Description copied from interface:VRMLAudioClipNodeType
Accessor method to set a new value for field attribute duration- Specified by:
setDuration
in interfaceVRMLAudioClipNodeType
- Parameters:
newDuration
- The new duration
-
addSoundStateListener
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.- Parameters:
listener
- The listener instance to add
-
removeSoundStateListener
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.- Parameters:
listener
- The listener to be removed
-
addContentStateListener
Add a listener to this node instance for the content state changes. If the listener is already added or null the request is silently ignored.- Specified by:
addContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
listener
- The listener instance to add
-
removeContentStateListener
Remove a listener from this node instance for the content state changes. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
listener
- The listener to be removed
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getSecondaryType
public int[] getSecondaryType()Get the secondary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Overrides:
getSecondaryType
in classAbstractNode
- Returns:
- The secondary type
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classBaseTimeControlledNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
setValue
public void setValue(int index, String value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a string. This would be used to set SFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The index is not a valid fieldInvalidFieldValueException
- The field value is not legal for the field specified.
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of strings. This would be used to set MFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knowInvalidFieldValueException
- The field value is not legal for the field specified.
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
allEventsComplete
public void allEventsComplete()Notification that the rendering of the event model is complete and that rendering is about to begin. Used to update the transformation matrix only once per frame.- Specified by:
allEventsComplete
in interfaceFrameStateListener
- Overrides:
allEventsComplete
in classAbstractNode
-
fireUrlChanged
protected void fireUrlChanged(int index) Send a notification to the registered listeners that a field has been changed. If no listeners have been registered, then this does nothing, so always call it regardless.- Parameters:
index
- The index of the field that changed
-
fireSoundStateChanged
protected void fireSoundStateChanged()Send a notification to the registered listeners that a field has been changed. If no listeners have been registered, then this does nothing, so always call it regardless. -
fireContentStateChanged
protected void fireContentStateChanged()Send a notification to the registered listeners that the content state has been changed. If no listeners have been registered, then this does nothing, so always call it regardless. -
getLoadState
public int getLoadState()Ask the state of the load of this node. The value will be one of the constants defined in VRMLSingleExternalNodeType.- Specified by:
getLoadState
in interfaceVRMLSingleExternalNodeType
- Returns:
- The current load state of the node
-
setLoadState
public void setLoadState(int state) Set the load state of the node. The value must be one of the constants defined in VRMLSingleExternalNodeType.- Specified by:
setLoadState
in interfaceVRMLSingleExternalNodeType
- Parameters:
state
- The new state of the node
-
setUrl
Sets the URL to a new value. We will load only one of these URL's. The list provides alternates.- Specified by:
setUrl
in interfaceVRMLAudioClipNodeType
- Specified by:
setUrl
in interfaceVRMLSingleExternalNodeType
- Parameters:
newURL
- Array of candidate URL stringsnumValid
- The number of valid values to copy from the array
-
getUrl
Get the list of URLs requested by this node. If there are no URLs supplied in the text file then this will return a zero length array.- Specified by:
getUrl
in interfaceVRMLAudioClipNodeType
- Specified by:
getUrl
in interfaceVRMLSingleExternalNodeType
- Returns:
- The list of URLs to attempt to load
-
checkValidContentType
Check to see if the given MIME type is one that would be supported as content coming into this node.- Specified by:
checkValidContentType
in interfaceVRMLSingleExternalNodeType
- Parameters:
mimetype
- The type to check for- Returns:
- true if this is OK, false if not
-
setLoadedURI
Notify the node which URL was used to load the content. It will be the complete URI with path, query and references parts. This method will be called before setContent.- Specified by:
setLoadedURI
in interfaceVRMLSingleExternalNodeType
- Parameters:
URI
- The URI used to load this content
-
setContent
Set the content of this node to the given object. The object is then cast by the internal representation to the form it needs. This assumes at least some amount of intelligence on the part of the caller, but we also know that we should not pass something dumb to it when we can check what sort of content types it likes to handle. We assume the loader thread is operating in the same context as the one that created the node in the first place and thus knows the general types of items to pass through.- Specified by:
setContent
in interfaceVRMLSingleExternalNodeType
- Parameters:
mimetype
- The mime type of this object if knowncontent
- The content of the object- Throws:
IllegalArgumentException
- The content object is not supported
-
setWorldUrl
Set the world URL so that any relative URLs may be corrected to the fully qualified version. Guaranteed to be non-null.- Specified by:
setWorldUrl
in interfaceVRMLExternalNodeType
- Parameters:
url
- The world URL.
-
getWorldUrl
Get the world URL so set for this node.- Specified by:
getWorldUrl
in interfaceVRMLExternalNodeType
- Returns:
- url The world URL.
-
addUrlListener
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.- Specified by:
addUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
listener
- The listener instance to add
-
removeUrlListener
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
listener
- The listener to be removed
-
setVRMLClock
Set the vrmlClock that this time dependent node will be running with.- Specified by:
setVRMLClock
in interfaceVRMLTimeDependentNodeType
- Overrides:
setVRMLClock
in classBaseTimeDependentNode
- Parameters:
clk
- The vrmlClock to use for this node
-
setLoop
public void setLoop(boolean loop) Set the loop variable. Override the base class. TODO: Need to commonize timer handling, this is not exactly right.- Specified by:
setLoop
in interfaceVRMLTimeControlledNodeType
- Overrides:
setLoop
in classBaseTimeControlledNode
- Parameters:
loop
-
-
getDescription
Accessor method to get current value of field description- Specified by:
getDescription
in interfaceVRMLAudioClipNodeType
- Returns:
- The description
-
getPitch
public float getPitch()Accessor method to get current value of field pitch, default value is1
.- Specified by:
getPitch
in interfaceVRMLAudioClipNodeType
- Returns:
- The Pitch
-
getDuration
public double getDuration()Accessor method to get current value of field duration- Specified by:
getDuration
in interfaceVRMLAudioClipNodeType
- Returns:
- The duration
-
getIsActive
public boolean getIsActive()Accessor method to get current value of field isActive- Specified by:
getIsActive
in interfaceVRMLAudioClipNodeType
- Returns:
- The value of isActive
-
timeClick
public void timeClick(long time) Notification that the time is now this value.- Specified by:
timeClick
in interfaceVRMLTimeListener
- Parameters:
time
- The current time
-