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 SHERLOCK_SOUND_H
23 #define SHERLOCK_SOUND_H
24 
25 #include "common/scummsys.h"
26 #include "common/str.h"
27 #include "audio/mixer.h"
28 #include "access/files.h"
29 
30 namespace Sherlock {
31 
32 class SherlockEngine;
33 
34 enum WaitType {
35  WAIT_RETURN_IMMEDIATELY = 0, WAIT_FINISH = 1, WAIT_KBD_OR_FINISH = 2
36 };
37 
38 #define MAX_MIXER_CHANNELS 10
39 
40 class Sound {
41 private:
42  SherlockEngine *_vm;
43  Audio::Mixer *_mixer;
44  Audio::SoundHandle _scalpelEffectsHandle;
45  Audio::SoundHandle _aiffHandle;
46  Audio::SoundHandle _tattooEffectsHandle[MAX_MIXER_CHANNELS];
47  Audio::SoundHandle _speechHandle;
48  int _curPriority;
49 
53  byte decodeSample(byte sample, byte& reference, int16& scale);
54 
58  bool playSoundResource(const Common::Path &name, const Common::Path &libFilename,
59  Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle);
60 
64  Common::Path formFilename(const Common::Path &name);
65 public:
66  bool _digitized;
67  int _voices;
68  bool _soundOn;
69  bool _speechOn;
70  bool _soundPlaying;
71  bool _speechPlaying;
72  int _soundVolume;
73 
74  Common::String _talkSoundFile;
75 public:
76  Sound(SherlockEngine *vm, Audio::Mixer *mixer);
77 
81  void syncSoundSettings();
82 
86  void loadSound(const Common::Path &name, int priority);
87 
91  bool playSound(const Common::Path &name, WaitType waitType, int priority = 100, const Common::Path &libraryFilename = Common::Path());
92 
96  void playAiff(const Common::Path &name, int volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
97 
101  void stopAiff();
102 
106  void playLoadedSound(int bufNum, WaitType waitType);
107 
111  void freeLoadedSounds();
112 
116  void stopSound();
117 
118  void freeDigiSound();
119 
124 
128  void setVolume(int volume);
129 
133  void playSpeech(const Common::Path &name);
134 
138  void stopSpeech();
139 
143  bool isSpeechPlaying();
144 };
145 
146 } // End of namespace Sherlock
147 
148 #endif
149 
Definition: str.h:59
void freeLoadedSounds()
Definition: animation.h:29
Definition: sound.h:40
Definition: path.h:52
void syncSoundSettings()
bool isSpeechPlaying()
Definition: mixer.h:49
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
bool playSound(const Common::Path &name, WaitType waitType, int priority=100, const Common::Path &libraryFilename=Common::Path())
SoundType
Definition: mixer.h:62
Definition: mixer.h:59
void playAiff(const Common::Path &name, int volume=Audio::Mixer::kMaxChannelVolume, bool loop=false)
void playLoadedSound(int bufNum, WaitType waitType)
void loadSound(const Common::Path &name, int priority)
Definition: sherlock.h:76
Audio::SoundHandle & getFreeSoundHandle()
Definition: mixer.h:71
void setVolume(int volume)
void playSpeech(const Common::Path &name)