H3D API
2.4.1
|
An AudioClip node specifies audio data that can be referenced by Sound nodes. More...
#include <H3D/AudioClip.h>
Public Member Functions | |
AudioClip (Inst< SFString > _description=0, Inst< SFBool > _loop=0, Inst< SFNode > _metadata=0, Inst< SFTime > _pauseTime=0, Inst< SFFloat > _pitch=0, Inst< SFTime > _resumeTime=0, Inst< StartTime > _startTime=0, Inst< StopTime > _stopTime=0, Inst< MFString > _url=0, Inst< SFTime > _duration_changed=0, Inst< SFTime > _elapsedTime=0, Inst< SFBool > _isActive=0, Inst< SFBool > _isPaused=0, Inst< TimeHandler > _time_handler=0) | |
Constructor. | |
virtual void | ALrender () |
Perform the OpenAL calls to render the audio clip. | |
![]() | |
X3DSoundSourceNode (Inst< SFNode > _metadata=0, Inst< SFString > _description=0, Inst< SFBool > _loop=0, Inst< SFTime > _pauseTime=0, Inst< SFFloat > _pitch=0, Inst< SFTime > _resumeTime=0, Inst< StartTime > _startTime=0, Inst< StopTime > _stopTime=0, Inst< SFTime > _duration_changed=0, Inst< SFTime > _elapsedTime=0, Inst< SFBool > _isActive=0, Inst< SFBool > _isPaused=0, Inst< TimeHandler > _timeHandler=0) | |
Constructor. | |
virtual bool | initALBuffers (bool stream) |
Reads new data into the OpenAL from the reader and attaches them to the sound sources that use this sound source. More... | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
virtual void | registerSoundNode (X3DSoundNode *n) |
Register this sound node with the X3DSoundSourceNode. More... | |
virtual void | unregisterSoundNode (X3DSoundNode *n) |
Unregister this sound node with the X3DSoundSourceNode. | |
virtual void | onPause () |
On pause, pause the sound. | |
virtual void | onResume () |
On resume, resume paused sound. | |
virtual void | onStart () |
On start, initialize AL buffers and start playing. | |
virtual void | onStop () |
On stop, stop playing the sound. | |
![]() | |
X3DTimeDependentNode (Inst< SFNode > _metadata=0, Inst< SFBool > _loop=0, Inst< SFTime > _pauseTime=0, Inst< SFTime > _resumeTime=0, Inst< StartTime > _startTime=0, Inst< StopTime > _stopTime=0, Inst< SFTime > _elapsedTime=0, Inst< SFBool > _isActive=0, Inst< SFBool > _isPaused=0, Inst< TimeHandler > _timeHandler=0) | |
Constructor. | |
virtual void | initialize () |
Activates the node if the conditions for a time node to be active from the start are met. More... | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual void | render () |
the render() function is used for the depth-first rendering traversal of the scene-graph. More... | |
virtual void | traverseSG (TraverseInfo &ti) |
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More... | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the Node. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on Node to p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the Node. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
![]() | |
X3DUrlObject (Inst< MFString > _url=0) | |
Constructor. | |
virtual LoadStatus | loadStatus () |
The loadStatus function returns the status of the loading of the current urls in order to be used with the LoadSensor node. | |
virtual H3DFloat | loadProgress () |
The loadProgress() functions returns a value between 0 and 1 indicating how much of the current url has been loaded. More... | |
void | setURLUsed (const string &_url_used) |
Set the url that is currently loaded. | |
const string & | getURLUsed () |
Get the url that is currently loaded. | |
void | setURLBase (const string &_url_base) |
Set the url base address. | |
const string & | getURLBase () |
Get the current url base address. | |
string | resolveURLAsFile (const string &url, bool *is_tmp_file=NULL) |
Get the url as a local file. | |
string | resolveURLAsString (const string &url) |
Get the content of the URL as a string. | |
bool | removeTmpFile (const string &file) |
Remove a tmpfile with the given name. More... | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
enum | LoadStatus { INIT , LOADED , LOADING , FAILED } |
The load status of the given url. More... | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
![]() | |
H3DUniquePtr< SFString > | description |
The description field specifies a textual description of the audio source. More... | |
H3DUniquePtr< SFFloat > | pitch |
The pitch field specifies a multiplier for the rate at which sampled sound is played. More... | |
H3DUniquePtr< SFTime > | duration_changed |
The duration field is the length of time in seconds for one cycle of the audio for a pitch set to 1.0. More... | |
![]() | |
H3DUniquePtr< SFBool > | loop |
If loop is TRUE at the end of a cycle, execution continues into the next cycle, otherwise it stops. More... | |
H3DUniquePtr< SFTime > | pauseTime |
A time at which to pause and stop generating events. More... | |
H3DUniquePtr< SFTime > | resumeTime |
A time at which to start generating events again after being paused. More... | |
H3DUniquePtr< StartTime > | startTime |
A time-dependent node is inactive until its startTime is reached. More... | |
H3DUniquePtr< StopTime > | stopTime |
An active time-dependent node will become inactive when stopTime is reached if stopTime > startTime. More... | |
H3DUniquePtr< SFTime > | elapsedTime |
The elapsedTime outputOnly field delivers the current elapsed time since the X3DTimeDependentNode was activated and running, cumulative in seconds and not counting any time while in a paused state. More... | |
H3DUniquePtr< SFBool > | isActive |
An isActive TRUE event is generated when the node becomes active and an isActive FALSE event is generated when it becomes inactive. More... | |
H3DUniquePtr< SFBool > | isPaused |
An isPaused TRUE event is generated when the node becomes paused and an isPaused FALSE event is generated when it is resumed. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< MFString > | url |
The urls in decreasing order of preference. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
string | resolveURL (const string &_url, bool return_contents, bool *is_tmp_file=NULL) |
Helper function for resolveURLAs*() functions. | |
void | addInlinePrefix (const string &s) |
Add a inline prefix that this node supports. | |
int | getInlinedContentOffset (const std::string &url) |
If the URL contains any inline prefix, return the index of the start of the inlined content. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
![]() | |
list< X3DSoundNode * > | parent_sound_nodes |
The X3DSoundNodes that use this node as sound source. | |
ALuint | al_buffers [NR_STREAM_BUFFERS] |
OpenAL buffer ids used for playing sound. | |
ALenum | al_format |
The OpenAL format of the current sound source. | |
AutoRef< H3DSoundStreamNode > | reader |
The H3DSoundStreamNode used to read sound data. | |
bool | sound_as_stream |
Indicates if the current sounds source is being streamed or not. | |
H3DUniquePtr< ALSoundBuffer > | soundBuffer |
Field that calls ALrender() when a field routed to it has generated an event. | |
![]() | |
string | url_used |
If loadStatus() returns LOADED this string should contain the url that is loaded. More... | |
string | url_base |
The base URL for urls in this url object. More... | |
list< string > | supported_inline_prefixes |
A list of inline prefixes that are supported by this url object. More... | |
An AudioClip node specifies audio data that can be referenced by Sound nodes.
The description field specifies a textual description of the audio source. A browser is not required to display the description field but may choose to do so in addition to playing the sound.
The url field specifies the URL from which the sound is loaded.
The loop, pauseTime, resumeTime, startTime, and stopTime inputOutput fields and the elapsedTime, isActive, and isPaused outputOnly fields, and their effects on the AudioClip node, are discussed in detail in 8 Time component. The "cycle" of an AudioClip is the length of time in seconds for one playing of the audio at the specified pitch.
The pitch field specifies a multiplier for the rate at which sampled sound is played. Values for the pitch field shall be greater than zero. Changing the pitch field affects both the pitch and playback speed of a sound. A set_pitch event to an active AudioClip is ignored and no pitch_changed field is generated. If pitch is set to 2.0, the sound shall be played one octave higher than normal and played twice as fast. For a sampled sound, the pitch field alters the sampling rate at which the sound is played.
A duration_changed event is sent whenever there is a new value for the "normal" duration of the clip. Typically, this will only occur when the current url in use changes and the sound data has been loaded, indicating that the clip is playing a different sound source. The duration is the length of time in seconds for one cycle of the audio for a pitch set to 1.0. Changing the pitch field will not trigger a duration_changed event. A duration value of "-1" implies that the sound data has not yet loaded or the value is unavailable for some reason. A duration_changed event shall be generated if the AudioClip node is loaded when the X3D file is read or the AudioClip node is added to the scene graph.
The isActive field may be used by other nodes to determine if the clip is currently active. If an AudioClip is active, it shall be playing the sound corresponding to the sound time (i.e., in the sound's local time system with sample 0 at time 0):
t = (now - startTime) modulo (duration / pitch)
Examples: