src/engine/eSound.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ArmageTron_SOUND_H
00029 #define ArmageTron_SOUND_H
00030 
00031 #include "rSDL.h"
00032 #include "defs.h"
00033 // #include "eGrid.h"
00034 #include "tString.h"
00035 #include "tLinkedList.h"
00036 
00037 void se_SoundInit();
00038 void se_SoundExit();
00039 void se_SoundLock();
00040 void se_SoundUnlock();
00041 void se_SoundPause(bool p);
00042 void se_SoundMenu();
00043 
00044 class eAudioPos{
00045 public:
00046     Uint32 pos;
00047     Uint32 fraction;
00048 
00049     void Reset(int randomize=0);
00050 
00051     eAudioPos(){Reset();}
00052 };
00053 
00054 class eWavData: public tListItem<eWavData>{
00055     SDL_AudioSpec spec; // the audio format
00056     Uint8         *data; // the sound data
00057     Uint32        len;   // the data's length
00058     Uint32        samples; // samples
00059     tString       filename; // the filename
00060     tString       filename_alt; // the filename
00061     bool          freeData; // manually free data or use SDL_FreeWAV?
00062 
00063     static eWavData* s_anchor; // list anchor
00064 
00065 public:
00066     bool alt; // was the alternative used?
00067 
00068     eWavData(const char * fileName,const char *alternative_file=""); // load file
00069     ~eWavData();
00070 
00071     void Load();                // really load the file
00072     void Unload();      // remove the file from memory
00073     static void UnloadAll(); // unload all sounds
00074 
00075 
00076     bool Mix(Uint8 *dest,
00077              Uint32 len,
00078              eAudioPos &pos,
00079              REAL rvol,
00080              REAL lvol,
00081              REAL speed=1,
00082              bool loop=false);
00083 
00084     // mixes to the buffer at *dest with length len the data from the wav
00085     // from position pos (will be modified to contain the end position)
00086     // with volume rvol/lvol and play speed speed. If loop is set,
00087     // start over if you reached the end.
00088     // return value: end reached.
00089 
00090     void Loop(); // prepares the sample for smooth looped output;
00091     // none of the many sound-editors I tried had that feature...
00092 };
00093 
00094 class eSoundPlayer{
00095     int id;
00096     eWavData *wav; // the sound we should put out
00097     eAudioPos pos[MAX_VIEWERS]; // the position of all viewers
00098     bool goon[MAX_VIEWERS];
00099     bool loop;
00100 
00101 public:
00102     eSoundPlayer(eWavData &w,bool loop=false);
00103     ~eSoundPlayer();
00104 
00105     bool Mix(Uint8 *dest,
00106              Uint32 len,
00107              int viewer,
00108              REAL rvol,
00109              REAL lvol,
00110              REAL speed=1);
00111 
00112     void Reset(int randomize=0);
00113     void End();
00114 
00115     void MakeGlobal();
00116 
00117     //  static eGrid *S_Grid; // the grid we play the sounds on
00118 };
00119 
00120 
00121 #endif

Generated on Sat Mar 15 22:55:47 2008 for Armagetron Advanced by  doxygen 1.5.4