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
00089 bool isPaused() const;
00090
00097 void setDirection(float directionx, float directiony, float directionz);
00098
00105 void getDirection(float &directionx,float &directiony,float &directionz) const;
00106
00111 void makeOmniDirectional();
00112
00126 void setSoundCone(float innerangle,
00127 float outerangle=360.0,float outergain=0.0);
00128
00135 void getSoundCone(float &innerangle,float &outerangle,float &outergain)const;
00136
00145 void setGain(float gain);
00146
00151 float getGain() const;
00152
00159 void setMinMaxGain(float min = 0.0, float max = 1.0);
00160
00166 void getMinMaxGain(float & min, float &max) const;
00167
00174 void setAmbient(bool ambient = true);
00175
00180 bool isAmbient() const;
00181
00188 void setRelative(bool relative = true);
00189
00194 bool isRelative() const;
00195
00201 void setReferenceDistance(float distance = 1.0);
00202
00207 float getReferenceDistance() const;
00208
00215 void setMaxDistance(float distance);
00216
00221 float getMaxDistance() const;
00222
00228 void setRolloffFactor(float factor = 1.0);
00229
00234 float getRolloffFactor() const;
00235
00241 void setPitch(float pitch = 1.0);
00242
00247 float getPitch() const;
00248
00255 void setReverbScale(float scale) throw (InitError,ValueError);
00256
00263 void setReverbDelay(float delay) throw (InitError,ValueError);
00264
00269 float getReverbDelay() throw (InitError);
00270
00275 float getReverbScale() throw (InitError);
00276
00285 ALuint link(const SourceBase *source) throw (MemoryError);
00286
00291 void unlink(const SourceBase *source) throw (NameError);
00292
00297 void unlink(const ALuint name) throw (NameError);
00298
00302 void unlinkAll();
00303
00308 ALuint getAlSource() const;
00309
00313 void setPosition(float x, float y, float z);
00314
00318 void getPosition(float &x, float &y, float &z) const;
00319
00323 void setVelocity(float vx, float vy, float vz);
00324
00328 void getVelocity(float &vx, float &vy, float &vz) const;
00329
00333 SourceBase &operator=(const SourceBase &sourcebase);
00334
00335 protected:
00339 virtual ~SourceBase();
00340
00344 SourceBase() throw (MemoryError,NameError);
00345
00352 SourceBase(float x,float y,float z) throw (MemoryError,NameError);
00353
00357 SourceBase(const SourceBase &sourcebase);
00358
00362 ALuint sourcename_;
00363
00367 bool streaming_;
00368 private:
00373 void init() throw (MemoryError,NameError);
00374
00378 ALuint *linkedsources_;
00379
00383 unsigned int nlinkedsources_;
00384
00388 unsigned int alloclinkedsources_;
00389
00393 float reverbscale_,reverbdelay_;
00394 };
00395
00396 }
00397
00398 #endif