Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

sound.h

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 #ifndef sound_h_included
00012 #define sound_h_included
00013 
00014 #include "../ascstring.h"
00015 #include "../music.h"
00016 
00017 
00018 class Sound_InternalData;
00019 
00020 class Sound {
00021    public:
00028      Sound( const ASCString& filename, int fadeIn = 0 );
00029      Sound( const ASCString& startSoundFilename, const ASCString& continuousSoundFilename, int fadeIn = 0 );
00030 
00031 
00032      void play(void);
00033      void playWait(void);
00034 
00035      void playLoop();
00036      void stop();
00037 
00038      void fadeOut ( int ms );
00039 
00040      bool load();
00041 
00042      friend class SoundSystem;
00043 
00044      ~Sound(void);
00045    private:
00047      const ASCString name;
00048 
00050      int startPlaying( bool loop ); 
00051 
00052      void finishedSignal( int channelnum );
00053 
00054      Sound_InternalData* internalData;
00055      
00056      int fadeIn;
00057      bool waitingForMainWave;
00058 };
00059 
00060 
00061 class SoundSystem_InternalData;
00062 
00063 class SoundSystem {
00064       bool effectsMuted;
00065       bool off;
00066       bool sdl_initialized;
00067       bool mix_initialized;
00068       int musicVolume;
00069       int effectVolume;
00070 
00071       static SoundSystem* instance;
00072 
00073       SoundSystem_InternalData* internalData;
00074       
00075 
00077       static void trackFinished( void );
00078 
00079       void nextTrack ( void );
00080 
00081       static void channelFinishedCallback( int channelnum );
00082 
00083       enum MusicState { uninitialized, init_ready, init_paused, playing, paused } musicState;
00084    protected:
00085 
00087       friend class Sound;
00088 
00089    public:
00095       SoundSystem ( bool muteEffects, bool muteMusic, bool off );
00096 
00098       void setEffectsMute ( bool mute );
00099 
00101       bool areEffectsMuted ( ) { return effectsMuted || off; };
00102 
00104       bool isOff ( ) { return off; };
00105 
00107       void playMusic ( MusicPlayList* playlist );
00108 
00110       void pauseMusic();
00111 
00113       void resumeMusic();
00114 
00116       void resumePauseMusic();
00117 
00119       void setMusicVolume( int Volume );
00120 
00122       void setEffectVolume( int Volume );
00123 
00125       int getEffectVolume( ) { return effectVolume; };
00126 
00127       static SoundSystem* getInstance() { return instance; };
00128 
00129       ASCString getDiagnosticText();
00130 
00131       ~SoundSystem();
00132 };
00133 
00134 #endif

Generated on Tue Jun 24 01:27:52 2008 for Advanced Strategic Command by  doxygen 1.4.2