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 ULTIMA4_SOUND_H
24 #define ULTIMA4_SOUND_H
25 
26 #include "ultima/shared/std/containers.h"
27 #include "audio/audiostream.h"
28 #include "audio/mixer.h"
29 #include "common/str.h"
30 
31 namespace Ultima {
32 namespace Ultima4 {
33 
34 enum Sound {
35 	SOUND_TITLE_FADE,       // the intro title fade
36 	SOUND_WALK_NORMAL,      // walk, world and town
37 	SOUND_WALK_SLOWED,      // walk, slow progress
38 	SOUND_WALK_COMBAT,      // walk, combat
39 	SOUND_BLOCKED,          // location blocked
40 	SOUND_ERROR,            // error/bad command
41 	SOUND_PC_ATTACK,        // PC attacks
42 	SOUND_PC_STRUCK,        // PC damaged
43 	SOUND_NPC_ATTACK,       // NPC attacks
44 	SOUND_NPC_STRUCK,       // NPC damaged
45 	SOUND_ACID,             // effect, acid damage
46 	SOUND_SLEEP,            // effect, sleep
47 	SOUND_POISON_EFFECT,    // effect, poison
48 	SOUND_POISON_DAMAGE,    // damage, poison
49 	SOUND_EVADE,            // trap evaded
50 	SOUND_FLEE,             // flee combat
51 	SOUND_ITEM_STOLEN,      // item was stolen from a PC, food or gold
52 	SOUND_LBHEAL,           // LB heals party
53 	SOUND_LEVELUP,          // PC level up
54 	SOUND_MOONGATE,         // moongate used
55 
56 	SOUND_CANNON,
57 	SOUND_RUMBLE,
58 	SOUND_PREMAGIC_MANA_JUMBLE,
59 	SOUND_MAGIC,
60 	SOUND_WHIRLPOOL,
61 	SOUND_STORM,
62 
63 	//    SOUND_MISSED,
64 	//    SOUND_CREATUREATTACK,
65 	//    SOUND_PLAYERHIT,
66 	SOUND_MAX
67 };
68 
69 void soundPlay(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
70 
71 void soundStop(int channel = 1);
72 
73 class SoundManager {
74 private:
75 	Audio::Mixer *_mixer;
76 	Audio::SoundHandle _soundHandle;
77 	Std::vector<Common::String> _soundFilenames;
78 	Std::vector<Audio::SeekableAudioStream *> _sounds;
79 private:
80 	bool load(Sound sound);
81 
82 	void play_sys(Sound sound, bool onlyOnce, int specificDurationMilli);
83 	bool load_sys(Sound sound, const Common::String &filename);
84 	void stop_sys(int channel);
85 public:
86 	SoundManager(Audio::Mixer *mixer);
87 	~SoundManager();
88 
89 	void play(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
90 	void stop(int channel = 1);
91 };
92 
93 extern SoundManager *g_sound;
94 
95 } // End of namespace Ultima4
96 } // End of namespace Ultima
97 
98 #endif
99