00001
00024 #ifndef SOURCEBASE_H_INCLUDED_C419E330
00025 #define SOURCEBASE_H_INCLUDED_C419E330
00026 #include "openalpp/export.h"
00027 #include "openalpp/positionedobject.h"
00028 #include "openalpp/error.h"
00029
00030 namespace openalpp {
00031
00038 typedef enum SourceState {Initial,Playing,Paused,Stopped};
00039
00046 class OPENALPP_API SourceBase : public PositionedObject {
00047 public:
00051 void play();
00052
00056 void pause();
00057
00061 void stop();
00062
00066 void rewind();
00067
00072 SourceState getState() const;
00073
00078 void setLooping(bool loop = true);
00079
00084 bool isLooping() const;
00085
00092 void setDirection(float directionx, float directiony, float directionz);
00093
00100 void getDirection(float &directionx,float &directiony,float &directionz) const;
00101
00106 void makeOmniDirectional();
00107
00121 void setSoundCone(float innerangle,
00122 float outerangle=360.0,float outergain=0.0);
00123
00130 void getSoundCone(float &innerangle,float &outerangle,float &outergain)const;
00131
00140 void setGain(float gain);
00141
00146 float getGain() const;
00147
00154 void setMinMaxGain(float min = 0.0, float max = 1.0);
00155
00161 void getMinMaxGain(float & min, float &max) const;
00162
00169 void setAmbient(bool ambient = true);
00170
00175 bool isAmbient() const;
00176
00183 void setRelative(bool relative = true);
00184
00189 bool isRelative() const;
00190
00196 void setReferenceDistance(float distance = 1.0);
00197
00202 float getReferenceDistance() const;
00203
00210 void setMaxDistance(float distance);
00211
00216 float getMaxDistance() const;
00217
00223 void setRolloffFactor(float factor = 1.0);
00224
00229 float getRolloffFactor() const;
00230
00236 void setPitch(float pitch = 1.0);
00237
00242 float getPitch() const;
00243
00250 void setReverbScale(float scale) throw (InitError,ValueError);
00251
00258 void setReverbDelay(float delay) throw (InitError,ValueError);
00259
00264 float getReverbDelay() throw (InitError);
00265
00270 float getReverbScale() throw (InitError);
00271
00280 ALuint link(const SourceBase *source) throw (MemoryError);
00281
00286 void unlink(const SourceBase *source) throw (NameError);
00287
00292 void unlink(const ALuint name) throw (NameError);
00293
00297 void unlinkAll();
00298
00303 ALuint getAlSource() const;
00304
00308 void setPosition(float x, float y, float z);
00309
00313 void getPosition(float &x, float &y, float &z) const;
00314
00318 void setVelocity(float vx, float vy, float vz);
00319
00323 void getVelocity(float &vx, float &vy, float &vz) const;
00324
00328 SourceBase &operator=(const SourceBase &sourcebase);
00329
00330 protected:
00334 virtual ~SourceBase();
00335
00339 SourceBase() throw (MemoryError,NameError);
00340
00347 SourceBase(float x,float y,float z) throw (MemoryError,NameError);
00348
00352 SourceBase(const SourceBase &sourcebase);
00353
00357 ALuint sourcename_;
00358
00362 bool streaming_;
00363 private:
00368 void init() throw (MemoryError,NameError);
00369
00373 ALuint *linkedsources_;
00374
00378 unsigned int nlinkedsources_;
00379
00383 unsigned int alloclinkedsources_;
00384
00388 float reverbscale_,reverbdelay_;
00389 };
00390
00391 }
00392
00393 #endif