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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SHERLOCK_SOUND_H 24 #define SHERLOCK_SOUND_H 25 26 #include "common/scummsys.h" 27 #include "common/str.h" 28 #include "audio/mixer.h" 29 #include "access/files.h" 30 31 namespace Sherlock { 32 33 class SherlockEngine; 34 35 enum WaitType { 36 WAIT_RETURN_IMMEDIATELY = 0, WAIT_FINISH = 1, WAIT_KBD_OR_FINISH = 2 37 }; 38 39 #define MAX_MIXER_CHANNELS 10 40 41 class Sound { 42 private: 43 SherlockEngine *_vm; 44 Audio::Mixer *_mixer; 45 Audio::SoundHandle _scalpelEffectsHandle; 46 Audio::SoundHandle _aiffHandle; 47 Audio::SoundHandle _tattooEffectsHandle[MAX_MIXER_CHANNELS]; 48 Audio::SoundHandle _speechHandle; 49 int _curPriority; 50 51 /** 52 * Decode a sound sample 53 */ 54 byte decodeSample(byte sample, byte& reference, int16& scale); 55 56 /** 57 * Handle playing a sound or speech 58 */ 59 bool playSoundResource(const Common::String &name, const Common::String &libFilename, 60 Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle); 61 62 /** 63 * Form a filename from a passed sound resource name 64 */ 65 Common::String formFilename(const Common::String &name); 66 public: 67 bool _digitized; 68 int _voices; 69 bool _soundOn; 70 bool _speechOn; 71 bool _soundPlaying; 72 bool _speechPlaying; 73 int _soundVolume; 74 75 Common::String _talkSoundFile; 76 public: 77 Sound(SherlockEngine *vm, Audio::Mixer *mixer); 78 79 /** 80 * Saves sound-related settings 81 */ 82 void syncSoundSettings(); 83 84 /** 85 * Load a sound 86 */ 87 void loadSound(const Common::String &name, int priority); 88 89 /** 90 * Play the sound in the specified resource 91 */ 92 bool playSound(const Common::String &name, WaitType waitType, int priority = 100, const char *libraryFilename = nullptr); 93 94 /** 95 * Play the specified AIFF file. (Used for the 3DO Scalpel intro.) 96 */ 97 void playAiff(const Common::String &name, int volume = Audio::Mixer::kMaxChannelVolume, bool loop = false); 98 99 /** 100 * Stop the AIFF sound that was started with playAiff(). 101 */ 102 void stopAiff(); 103 104 /** 105 * Play a previously loaded sound 106 */ 107 void playLoadedSound(int bufNum, WaitType waitType); 108 109 /** 110 * Free any previously loaded sounds 111 */ 112 void freeLoadedSounds(); 113 114 /** 115 * Stop playing any active sound 116 */ 117 void stopSound(); 118 119 void freeDigiSound(); 120 121 /** 122 * Return a sound handle to use 123 */ 124 Audio::SoundHandle &getFreeSoundHandle(); 125 126 /** 127 * Set the volume 128 */ 129 void setVolume(int volume); 130 131 /** 132 * Play a specified voice resource 133 */ 134 void playSpeech(const Common::String &name); 135 136 /** 137 * Stop any currently playing speech 138 */ 139 void stopSpeech(); 140 141 /** 142 * Returns true if speech is currently playing 143 */ 144 bool isSpeechPlaying(); 145 }; 146 147 } // End of namespace Sherlock 148 149 #endif 150 151