00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef _SG_SOUND_HXX
00030 #define _SG_SOUND_HXX 1
00031
00032 #ifndef __cplusplus
00033 # error This library requires C++
00034 #endif
00035
00036 #include <vector>
00037
00038 #include <simgear/compiler.h>
00039 #include <simgear/props/condition.hxx>
00040
00041 #include "sample_group.hxx"
00042 #include "sample_openal.hxx"
00043
00044 static const double MAX_TRANSIT_TIME = 0.1;
00045
00046
00055 class SGXmlSound
00056 {
00057
00058 public:
00059
00060 SGXmlSound();
00061 virtual ~SGXmlSound();
00062
00106 virtual void init (SGPropertyNode *, SGPropertyNode *, SGSampleGroup *,
00107 SGSampleGroup *, const string &);
00108
00112 virtual void update (double dt);
00113
00117 void stop();
00118
00119 protected:
00120
00121 enum { MAXPROP=5 };
00122 enum { ONCE=0, LOOPED, IN_TRANSIT };
00123 enum { LEVEL=0, INVERTED, FLIPFLOP };
00124
00125
00126 typedef struct {
00127 SGPropertyNode_ptr prop;
00128 double (*fn)(double);
00129 double *intern;
00130 double factor;
00131 double offset;
00132 double min;
00133 double max;
00134 bool subtract;
00135 } _snd_prop;
00136
00137 private:
00138
00139 SGSampleGroup * _sgrp;
00140 SGSharedPtr<SGSoundSample> _sample;
00141
00142 SGSharedPtr<SGCondition> _condition;
00143 SGPropertyNode_ptr _property;
00144
00145 bool _active;
00146 string _name;
00147 int _mode;
00148 double _prev_value;
00149 double _dt_play;
00150 double _dt_stop;
00151 double _delay;
00152 double _stopping;
00153
00154
00155 std::vector<_snd_prop> _volume;
00156 std::vector<_snd_prop> _pitch;
00157
00158 };
00159
00160 #endif // _SG_SOUND_HXX