00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _SO_VRMLSOUND_
00050 #define _SO_VRMLSOUND_
00051
00052 #include <Inventor/fields/SoSFVec3f.h>
00053 #include <Inventor/fields/SoSFFloat.h>
00054 #include <Inventor/fields/SoSFTime.h>
00055 #include <Inventor/fields/SoSFEnum.h>
00056 #include <Inventor/fields/SoSFBool.h>
00057 #include <Inventor/fields/SoMFString.h>
00058 #include <Inventor/nodes/SoNode.h>
00059 #include <Inventor/fields/SoSFNode.h>
00060 #include <Inventor/VRMLnodes/SoVRMLNode.h>
00061
00062
00063 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00064 #include <SoDeprecationRules.h>
00065 #pragma push_macro("SoDEPRECATED_CLASS")
00066 #pragma push_macro("SoDEPRECATED_TYPEDEF")
00067 #undef SoDEPRECATED_CLASS
00068 #undef SoDEPRECATED_TYPEDEF
00069 #define SoDEPRECATED_CLASS(x,y)
00070 #define SoDEPRECATED_TYPEDEF(x,y)
00071 #endif
00072
00073 #ifdef _WIN32
00074 class SoSensor;
00075 class SoFieldSensor;
00076 class SoTimerSensor;
00077 class SoWavDecoder;
00078 class SoSoundDecoder;
00079 class SoVRMLSound;
00080 class SoSFNode;
00081 class SoSoundSpatializer;
00082 class SoVRMLAudioClip ;
00083 enum SoSoundType ;
00084
00085 #endif
00086 #ifdef SO_MPEG_DECODER
00087 #define MPEG_NUM_BUFFERS 5 // Number of buffers for MPEG streaming
00088
00089 #endif
00090 class SoDEPRECATED SoVRMLSound : public SoVRMLNode {
00332
00333 SO_NODE_HEADER(SoVRMLSound);
00334
00335 public:
00336
00337
00342 SoSFNode source;
00343
00344
00349 SoSFFloat intensity;
00350
00356 SoSFFloat priority;
00357
00362 SoSFVec3f location;
00363
00368 SoSFVec3f direction;
00380 SoSFFloat minFront;
00381
00383
00394 SoSFFloat maxFront;
00395 SoSFFloat minBack;
00396 SoSFFloat maxBack;
00398
00404 SoSFBool spatialize;
00405
00416 SoSFFloat dopplerFactor ;
00417
00428 SoSFFloat dopplerVelocity ;
00429
00433 SoVRMLSound();
00434
00435
00436
00437 private:
00438 virtual void GLRender(SoGLRenderAction *action);
00439
00440
00441
00442 private:
00443 static void initClass();
00444 static void exitClass();
00445 #ifdef _WIN32
00446 void setSoundSpatializer(SoSoundSpatializer * ss);
00447
00448 #endif
00449 private:
00450 virtual ~SoVRMLSound();
00451
00452 private:
00453 #ifdef _WIN32
00454
00455 static void grabCB(void *, SoSensor *);
00456 static void sourceChangedCB(void *, SoSensor *);
00457 static void dopplerFactorChangedCB(void *, SoSensor *);
00458 static void dopplerVelocityChangedCB(void *, SoSensor *);
00459 static void intensityChangedCB(void *, SoSensor *);
00460 static void soundBufferChangedCB(void *data, SoSensor *);
00461 static void computeDopplerEffectCB(void *data, SoSensor *);
00462
00463
00464 static void startChangedCB(void *data, SoSensor *);
00465 static void stopChangedCB(void *data, SoSensor *);
00466 static void startSoundCB(void *data, SoSensor *);
00467 static void stopSoundCB(void *data, SoSensor *);
00468 static void pitchChangedCB(void *, SoSensor *);
00469 static void filenameChangedCB(void *, SoSensor *);
00470 static void loopChangedCB(void *, SoSensor *);
00471
00472
00473 void configStartTimeSensor(SoVRMLAudioClip *audioClip) ;
00474 void configStopTimeSensor(SoVRMLAudioClip *audioClip) ;
00475
00476 SoSoundType checkFileType();
00477 bool openSound();
00478 void closeSound(bool close_file=false);
00479 SbBool initSoundSource();
00480
00481
00482 SoSoundDecoder *m_soundDecoder ;
00483
00484 SoFieldSensor *m_sourceChangedSensor;
00485 SoFieldSensor *m_soundBufferChangedSensor;
00486 SoFieldSensor *m_dopplerFactorChangedSensor ;
00487 SoFieldSensor *m_dopplerVelocityChangedSensor ;
00488 SoFieldSensor *m_intensityChangedSensor;
00489
00490
00491 SoFieldSensor *m_pitchChangedSensor;
00492 SoFieldSensor *m_startChangedSensor;
00493 SoFieldSensor *m_stopChangedSensor;
00494 SoFieldSensor *m_loopChangedSensor;
00495 SoFieldSensor *m_filenameSensor;
00496
00497 SoAlarmSensor *m_startSensor;
00498 SoAlarmSensor *m_stopSensor;
00499 SoTimerSensor *m_grabSensor;
00500 SoTimerSensor *m_dopplerEffectSensor;
00501
00502 bool m_loop;
00503 float m_pitch;
00504
00505 bool m_isEndDecodingSound;
00506 bool m_isCorrectAudioClipFile ;
00507
00508 bool m_shouldPlaySound;
00509 bool m_isSoundOpened;
00510 bool m_isEndPlayingSound;
00511 bool m_isRenderedOnce;
00512
00513
00514
00515 int m_soundBufferQueue ;
00516 int m_numSoundBuffersInQueue;
00517
00518 SoSoundType m_soundType;
00519 SbString m_audioClipURL;
00520 int m_numSoundBuffers ;
00521 SoSoundSpatializer *m_soundSpatializer;
00522
00523 SoType m_currentSourceType;
00524
00525
00526
00527 double m_prevRenderTime;
00528 SbVec3f m_prevListenerPos;
00529 SbVec3f m_prevSourcePos;
00530 #endif // _WIN32
00531 };
00532
00533
00534
00535 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00536 #pragma pop_macro("SoDEPRECATED_TYPEDEF")
00537 #pragma pop_macro("SoDEPRECATED_CLASS")
00538 #endif
00539
00540 #endif
00541