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  void loadWavSample(int wavIndex, const Common::Path &filename, bool freeSample);
106  void playWavSample(int voiceIndex, int wavIndex);
107 
108 public:
109  bool _musicOffFl;
110  bool _soundOffFl;
111  bool _voiceOffFl;
112  bool _textOffFl;
113  bool _soundFl;
114  bool _skipRefreshFl;
115  int _musicVolume;
116  int _soundVolume;
117  int _voiceVolume;
118  int _specialSoundNum;
119 public:
121  ~SoundManager();
122 
123  void loadAnimSound();
124  void playAnimSound(int animFrame);
125 
126  void loadSample(int wavIndex, const Common::Path &file);
127  void playSample(int wavIndex, int voiceMode = 9);
128  void removeSample(int soundIndex);
129 
130  void checkSoundEnd();
131  void checkSounds();
132  void playSoundFile(const Common::Path &file);
133  void playSound(int soundNumber);
134  void stopSound();
135 
136  void updateScummVMSoundSettings();
137  void syncSoundSettings();
138  bool mixVoice(int voiceId, int voiceMode, bool displTxtFl = false);
139 
140  void setMODMusicVolume(int volume);
141  void setMODSampleVolume();
142  void setMODVoiceVolume();
143 
144  void loadWav(const Common::Path &file, int wavIndex);
145  void playWav(int wavIndex);
146  void directPlayWav(const Common::Path &file2);
147 };
148 
149 } // End of namespace Hopkins
150 
151 #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:86
Definition: sound.h:57
Definition: system.h:38