SoundHandler.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * SoundHandler.h
00009  * MetalWarriors
00010  * $Revision: 1.7 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029 
00030 #ifndef _SOUND_HANDLER_
00031 #define _SOUND_HANDLER_
00032 
00033 #include <list>
00034 #include <sys/types.h>
00035 
00036 static const float SPEED_OF_SOUND = 346.4;
00037 
00038 //#include "config.h"
00039 
00040 struct source_t
00041 {
00042      int sid;
00043      bool updateMe;
00044 };
00045 
00046 class SoundEmitter
00047 {
00048  protected:
00049      float *pos;
00050      float *vel;
00051 
00052      std::list<source_t*> sources;
00053      static float null_[3];
00054 
00055 public:
00056      SoundEmitter() { pos = null_; vel = null_;}
00057      virtual ~SoundEmitter() {}
00058      virtual int addSound(const char *file_name) { return 0; }
00059      virtual void delSound(int sound_index) {}
00060      virtual void playSound(int sound) {}
00061      virtual void setUpdate(int sound_index, bool do_update) {}
00062 
00063      virtual void setPosition(int idx, float *v) {}
00064      virtual void setDirection(int idx, float *v) {}
00065      virtual void setVelocity(int idx, float *v) {}
00066      //...
00067      virtual void setGain(int idx, float gain) {}
00068      
00069      virtual void setPosition(float *position) {}
00070      virtual void setVelocity(float *velocity) {}
00071 
00072      virtual void update() {}
00073 };
00074 
00075 class SoundHandler
00076 {
00077 protected:
00078      static pid_t musicPlayer;
00079      float *dir;
00080      float *pos;
00081      float *vel;
00082      
00083      SoundEmitter *myEmitter;
00084      std::list<SoundEmitter*> emitterList;
00085   
00086 public:
00087      SoundHandler() {}
00088      virtual ~SoundHandler() {}
00089      virtual int init(int argc, char** argv) { return 0; }
00090      virtual void setDirectionVector(float *direction) {}
00091 
00092      virtual SoundEmitter* allocNewEmitter(void) { return new SoundEmitter(); }
00093      virtual void delEmitter(SoundEmitter *emitter) {}
00094   
00095      virtual int addSound(const char *file_name) { return 0; }
00096      virtual void masterVolume(float volume) {}
00097 
00098      virtual void update() {}
00099 
00100      static void StartMusic(const std::string &fname);
00101      static void StopMusic();
00102 };
00103 
00104 #endif //_SOUND_HANDLER_

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7