Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

SoundMgr.H

Go to the documentation of this file.
00001 
00011 #ifndef SOUNDMGR_H
00012 #define SOUNDMGR_H
00013 
00014 #define OUTSIDE_GLUE_CORE
00015 #include <mlib/points.H>
00016 #include <std/strings.H>
00017 #include <std/list.H>
00018 
00019 
00020 // types of parameters that can be set for each sound
00021 enum SOUNDPARAM {
00022   SP_LOOP = 0,    // 0.0 or 1.0
00023   SP_PITCH = 1,   // (0.0,1.0] default=1.0
00024   SP_GAIN = 2,    // [0.0,any] default=1.0 0.0=mute 1.0=normal
00025   SP_POSX = 3,    // default <0,0,0>
00026   SP_POSY = 4,
00027   SP_POSZ = 5,
00028   SP_VELX = 6,    // default <0,0,0>
00029   SP_VELY = 7,
00030   SP_VELZ = 8,
00031 
00032   SP_NUM_PARAMS = 9
00033 };
00034 
00035 
00036 // base class for sound device implementations
00037 class SoundImplementation
00038 {
00039 public:
00040   // listener related
00041   virtual void setListenerLoc(Wtransf m) = 0;
00042   virtual void setListenerVel(Wvec v) =  0;
00043   virtual void setListenerGain(float g) = 0;
00044 
00045   // for each sound, accessed via filename
00046   virtual void load(str_ptr filename) = 0;
00047   virtual void play(str_ptr filename) = 0;
00048   virtual void stop(str_ptr filename) = 0;
00049   virtual void deleteSound(str_ptr filename) = 0;
00050   virtual void setParam(str_ptr filename, SOUNDPARAM param, float value) = 0;
00051 };
00052 
00053 
00054 // after adding an implementation to the SOUNDMGR, either a 
00055 // compiled-in implementation or a network interface to a soundserver,
00056 // make calls to SOUNDMGR within a program to deal with sounds
00057 class SOUNDMGR
00058 {
00059 public:
00060 
00061   // add a sound device to the manager..  need to do this before
00062   // anything can be played!
00063   // examples of implementations: 
00064   // 1. a network interface for a sound server
00065   // 2. code that makes calls to a sound library like OpenAL
00066   static void addImplementation(SoundImplementation *simp);
00067 
00068   static void setListenerLoc(Wtransf m);
00069   static void setListenerVel(Wvec v);
00070   static void setListenerGain(float g);
00071 
00072   // load a sound into memory
00073   static void load(str_ptr filename);
00074   // play a sound, if not already loaded will try to load first
00075   static void play(str_ptr filename);
00076   // stop playing a sound
00077   static void stop(str_ptr filename);
00078   // remove a sound file from memory
00079   static void deleteSound(str_ptr filename);
00080 
00081   // sets a parameter for a sound, for example, pitch, freq, or gain.
00082   static void setParam(str_ptr filename, SOUNDPARAM param, float value);
00083   
00084 private:
00085 
00086   static ARRAY<SoundImplementation*> _imp;
00087 
00088 };
00089 
00090 #endif

Generated on Thu Jul 8 15:19:29 2004 for inspace by doxygen 1.3.4