00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VRS_SOUND_SOURCEAL_H
00019 #define VRS_SOUND_SOURCEAL_H
00020
00021
00022
00023
00024 #include <vrs/vector.h>
00025 #include <vrs/polyattribute.h>
00026 #include <vrs/container/iterator.h>
00027 #include <vrs/container/array.h>
00028 #include <vrs/sg/scenething.h>
00029
00030
00031
00032
00033 #include <vrs/openal/bufferal.h>
00034
00035
00036
00037
00038 #include <limits>
00039
00040
00041 namespace VRS
00042 {
00043 namespace SOUND
00044 {
00045 class VRS_OPENAL_API SourceAL : public PolyAttribute
00046 {
00047 public:
00048
00049 enum SourceType
00050 {
00051 UNDETERMINED = AL_UNDETERMINED,
00052 STATIC = AL_STATIC,
00053 STREAMING = AL_STREAMING
00054
00055 };
00056 VRS_SERIALIZABLE_CLASS_ENUM(SourceType);
00057
00058
00059 enum SourceState
00060 {
00061 INITIAL = AL_INITIAL,
00062 PLAYING = AL_PLAYING,
00063 PAUSED = AL_PAUSED,
00064 STOPPED = AL_STOPPED
00065
00066 };
00067 VRS_SERIALIZABLE_CLASS_ENUM(SourceState);
00068
00069 SourceAL(const Vector& position = Vector::origin,
00070 const Vector& velocity = Vector::origin,
00071 const Vector& direction = Vector::origin,
00072 bool relativeMode = false,
00073 bool loopMode = false,
00074 float gain = 1.0f,
00075 float gainMax = 1.0f,
00076 float gainMin = 0.0f,
00077 float innerConeAngle = 360.0f,
00078 float outerConeAngle = 360.0f,
00079 float coneOuterGain = 0.0f,
00080 float pitch = 1.0f,
00081 float referenceDistance = 1.0f,
00082 float maxDistance = std::numeric_limits<float>::max(),
00083 float rollOffFactor = 1.0f,
00084 bool enabled = true);
00085
00086 SourceAL(const SO<BufferAL>& buffer,
00087 const Vector& position = Vector::origin,
00088 const Vector& velocity = Vector::origin,
00089 const Vector& direction = Vector::origin,
00090 bool relativeMode = false,
00091 bool loopMode = false,
00092 float gain = 1.0f,
00093 float gainMax = 1.0f,
00094 float gainMin = 0.0f,
00095 float innerConeAngle = 360.0f,
00096 float outerConeAngle = 360.0f,
00097 float coneOuterGain = 0.0f,
00098 float pitch = 1.0f,
00099 float referenceDistance = 1.0f,
00100 float maxDistance = std::numeric_limits<float>::max(),
00101 float rollOffFactor = 1.0f,
00102 bool enabled = true);
00103
00104 SourceAL(const SO<Iterator<SO<BufferAL> > >& buffers,
00105 const Vector& position = Vector::origin,
00106 const Vector& velocity = Vector::origin,
00107 const Vector& direction = Vector::origin,
00108 bool relativeMode = false,
00109 bool loopMode = false,
00110 float gain = 1.0f,
00111 float gainMax = 1.0f,
00112 float gainMin = 0.0f,
00113 float innerConeAngle = 360.0f,
00114 float outerConeAngle = 360.0f,
00115 float coneOuterGain = 0.0f,
00116 float pitch = 1.0f,
00117 float referenceDistance = 1.0f,
00118 float maxDistance = std::numeric_limits<float>::max(),
00119 float rollOffFactor = 1.0f,
00120 bool enabled = true);
00121
00122 SourceAL(const SO<BufferAL>& buffer,
00123 const SO<SceneThing>& sceneThing,
00124 const Vector& velocity = Vector::origin,
00125 const Vector& direction = Vector::origin,
00126 bool relativeMode = false,
00127 bool loopMode = false,
00128 float gain = 1.0f,
00129 float gainMax = 1.0f,
00130 float gainMin = 0.0f,
00131 float innerConeAngle = 360.0f,
00132 float outerConeAngle = 360.0f,
00133 float coneOuterGain = 0.0f,
00134 float pitch = 1.0f,
00135 float referenceDistance = 1.0f,
00136 float maxDistance = std::numeric_limits<float>::max(),
00137 float rollOffFactor = 1.0f,
00138 bool enabled = true);
00139
00140 SourceAL(const SO<Iterator<SO<BufferAL> > >& buffers,
00141 const SO<SceneThing>& sceneThing,
00142 const Vector& velocity = Vector::origin,
00143 const Vector& direction = Vector::origin,
00144 bool relativeMode = false,
00145 bool loopMode = false,
00146 float gain = 1.0f,
00147 float gainMax = 1.0f,
00148 float gainMin = 0.0f,
00149 float innerConeAngle = 360.0f,
00150 float outerConeAngle = 360.0f,
00151 float coneOuterGain = 0.0f,
00152 float pitch = 1.0f,
00153 float referenceDistance = 1.0f,
00154 float maxDistance = std::numeric_limits<float>::max(),
00155 float rollOffFactor = 1.0f,
00156 bool enabled = true);
00157
00158 ~SourceAL(void);
00159
00160 void setSceneThing(const SO<SceneThing>& sceneThing);
00161 inline SO<SceneThing> getSceneThing(void) const
00162 {
00163 return this->sceneThing_;
00164 }
00165
00166 void attachBuffer(const SO<BufferAL>& buffer);
00167
00168 void queueBuffer(const SO<BufferAL>& buffer);
00169 SO<BufferAL> unqueueBuffer(void);
00170
00180 void queueBuffers(const SO<Iterator<SO<BufferAL> > >& buffers);
00181
00182
00196 SO<Iterator<SO<BufferAL> > > unqueueBuffers(void);
00197 void unqueueAllBuffers(void);
00198
00199 unsigned int getQueuedBuffers(void) const;
00200 unsigned int getProcessedBuffers(void) const;
00201
00203 void play(void);
00204 bool isPlaying(void) const;
00205
00206 void stop(void);
00207 bool isStopped(void) const;
00208
00209 void pause(void);
00210 bool isPaused(void) const;
00211
00212 void rewind(void);
00213 bool isInitial(void) const;
00214
00225 void setPosition(const VRS::Vector& position);
00226 inline const Vector& getPosition(void) const
00227 {
00228 return this->position_;
00229 }
00230
00240 void setVelocity(const VRS::Vector& velocity);
00241 inline const Vector& getVelocity(void) const
00242 {
00243 return this->velocity_;
00244 }
00245
00254 void setDirection(const VRS::Vector& direction);
00255 inline const Vector& getDirection(void) const
00256 {
00257 return this->direction_;
00258 }
00259
00260
00269 void setGain(float gain);
00270 inline float getGain(void) const
00271 {
00272 return this->gain_;
00273 }
00274
00283 void setGainMin(float gainMin);
00284 inline float getGainMin(void) const
00285 {
00286 return this->gainMin_;
00287 }
00288
00297 void setGainMax(float gainMax);
00298 inline float getGainMax(void) const
00299 {
00300 return this->gainMax_;
00301 }
00302
00310 void setConeOuterGain(float coneOuterGain);
00311 inline float getConeOuterGain(void) const
00312 {
00313 return this->coneOuterGain_;
00314 }
00315
00320 void setReferenceDistance(float referenceDistance);
00321 inline float getReferenceDistance(void) const
00322 {
00323 return this->referenceDistance_;
00324 }
00325
00333 void setMaxDistance(float maxDistance);
00334 inline float getMaxDistance(void) const
00335 {
00336 return this->maxDistance_;
00337 }
00338
00347 void setRollOffFactor(float rollOffFactor);
00348 inline float getRollOffFactor(void) const
00349 {
00350 return this->rollOffFactor_;
00351 }
00352
00357 void setPitch(float pitch);
00358 inline float getPitch(void) const
00359 {
00360 return this->pitch_;
00361 }
00362
00366 void setInnerConeAngle(float innerConeAngle);
00367 inline float getInnerConeAngle(void) const
00368 {
00369 return this->innerConeAngle_;
00370 }
00371
00376 void setOuterConeAngle(float outerConeAngle);
00377 inline float getOuterConeAngle(void) const
00378 {
00379 return this->outerConeAngle_;
00380 }
00381
00385 void setRelativeMode(bool relativeMode);
00386 inline bool getRelativeMode(void) const
00387 {
00388 return this->relativeMode_;
00389 }
00390
00397 void setLoopMode(bool loopMode);
00398 inline bool getLoopMode(void) const
00399 {
00400 return this->loopMode_;
00401 }
00402
00419 void setSecondOffset(float secondOffset);
00420 inline float getSecondOffset(void) const
00421 {
00422 return this->secondOffset_;
00423 }
00424
00440 void setSampleOffset(float sampleOffset);
00441 inline float getSampleOffset(void) const
00442 {
00443 return this->sampleOffset_;
00444 }
00445
00461 void setByteOffset(float byteOffset);
00462 inline float getByteOffset(void) const
00463 {
00464 return this->byteOffset_;
00465 }
00466
00475 SourceType getSourceType(void) const;
00476
00488 SourceState getSourceState(void) const;
00489
00491 bool isValid(void) const;
00492
00493 inline unsigned int getName(void) const
00494 {
00495 return this->name_;
00496 }
00497
00498 VRS_TYPEINFO(SourceAL, PolyAttribute);
00499 VRS_SERIALIZABLE(SourceAL);
00500
00501 private:
00502
00503 SO<BufferAL> findAndUnqueueBuffer(unsigned int name);
00504
00505 SO<SceneThing> sceneThing_;
00506 SO<BufferAL> buffer_;
00507 SO<NonPersistentArray<SO<BufferAL> > > queuedBuffers_;
00508
00509 Vector position_;
00510 Vector velocity_;
00511 Vector direction_;
00512
00513 bool relativeMode_;
00514 bool loopMode_;
00515
00516 float innerConeAngle_;
00517 float outerConeAngle_;
00518 float coneOuterGain_;
00519
00520 float gain_;
00521 float gainMax_;
00522 float gainMin_;
00523
00524 float pitch_;
00525
00526 float referenceDistance_;
00527 float maxDistance_;
00528 float rollOffFactor_;
00529
00530 float secondOffset_;
00531 float sampleOffset_;
00532 float byteOffset_;
00533
00534 unsigned int name_;
00535
00536 };
00537
00538 };
00539
00540 };
00541
00542 #endif //VRS_SOUND_SOURCEAL_H