src/engine/sound/sdl_mixer/eChannelSDLMixer.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 #include "rSDL.h"
00029 #ifndef DEDICATED
00030 #include <SDL_mixer.h>
00031 #else
00032 // dummy types
00033 typedef int Mix_Chunk;
00034 typedef int Mix_Music;
00035 #endif
00036 #include "tPlayList.h"
00037 #include "eCoord.h"
00038 
00039 #include "base/eChannel.h"
00040 
00041 #ifndef ECHANNELSDLMIXER_H
00042 #define ECHANNELSDLMIXER_H
00043 
00044 // Forward declarations from other files
00045 class eGameObject;
00046 class eCoord;
00047 
00048 // Forward declarations from this file
00049 class eWavDataSDLMixer;
00050 class eMusicTrackSDLMixer;
00051 class eChannelSDLMixer;
00052 
00053 /*******************************************************************************
00054  *
00055  * eWavData
00056  *
00057  *******************************************************************************/
00058 
00059 class eWavDataSDLMixer : public eWavData {
00060 public:
00061     eWavDataSDLMixer();
00062     ~eWavDataSDLMixer();
00063     eWavDataSDLMixer(const char* filename);
00064     void LoadWavFile(const char* filename);
00065 
00066     Mix_Chunk* GetWavData() { return m_WavData; };
00067 
00068     void SetVolume(int newVolume) { m_Volume = newVolume; };
00069     int GetVolume() { return m_Volume; };
00070 
00071 private:
00072     Mix_Chunk* m_WavData;
00073     int m_Volume;
00074     bool m_Playable;
00075 };
00076 
00077 /*******************************************************************************
00078  *
00079  * eChannel
00080  *      Description of a mixer channel, corresponds to an SDL_mixer channel
00081  *
00082  *******************************************************************************/
00083 
00084 class eChannelSDLMixer {
00085 public:
00086     eChannelSDLMixer();
00087     void SetVolume(int volume);
00088     int GetId() { return m_ChannelID; };
00089     void SetId(int newID) { m_ChannelID = newID; };
00090 
00091     void Set3d(eCoord home, eCoord soundPos, eCoord homeDirection);
00092     void PlaySound(eWavData& sound);
00093     void LoopSound(eWavData& sound);
00094     void StopSound() {
00095 #ifndef DEDICATED
00096         m_isDirty = true; m_isPlaying = false; Mix_HaltChannel(m_ChannelID);
00097 #endif
00098     };
00099 
00100     // Removes any effects on the channel, should it get picked more or less at random
00101     // to play a sample.  Intended to be called from an SDL_mixer callback.
00102     void UnplaySound();
00103 
00104     Uint32 StartTime() { return m_StartTime; };
00105     bool IsContinuous() { return m_continuous; };
00106 
00107     // Call this whenever the object needs to be updated.
00108     void Update();
00109 
00110     // Call to see if the object needs to be updated
00111     bool isDirty() { return m_isDirty; };
00112 
00113     // Call to see if it's busy right now
00114     bool isBusy() { return m_isPlaying; };
00115 
00116     void SetOwner(eGameObject* owner);
00117     void DelayStarting() { m_Delayed = true; m_StartNow = false; };
00118     bool IsDelayed() { return m_Delayed; };
00119     void Undelay() { m_StartNow = true; };
00120     void SetHome(eGameObject* home) { m_Home = home; };
00121     eGameObject* GetOwner() { return m_Owner; };
00122 
00123     // A cop out, I should just iterate through all the channels and initialize it
00124     // properly, so they're guaranteed to be in sync, but this should work, as long
00125     // as the list of channels only gets built once.
00126     static int numChannels;
00127 
00128 private:
00129     eWavData m_Sound;
00130     bool m_Delayed;
00131     bool m_StartNow;
00132     int m_Volume;
00133     int m_ChannelID;
00134     Uint32 m_StartTime;
00135     bool m_isDirty;
00136     bool m_isPlaying;
00137     eGameObject* m_Owner;
00138     eGameObject* m_Home;
00139     bool m_continuous;
00140 };
00141 
00142 #endif

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