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 StringexposedField SFString description ""protected doubleduration of most recently loaded clipprotected booleaneventOut SFBool isActiveprotected booleaneventOut SFBool isPausedprotected floatexposedField 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, vfStopTimeFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTimeDependentNode
vrmlClockFields 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, vrmlMinorVersionFields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener to this node instance for the content state changes.voidaddSoundStateListener(VRMLSoundStateListener listener) Add a listener to this node instance.voidaddUrlListener(VRMLUrlListener listener) Add a listener to this node instance.voidNotification that the rendering of the event model is complete and that rendering is about to begin.booleancheckValidContentType(String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node.voidcopy(VRMLNodeType node) Copies all of the field values from the passed nodes into our own node.protected voidSend a notification to the registered listeners that the content state has been changed.protected voidSend a notification to the registered listeners that a field has been changed.protected voidfireUrlChanged(int index) Send a notification to the registered listeners that a field has been changed.Accessor method to get current value of field descriptiondoubleAccessor method to get current value of field durationgetFieldDeclaration(int index) Get the declaration of the field at the given index.intgetFieldIndex(String fieldName) Get the index of the given field name.getFieldValue(int index) Get the value of a field.booleanAccessor method to get current value of field isActiveintAsk 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).intGet the number of fields.floatgetPitch()Accessor method to get current value of field pitch, default value is1.intGet 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.voidRemove a listener from this node instance for the content state changes.voidRemove a listener from this node instance.voidremoveUrlListener(VRMLUrlListener listener) Remove a listener from this node instance.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetContent(String mimetype, Object content) Set the content of this node to the given object.voidsetDescription(String newDescription) Set a new description string for this node.voidsetDuration(double newDuration) Accessor method to set a new value for field attribute durationvoidsetIsActive(boolean newIsActive) Set a new value for isActive.voidsetLoadedURI(String URI) Notify the node which URL was used to load the content.voidsetLoadState(int state) Set the load state of the node.voidsetLoop(boolean loop) Set the loop variable.voidsetPitch(float newPitch) Sets a new value for this node's pitch.voidsetStartTime(double newStartTime) Set a new value for the start time.voidsetStopTime(double newStopTime) Set a new value for the stop time.voidSets the URL to a new value.voidsetValue(int index, float value) Set the value of the field at the given index as a float.voidSet the value of the field at the given index as a string.voidSet the value of the field at the given index as an array of strings.voidsetVRMLClock(VRMLClock clk) Set the vrmlClock that this time dependent node will be running with.voidsetWorldUrl(String url) Set the world URL so that any relative URLs may be corrected to the fully qualified version.voidtimeClick(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, setValueMethods 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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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, updateRefCountMethods 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:
setStartTimein interfaceVRMLTimeControlledNodeType- Overrides:
setStartTimein 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:
setStopTimein interfaceVRMLTimeControlledNodeType- Overrides:
setStopTimein classBaseTimeControlledNode- Parameters:
newStopTime- The new stop time
-
setDescription
Set a new description string for this node.- Specified by:
setDescriptionin 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:
setIsActivein 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:
setPitchin interfaceVRMLAudioClipNodeType- Parameters:
newPitch- New value for pitch.- Throws:
InvalidFieldValueException- Pitch is <= 0
-
setDuration
public void setDuration(double newDuration) Description copied from interface:VRMLAudioClipNodeTypeAccessor method to set a new value for field attribute duration- Specified by:
setDurationin 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:
addContentStateListenerin 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:
removeContentStateListenerin 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:
getFieldIndexin 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:
getPrimaryTypein 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:
getSecondaryTypein interfaceVRMLNode- Overrides:
getSecondaryTypein 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:
getNodeFieldIndicesin 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:
getFieldDeclarationin 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:
getNumFieldsin 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
allEventsCompletein interfaceFrameStateListener- Overrides:
allEventsCompletein 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:
getLoadStatein 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:
setLoadStatein 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:
setUrlin interfaceVRMLAudioClipNodeType- Specified by:
setUrlin 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:
getUrlin interfaceVRMLAudioClipNodeType- Specified by:
getUrlin 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:
checkValidContentTypein 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:
setLoadedURIin 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:
setContentin 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:
setWorldUrlin interfaceVRMLExternalNodeType- Parameters:
url- The world URL.
-
getWorldUrl
Get the world URL so set for this node.- Specified by:
getWorldUrlin 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:
addUrlListenerin 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:
removeUrlListenerin interfaceVRMLExternalNodeType- Parameters:
listener- The listener to be removed
-
setVRMLClock
Set the vrmlClock that this time dependent node will be running with.- Specified by:
setVRMLClockin interfaceVRMLTimeDependentNodeType- Overrides:
setVRMLClockin 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:
setLoopin interfaceVRMLTimeControlledNodeType- Overrides:
setLoopin classBaseTimeControlledNode- Parameters:
loop-
-
getDescription
Accessor method to get current value of field description- Specified by:
getDescriptionin interfaceVRMLAudioClipNodeType- Returns:
- The description
-
getPitch
public float getPitch()Accessor method to get current value of field pitch, default value is1.- Specified by:
getPitchin interfaceVRMLAudioClipNodeType- Returns:
- The Pitch
-
getDuration
public double getDuration()Accessor method to get current value of field duration- Specified by:
getDurationin interfaceVRMLAudioClipNodeType- Returns:
- The duration
-
getIsActive
public boolean getIsActive()Accessor method to get current value of field isActive- Specified by:
getIsActivein interfaceVRMLAudioClipNodeType- Returns:
- The value of isActive
-
timeClick
public void timeClick(long time) Notification that the time is now this value.- Specified by:
timeClickin interfaceVRMLTimeListener- Parameters:
time- The current time
-