11
11
#ifndef sound_h_included
12
12
#define sound_h_included
14
#include <SDL_mixer.h>
15
14
#include "../ascstring.h"
16
15
#include "../music.h"
18
class Sound_InternalData;
21
22
/** Create a Sound from the .wav file specified by filename.
22
23
* If it's not possible to use the wave file for some reason, the
23
24
* sound is set to silence.
25
* \param filename the file that is loaded
24
26
* \param fadeIn is a time in milliseconds
26
28
Sound( const ASCString& filename, int fadeIn = 0 );
29
Sound( const ASCString& startSoundFilename, const ASCString& continuousSoundFilename, int fadeIn = 0 );
29
33
void playWait(void);
34
38
void fadeOut ( int ms );
42
friend class SoundSystem;
38
46
/** A name for this sound - mostly for debugging purposes */
39
47
const ASCString name;
41
//! the actual wave data
49
//! returns the channel
50
int startPlaying( bool loop );
52
void finishedSignal( int channelnum );
54
Sound_InternalData* internalData;
57
bool waitingForMainWave;
61
class SoundSystem_InternalData;
48
63
class SoundSystem {
51
66
bool sdl_initialized;
52
67
bool mix_initialized;
56
71
static SoundSystem* instance;
58
MusicPlayList* currentPlaylist;
60
Sound* channel[MIX_CHANNELS];
73
SoundSystem_InternalData* internalData;
62
76
//! callback for SDL_mixer
63
77
static void trackFinished( void );
65
79
void nextTrack ( void );
81
static void channelFinishedCallback( int channelnum );
67
83
enum MusicState { uninitialized, init_ready, init_paused, playing, paused } musicState;
70
86
//! loads a sound from the wave file called name to an Mix_buffer.
71
Mix_Chunk* loadWave ( const ASCString& name );
72
87
friend class Sound;
75
90
/** Sets up ASC's sound system.
76
\param mute The sound is going to be initialized, but no sounds played. Sounds can be enabled at runtime
91
\param muteEffects The sound is going to be initialized, but no sounds played. Sounds can be enabled at runtime
92
\param muteMusic The sound is going to be initialized, but no music played. Music can be enabled at runtime
77
93
\param off The sound system is not even going to be initiliazed. Can only be restartet by restarting ASC
79
95
SoundSystem ( bool muteEffects, bool muteMusic, bool off );