ScummVM API documentation
sound.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SKY_SOUND_H
23 #define SKY_SOUND_H
24 
25 
26 #include "common/scummsys.h"
27 #include "audio/mixer.h"
28 
29 namespace Sky {
30 
31 class Disk;
32 
33 enum {
34  SOUND_CH0 = 0,
35  SOUND_CH1 = 1,
36  SOUND_BG = 2,
37  SOUND_VOICE = 3,
38  SOUND_SPEECH = 4
39 };
40 
41 struct SfxQueue {
42  uint8 count, fxNo, chan, vol;
43 };
44 
45 #define MAX_QUEUED_FX 4
46 
47 class Sound {
48 protected:
49 
50 public:
51 
52  Audio::Mixer *_mixer;
53  Audio::SoundHandle _voiceHandle;
54  Audio::SoundHandle _effectHandle;
55  Audio::SoundHandle _bgSoundHandle;
56  Audio::SoundHandle _ingameSound0, _ingameSound1, _ingameSpeech;
57 
58  uint16 _saveSounds[2];
59 
60 protected:
61 
62  void playSound(uint32 id, byte *sound, uint32 size, Audio::SoundHandle *handle);
63 
64 public:
65  Sound(Audio::Mixer *mixer, Disk *pDisk, uint8 pVolume);
66  ~Sound();
67 
68  void loadSection(uint8 pSection);
69  void playSound(uint16 sound, uint16 volume, uint8 channel);
70  void fnStartFx(uint32 sound, uint8 channel);
71  bool startSpeech(uint16 textNum);
72  bool speechFinished() { return !_mixer->isSoundHandleActive(_ingameSpeech); }
73  void fnPauseFx();
74  void fnUnPauseFx();
75  void fnStopFx();
76  void stopSpeech();
77  void checkFxQueue();
78  void restoreSfx();
79  uint8 _soundsTotal;
80 
81 private:
82  Disk *_skyDisk;
83  uint16 _sfxBaseOfs;
84  uint8 *_soundData;
85  uint8 *_sampleRates, *_sfxInfo;
86  uint8 _mainSfxVolume;
87 
88  bool _isPaused;
89 
90  static uint16 _speechConvertTable[8];
91  static SfxQueue _sfxQueue[MAX_QUEUED_FX];
92 };
93 
94 } // End of namespace Sky
95 
96 #endif
virtual bool isSoundHandleActive(SoundHandle handle)=0
Definition: disk.h:37
Definition: mixer.h:49
Definition: mixer.h:59
Definition: sound.h:47
Definition: autoroute.h:28
Definition: sound.h:41