Player.h

Go to the documentation of this file.
00001 
00002 //Luke Lenhart, 2008
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 
00007 #include "../base/Setup.h"
00008 
00009 #ifdef MPMA_COMPILE_AUDIO
00010 
00011 #include "Buffer.h"
00012 #include "../base/ReferenceCount.h"
00013 #include "AL_Include.h"
00014 
00015 namespace AUDIO
00016 {
00018     enum RenderMode
00019     {
00021         POSITIONAL=0x200,
00023         FIXED
00024     };
00025 
00026     //internal data common to all player objects
00027     struct InternalSharedPlayerData
00028     {
00029         inline InternalSharedPlayerData(): player(0), isPlaying(false), isBufferStatic(false)
00030             {}
00031 
00032         ALuint player;
00033         Buffer buffer;
00034 
00035         bool isPlaying;
00036         bool isBufferStatic;
00037     };
00038 
00040     class Player: public MPMA::ReferenceCountedData<InternalSharedPlayerData>
00041     {
00042     public:
00043         virtual ~Player();
00044 
00046         bool Play(Buffer &buffer, RenderMode mode);
00047 
00049         void Stop();
00050 
00052         bool IsPlaying() const;
00053 
00055         void SetVolume(float value);
00057         static void SetDefaultVolume(float value);
00058 
00060         void SetPitchMultiplier(float value);
00062         static void SetDefaultPitchMultiplier(float value);
00063 
00065         void SetPosition(float x, float y, float z);
00067         template <typename VectorType>
00068         inline void SetPosition(const VectorType &pos)
00069             { SetPosition(pos[0], pos[1], pos[2]); }
00070 
00072         void SetVelocity(float x, float y, float z);
00074         template <typename VectorType>
00075         inline void SetVelocity(const VectorType &vel)
00076             { SetVelocity(vel[0], vel[1], vel[2]); }
00077 
00079         void SetCone(float dirX, float dirY, float dirZ, float coneInnerAngle, float coneOutterAngle, float coneOutterAngleVolume);
00081         template <typename VectorType>
00082         inline void SetCone(const VectorType &dir, float coneInnerAngle, float coneOutterAngle, float coneOutterAngleVolume)
00083             { SetCone(dir[0], dir[1], dir[2], coneInnerAngle, coneOutterAngle, coneOutterAngleVolume); }
00084 
00086         void SetDistanceVolumeLimits(float minVolume, float maxVolume);
00088         static void SetDefaultDistanceVolumeLimits(float minVolume, float maxVolume);
00089 
00091         void SetReferenceDistance(float value);
00093         static void SetDefaultReferenceDistance(float value);
00094 
00096         void SetMaxDistance(float value);
00098         static void SetDefaultMaxDistance(float value);
00099 
00101         void SetRolloffFactor(float value);
00103         static void SetDefaultRolloffFactor(float value);
00104 
00105         //TODO: effects (reverb etc)
00106 
00107     private:
00108 
00109         //Sets up a player to match our state (what openal calls a source)
00110         void InitPlayer();
00111     };
00112 }
00113 
00114 #endif //#ifdef MPMA_COMPILE_AUDIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends