src/engine/sound/sdl_mixer/eMusicTrackSDLMixer.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 typedef int Mix_MusicType;
00036 #endif
00037 #include "tPlayList.h"
00038 
00039 
00040 #ifndef EMUSICTRACK_H
00041 #define EMUSICTRACK_H
00042 
00043 #include <map>
00044 
00045 // Forward declarations from other files
00046 class eGameObject;
00047 class eCoord;
00048 
00049 // Forward declarations from this file
00050 class eWavData;
00051 class eSoundMixer;
00052 class eChannel;
00053 
00054 /*******************************************************************************
00055  *
00056  * eMusicTrack
00057  *      This class represents a music track
00058  *
00059  *******************************************************************************/
00060 
00061 class eMusicTrack {
00062 public:
00063     eMusicTrack();
00064     eMusicTrack(const char* filename, bool isinstalled=false);
00065     ~eMusicTrack();
00066 
00067     void SetVolume(int newVolume) { m_Volume = newVolume; };
00068     int GetVolume() { return m_Volume; };
00069 
00070     void Loop() { m_Loop = true; };
00071 
00072     tString const &GetFileName() { return m_Filename; };
00073 
00074     bool Play();
00075     void Stop() {
00076 #ifndef DEDICATED
00077         Mix_HaltMusic();
00078 #endif
00079     };
00080     void Next();
00081     void Previous();
00082     void Pause();
00083     void VolumeUp();
00084     void VolumeDown();
00085     void Mute();
00086 
00087     void Update();
00088     void SetDirty();
00089 
00090     bool LoadSong(tSong thesong);
00091     void LoadPlaylist(const char* filename);
00092 
00093     void SetPlaylist(int i) { usePlaylist = i; if(m_Playlist) m_Playlist->SetPlaylist(i); };
00094 
00095     void FadeOut(); // Fades out the track if it's currently playing
00096 bool IsPlaying() { return m_IsPlaying; };
00097     bool HasSong() { return m_HasSong; };
00098     void UnloadSong();
00099     // Determines if *any* music is playing
00100     static bool musicIsPlaying;
00101 
00102     void MusicFinished();
00103     static eMusicTrack* currentMusic;
00104 private:
00105     void Init(bool isinstalled);
00106 
00107     Mix_Music* LoadFile(const char* filename);
00108     void LoadAATrack(tSong& thesong);
00109     void LoadVorbisTrack(tSong& thesong);
00110     void PlayCurrentSequence();
00111 
00112     // Do we play the track from installed music?
00113     bool m_IsInstalled;
00114 
00115     int m_Volume;
00116     bool m_Loop;
00117     // Determines if *this* track is playing
00118     bool m_IsPlaying;
00119 
00120     int usePlaylist;
00121 
00122     bool m_isDirty;
00123 
00124     bool m_HasSong;
00125 
00126     bool m_SequenceChange;
00127 
00128     double m_Pos;
00129     std::map<tString, Mix_Music*>::iterator m_SequencePos;
00130     Uint32 m_StartTime;
00131     tSong m_CurrentSong;
00132 
00133     std::map<tString, Mix_Music*> m_Tracklist;
00134     eSoundMixer* m_mixer;
00135 
00136     // The file associated with this music track
00137     tString m_Filename;
00138     Mix_Music* m_Music;
00139     Mix_MusicType m_MusicType;
00140 
00141     tPlayList* m_Playlist;
00142 };
00143 
00144 #endif
00145 

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