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 HOPKINS_SOUND_H
23 #define HOPKINS_SOUND_H
24 
25 #include "common/scummsys.h"
26 #include "common/str.h"
27 #include "audio/mixer.h"
28 
29 namespace Audio {
30 class RewindableAudioStream;
31 }
32 
33 namespace Common {
34 class SeekableReadStream;
35 }
36 
37 namespace Hopkins {
38 
39 class VoiceItem {
40 public:
41  VoiceItem() : _status(false), _wavIndex(0) {}
42 
43  bool _status;
44  int _wavIndex;
45 };
46 
47 class SwavItem {
48 public:
49  SwavItem() : _active(false), _audioStream(NULL), _freeSampleFl(false) {}
50 
51  bool _active;
52  Audio::RewindableAudioStream *_audioStream;
53  Audio::SoundHandle _soundHandle;
54  bool _freeSampleFl;
55 };
56 
57 class MusicItem {
58 public:
59  MusicItem() : _active(false) {}
60 
61  bool _active;
62 };
63 
64 class SoundItem {
65 public:
66  SoundItem() : _active(false) {}
67 
68  bool _active;
69 };
70 
71 #define VOICE_COUNT 3
72 #define SWAV_COUNT 50
73 #define SOUND_COUNT 10
74 
75 class HopkinsEngine;
76 
77 class SoundManager {
78 private:
79  HopkinsEngine *_vm;
80 
81  Audio::SoundHandle _musicHandle;
82  int _currentSoundIndex;
83  bool _modPlayingFl;
84  int _oldSoundNumber;
85 
86  VoiceItem _voice[VOICE_COUNT];
87  SwavItem _sWav[SWAV_COUNT];
88  SoundItem _sound[SOUND_COUNT];
89  MusicItem _music;
90 
91  void playMod(const Common::Path &file);
92  void loadMusic(const Common::Path &file);
93  void playMusic();
94  void stopMusic();
95  void delMusic();
96  bool checkVoiceStatus(int voiceIndex);
97  bool loadVoice(const Common::Path &filename, size_t fileOffset, size_t entryLength, SwavItem &item);
98  void stopVoice(int voiceIndex);
99  void playVoice();
100  void delWav(int wavIndex);
101  void checkVoiceActivity();
102  Common::Path setExtension(const Common::Path &str, const Common::String &ext);
104  bool removeWavSample(int wavIndex);
105  bool loadWavSample(int wavIndex, const Common::Path &filename, bool freeSample);
106  void playWavSample(int voiceIndex, int wavIndex, bool useVoiceVolume = false);
107  bool isValidVoiceIndex(int voiceIndex) const;
108  bool isValidWavIndex(int wavIndex) const;
109  bool isValidSoundIndex(int soundIndex) const;
110 
111 public:
112  bool _musicOffFl;
113  bool _soundOffFl;
114  bool _voiceOffFl;
115  bool _textOffFl;
116  bool _soundFl;
117  bool _skipRefreshFl;
118  int _musicVolume;
119  int _soundVolume;
120  int _voiceVolume;
121  int _specialSoundNum;
122 public:
124  ~SoundManager();
125 
126  void loadAnimSound();
127  void playAnimSound(int animFrame);
128 
129  bool loadSample(int wavIndex, const Common::Path &file);
130  void playSample(int wavIndex, int voiceMode = 9);
131  void removeSample(int soundIndex);
132 
133  void checkSoundEnd();
134  void checkSounds();
135  void playSoundFile(const Common::Path &file);
136  void playSound(int soundNumber);
137  void stopSound();
138 
139  void updateScummVMSoundSettings();
140  void syncSoundSettings();
141  bool mixVoice(int voiceId, int voiceMode, bool displTxtFl = false);
142 
143  void setMODMusicVolume(int volume);
144  void setMODSampleVolume();
145  void setMODVoiceVolume();
146 
147  void loadWav(const Common::Path &file, int wavIndex);
148  void playWav(int wavIndex);
149  void directPlayWav(const Common::Path &file2);
150 };
151 
152 } // End of namespace Hopkins
153 
154 #endif /* HOPKINS_SOUND_H */
Definition: str.h:59
Definition: sound.h:39
Definition: path.h:52
Definition: stream.h:745
Definition: mixer.h:49
Definition: sound.h:77
Definition: algorithm.h:29
Definition: anim.h:30
Definition: audiostream.h:109
Definition: sound.h:64
Definition: sound.h:47
Definition: hopkins.h:95
Definition: sound.h:57
Definition: system.h:39