29 #ifndef __X3DSOUNDSOURCENODE_H__
30 #define __X3DSOUNDSOURCENODE_H__
41 #include <OpenAL/al.h>
42 #include <OpenAL/alc.h>
49 #define NR_STREAM_BUFFERS 3
50 #define STREAM_BUFFER_SIZE (4096*8)
70 virtual void update();
73 friend class TimeHandler;
91 event_fields.insert( e.
ptr );
98 return event_fields.find( f ) != event_fields.end();
103 template<
class FieldType >
105 return hasCausedEvent( f.get() );
117 Inst< SFString > _description = 0,
118 Inst< SFBool > _loop = 0,
119 Inst< SFTime > _pauseTime = 0,
120 Inst< SFFloat > _pitch = 0,
121 Inst< SFTime > _resumeTime = 0,
122 Inst< StartTime > _startTime = 0,
123 Inst< StopTime > _stopTime = 0,
124 Inst< SFTime > _duration_changed = 0,
125 Inst< SFTime > _elapsedTime = 0,
126 Inst< SFBool > _isActive = 0,
127 Inst< SFBool > _isPaused = 0,
128 Inst< TimeHandler > _timeHandler = 0 );
135 virtual bool initALBuffers(
bool stream );
138 virtual void ALrender();
155 virtual void onPause();
158 virtual void onResume();
161 virtual void onStart();
164 virtual void onStop();
200 ALuint al_buffers[NR_STREAM_BUFFERS];
Header file for H3DSoundStreamNode, X3D scene-graph node.
Header file for PeriodicUpdate, template field modifier.
Header file for X3DSoundNode, X3D scene-graph node.
Header file for X3DTimeDependentNode, X3D scene-graph node.
The Field class.
Definition: Field.h:46
virtual void propagateEvent(Event e)
Propagates an event to all Fields we are routed to.
Definition: Field.cpp:367
The PeriodicUpdate is a template modifier that changes the way the field is updated.
Definition: PeriodicUpdate.h:74
This abstract node type is the base for all Sound nodes.
Definition: X3DSoundNode.h:48
Field that calls ALrender() when a field routed to it has generated an event.
Definition: X3DSoundSourceNode.h:79
bool hasCausedEvent(H3DUniquePtr< FieldType > &f)
Returns true if the Field given has generated an event to this field since the last call to the updat...
Definition: X3DSoundSourceNode.h:104
set< Field * > event_fields
The fields that has generated an event since the last call to update()
Definition: X3DSoundSourceNode.h:111
virtual void propagateEvent(Event e)
When the event is propagated the display list is invalidated.
Definition: X3DSoundSourceNode.h:89
bool hasCausedEvent(Field *f)
Returns true if the Field given has generated an event to this field since the last call to the updat...
Definition: X3DSoundSourceNode.h:97
virtual void update()
This function will be called to update the field if it has a pending event when the upToDate() functi...
Definition: X3DSoundSourceNode.h:81
TimeHandler is extended to stream audio data to OpenAL buffers if the sound source is a streaming sou...
Definition: X3DSoundSourceNode.h:65
TimeHandler()
Constructor.
Definition: X3DSoundSourceNode.h:68
This abstract node type is used to derive node types that can emit audio data.
Definition: X3DSoundSourceNode.h:61
H3DUniquePtr< ALSoundBuffer > soundBuffer
Field that calls ALrender() when a field routed to it has generated an event.
Definition: X3DSoundSourceNode.h:214
AutoRef< H3DSoundStreamNode > reader
The H3DSoundStreamNode used to read sound data.
Definition: X3DSoundSourceNode.h:207
virtual void ALrender()
Perform the OpenAL calls to render the sound.
Definition: X3DSoundSourceNode.cpp:302
bool sound_as_stream
Indicates if the current sounds source is being streamed or not.
Definition: X3DSoundSourceNode.h:210
list< X3DSoundNode * > parent_sound_nodes
The X3DSoundNodes that use this node as sound source.
Definition: X3DSoundSourceNode.h:196
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....
Definition: X3DSoundSourceNode.h:190
ALenum al_format
The OpenAL format of the current sound source.
Definition: X3DSoundSourceNode.h:203
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: X3DSoundSourceNode.h:193
H3DUniquePtr< SFString > description
The description field specifies a textual description of the audio source.
Definition: X3DSoundSourceNode.h:172
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: X3DSoundSourceNode.h:142
H3DUniquePtr< SFFloat > pitch
The pitch field specifies a multiplier for the rate at which sampled sound is played.
Definition: X3DSoundSourceNode.h:182
The TimeHandler field updates once per scene-graph loop to monitor the current time and updates the f...
Definition: X3DTimeDependentNode.h:50
This abstract node type is the base node type from which all time-dependent nodes are derived.
Definition: X3DTimeDependentNode.h:41
H3D API namespace.
Definition: Anchor.h:38
The Event struct encapsulates an event in the field network.
Definition: Field.h:75
Field * ptr
The Field that caused the event.
Definition: Field.h:84
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194