~ubuntu-branches/ubuntu/maverick/asc/maverick

« back to all changes in this revision

Viewing changes to source/sdl/sound.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Eddy Petrișor, Gonéri Le Bouder, Cyril Brulebois, Barry deFreese
  • Date: 2008-01-08 19:54:18 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080108195418-n19fc4eobhhqxcy5
Tags: 2.0.1.0-1
[ Eddy Petrișor ]
* fixed Homepage semifield

[ Gonéri Le Bouder ]
* add a watchfile
* move homepage from the description to the new Homepage field

[ Cyril Brulebois ]
* Added Vcs-Svn and Vcs-Browser fields in the control file.

[ Barry deFreese ]
* Fix make-clean lintian warning
* New upstream release
* Bump debhelper build-dep to match compat
* Add desktop file
* Update watch file for new upstream naming
* Remove nostrip check from rules
* Bump Standards Version to 3.7.3
* Add myself to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#ifndef sound_h_included
12
12
#define sound_h_included
13
13
 
14
 
#include <SDL_mixer.h>
15
14
#include "../ascstring.h"
16
15
#include "../music.h"
17
16
 
18
17
 
 
18
class Sound_InternalData;
 
19
 
19
20
class Sound {
20
21
   public:
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
25
27
      */
26
28
     Sound( const ASCString& filename, int fadeIn = 0 );
 
29
     Sound( const ASCString& startSoundFilename, const ASCString& continuousSoundFilename, int fadeIn = 0 );
 
30
 
27
31
 
28
32
     void play(void);
29
33
     void playWait(void);
33
37
 
34
38
     void fadeOut ( int ms );
35
39
 
 
40
     bool load();
 
41
 
 
42
     friend class SoundSystem;
 
43
 
36
44
     ~Sound(void);
37
45
   private:
38
46
     /** A name for this sound - mostly for debugging purposes */
39
47
     const ASCString name;
40
48
 
41
 
     //! the actual wave data
42
 
     Mix_Chunk *wave;
43
 
 
 
49
     //! returns the channel
 
50
     int startPlaying( bool loop ); 
 
51
 
 
52
     void finishedSignal( int channelnum );
 
53
 
 
54
     Sound_InternalData* internalData;
 
55
     
44
56
     int fadeIn;
 
57
     bool waitingForMainWave;
45
58
};
46
59
 
47
60
 
 
61
class SoundSystem_InternalData;
 
62
 
48
63
class SoundSystem {
49
64
      bool effectsMuted;
50
 
      int off;
 
65
      bool off;
51
66
      bool sdl_initialized;
52
67
      bool mix_initialized;
53
68
      int musicVolume;
54
69
      int effectVolume;
55
70
 
56
71
      static SoundSystem* instance;
57
 
      Mix_Music *musicBuf;
58
 
      MusicPlayList* currentPlaylist;
59
72
 
60
 
      Sound* channel[MIX_CHANNELS];
 
73
      SoundSystem_InternalData* internalData;
 
74
      
61
75
 
62
76
      //! callback for SDL_mixer
63
77
      static void trackFinished( void );
64
78
 
65
79
      void nextTrack ( void );
66
80
 
 
81
      static void channelFinishedCallback( int channelnum );
 
82
 
67
83
      enum MusicState { uninitialized, init_ready, init_paused, playing, paused } musicState;
68
84
   protected:
69
85
 
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;
73
88
 
74
89
   public:
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
78
94
      */
79
95
      SoundSystem ( bool muteEffects, bool muteMusic, bool off );
110
126
 
111
127
      static SoundSystem* getInstance() { return instance; };
112
128
 
 
129
      ASCString getDiagnosticText();
 
130
 
113
131
      ~SoundSystem();
114
132
};
115
133