1 /*
2  * Copyright 2011-2013 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Arx Libertatis is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /* Based on:
20 ===========================================================================
21 ARX FATALIS GPL Source Code
22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company.
23 
24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code').
25 
26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 
29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code.  If not, see
33 <http://www.gnu.org/licenses/>.
34 
35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these
36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx
37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below.
38 
39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o
40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
41 ===========================================================================
42 */
43 // Copyright (c) 1999-2000 ARKANE Studios SA. All rights reserved
44 
45 #ifndef ARX_SCENE_GAMESOUND_H
46 #define ARX_SCENE_GAMESOUND_H
47 
48 #include <string>
49 
50 #include "audio/AudioTypes.h"
51 #include "math/MathFwd.h"
52 
53 class Entity;
54 namespace res { class path; }
55 
56 enum SoundLoopMode {
57 	ARX_SOUND_PLAY_LOOPED = 0,
58 	ARX_SOUND_PLAY_ONCE = 1
59 };
60 
61 const audio::SampleId ARX_SOUND_TOO_FAR = -2;
62 
63 extern audio::MixerId ARX_SOUND_MixerGame;
64 extern audio::MixerId ARX_SOUND_MixerGameSample;
65 extern audio::MixerId ARX_SOUND_MixerGameSpeech;
66 extern audio::MixerId ARX_SOUND_MixerGameAmbiance;
67 extern audio::MixerId ARX_SOUND_MixerMenu;
68 extern audio::MixerId ARX_SOUND_MixerMenuSample;
69 extern audio::MixerId ARX_SOUND_MixerMenuSpeech;
70 extern audio::MixerId ARX_SOUND_MixerMenuAmbiance;
71 
72 // Menu ambiances
73 const std::string AMB_MENU = "ambient_menu.amb";
74 const std::string AMB_CREDITS = "ambient_credits.amb";
75 
76 // Menu samples
77 extern audio::SampleId SND_MENU_CLICK;
78 extern audio::SampleId SND_MENU_RELEASE;
79 
80 // Interface samples
81 extern audio::SampleId SND_BACKPACK;
82 extern audio::SampleId SND_BOOK_OPEN;
83 extern audio::SampleId SND_BOOK_CLOSE;
84 extern audio::SampleId SND_BOOK_PAGE_TURN;
85 extern audio::SampleId SND_GOLD;
86 extern audio::SampleId SND_INVSTD;
87 extern audio::SampleId SND_SCROLL_OPEN;
88 extern audio::SampleId SND_SCROLL_CLOSE;
89 extern audio::SampleId SND_TORCH_START;
90 extern audio::SampleId SND_TORCH_LOOP;
91 extern audio::SampleId SND_TORCH_END;
92 
93 // Other SFX samples
94 extern audio::SampleId SND_FIREPLACE;
95 extern audio::SampleId SND_PLOUF;
96 extern audio::SampleId SND_QUAKE;
97 extern audio::SampleId SND_WHOOSH;
98 
99 // Player samples
100 extern audio::SampleId SND_PLAYER_DEATH_BY_FIRE;
101 extern audio::SampleId SND_PLAYER_FILLLIFEMANA;
102 extern audio::SampleId SND_PLAYER_HEART_BEAT;
103 extern audio::SampleId SND_PLAYER_LEVEL_UP;
104 extern audio::SampleId SND_PLAYER_POISONED;
105 
106 // Magic drawing samples
107 extern audio::SampleId SND_MAGIC_AMBIENT;
108 extern audio::SampleId SND_MAGIC_DRAW;
109 extern audio::SampleId SND_MAGIC_FIZZLE;
110 
111 // Magic symbols samples
112 extern audio::SampleId SND_SYMB_AAM;
113 extern audio::SampleId SND_SYMB_CETRIUS;
114 extern audio::SampleId SND_SYMB_COSUM;
115 extern audio::SampleId SND_SYMB_COMUNICATUM;
116 extern audio::SampleId SND_SYMB_FOLGORA;
117 extern audio::SampleId SND_SYMB_FRIDD;
118 extern audio::SampleId SND_SYMB_KAOM;
119 extern audio::SampleId SND_SYMB_MEGA;
120 extern audio::SampleId SND_SYMB_MORTE;
121 extern audio::SampleId SND_SYMB_MOVIS;
122 extern audio::SampleId SND_SYMB_NHI;
123 extern audio::SampleId SND_SYMB_RHAA;
124 extern audio::SampleId SND_SYMB_SPACIUM;
125 extern audio::SampleId SND_SYMB_STREGUM;
126 extern audio::SampleId SND_SYMB_TAAR;
127 extern audio::SampleId SND_SYMB_TEMPUS;
128 extern audio::SampleId SND_SYMB_TERA;
129 extern audio::SampleId SND_SYMB_VISTA;
130 extern audio::SampleId SND_SYMB_VITAE;
131 extern audio::SampleId SND_SYMB_YOK;
132 
133 // Spells samples
134 extern audio::SampleId SND_SPELL_ACTIVATE_PORTAL;
135 extern audio::SampleId SND_SPELL_ARMOR_START;
136 extern audio::SampleId SND_SPELL_ARMOR_END;
137 extern audio::SampleId SND_SPELL_ARMOR_LOOP;
138 extern audio::SampleId SND_SPELL_BLESS;
139 extern audio::SampleId SND_SPELL_COLD_PROTECTION_START;
140 extern audio::SampleId SND_SPELL_COLD_PROTECTION_LOOP;
141 extern audio::SampleId SND_SPELL_COLD_PROTECTION_END;
142 extern audio::SampleId SND_SPELL_CONFUSE;
143 extern audio::SampleId SND_SPELL_CONTROL_TARGET;
144 extern audio::SampleId SND_SPELL_CREATE_FIELD;
145 extern audio::SampleId SND_SPELL_CREATE_FOOD;
146 extern audio::SampleId SND_SPELL_CURE_POISON;
147 extern audio::SampleId SND_SPELL_CURSE;
148 extern audio::SampleId SND_SPELL_DETECT_TRAP;
149 extern audio::SampleId SND_SPELL_DETECT_TRAP_LOOP;
150 extern audio::SampleId SND_SPELL_DISARM_TRAP;
151 extern audio::SampleId SND_SPELL_DISPELL_FIELD;
152 extern audio::SampleId SND_SPELL_DISPELL_ILLUSION;
153 extern audio::SampleId SND_SPELL_DOUSE;
154 extern audio::SampleId SND_SPELL_ELECTRIC;
155 extern audio::SampleId SND_SPELL_ENCHANT_WEAPON;
156 extern audio::SampleId SND_SPELL_EXPLOSION;
157 extern audio::SampleId SND_SPELL_EYEBALL_IN;
158 extern audio::SampleId SND_SPELL_EYEBALL_OUT;
159 extern audio::SampleId SND_SPELL_FIRE_FIELD;
160 extern audio::SampleId SND_SPELL_FIRE_HIT;
161 extern audio::SampleId SND_SPELL_FIRE_LAUNCH;
162 extern audio::SampleId SND_SPELL_FIRE_PROTECTION;
163 extern audio::SampleId SND_SPELL_FIRE_PROTECTION_LOOP;
164 extern audio::SampleId SND_SPELL_FIRE_PROTECTION_END;
165 extern audio::SampleId SND_SPELL_FIRE_WIND;
166 extern audio::SampleId SND_SPELL_FREEZETIME;
167 extern audio::SampleId SND_SPELL_HARM;
168 extern audio::SampleId SND_SPELL_HEALING;
169 extern audio::SampleId SND_SPELL_ICE_FIELD;
170 extern audio::SampleId SND_SPELL_ICE_FIELD_LOOP;
171 extern audio::SampleId SND_SPELL_ICE_FIELD_END;
172 extern audio::SampleId SND_SPELL_ICE_PROJECTILE_LAUNCH;
173 extern audio::SampleId SND_SPELL_INCINERATE;
174 extern audio::SampleId SND_SPELL_INCINERATE_LOOP;
175 extern audio::SampleId SND_SPELL_INCINERATE_END;
176 extern audio::SampleId SND_SPELL_IGNITE;
177 extern audio::SampleId SND_SPELL_INVISIBILITY_START;
178 extern audio::SampleId SND_SPELL_INVISIBILITY_END;
179 extern audio::SampleId SND_SPELL_LEVITATE_START;
180 extern audio::SampleId SND_SPELL_LIGHTNING;
181 extern audio::SampleId SND_SPELL_LIGHTNING_START;
182 extern audio::SampleId SND_SPELL_LIGHTNING_LOOP;
183 extern audio::SampleId SND_SPELL_LIGHTNING_END;
184 extern audio::SampleId SND_SPELL_LOWER_ARMOR;
185 extern audio::SampleId SND_SPELL_FIRE_FIELD_START;
186 extern audio::SampleId SND_SPELL_FIRE_FIELD_LOOP;
187 extern audio::SampleId SND_SPELL_FIRE_FIELD_END;
188 
189 extern audio::SampleId SND_SPELL_MAGICAL_HIT;
190 extern audio::SampleId SND_SPELL_MAGICAL_SHIELD;
191 extern audio::SampleId SND_SPELL_MASS_INCINERATE;
192 extern audio::SampleId SND_SPELL_MASS_PARALYSE;
193 extern audio::SampleId SND_SPELL_MM_CREATE;
194 extern audio::SampleId SND_SPELL_MM_HIT;
195 extern audio::SampleId SND_SPELL_MM_LAUNCH;
196 extern audio::SampleId SND_SPELL_MM_LOOP;
197 extern audio::SampleId SND_SPELL_NEGATE_MAGIC;
198 extern audio::SampleId SND_SPELL_NO_EFFECT;
199 extern audio::SampleId SND_SPELL_PARALYSE;
200 extern audio::SampleId SND_SPELL_PARALYSE_END;
201 extern audio::SampleId SND_SPELL_POISON_PROJECTILE_LAUNCH;
202 extern audio::SampleId SND_SPELL_RAISE_DEAD;
203 extern audio::SampleId SND_SPELL_REPEL_UNDEAD;
204 extern audio::SampleId SND_SPELL_REPEL_UNDEAD_LOOP;
205 extern audio::SampleId SND_SPELL_RUNE_OF_GUARDING;
206 extern audio::SampleId SND_SPELL_RUNE_OF_GUARDING_END;
207 extern audio::SampleId SND_SPELL_SLOW_DOWN;
208 extern audio::SampleId SND_SPELL_SPARK;
209 extern audio::SampleId SND_SPELL_SPEED_START;
210 extern audio::SampleId SND_SPELL_SPEED_LOOP;
211 extern audio::SampleId SND_SPELL_SPEED_END;
212 extern audio::SampleId SND_SPELL_SUMMON_CREATURE;
213 extern audio::SampleId SND_SPELL_TELEKINESIS_START;
214 extern audio::SampleId SND_SPELL_TELEKINESIS_END;
215 extern audio::SampleId SND_SPELL_TELEPORT;
216 extern audio::SampleId SND_SPELL_TELEPORTED;
217 extern audio::SampleId SND_SPELL_VISION_START;
218 extern audio::SampleId SND_SPELL_VISION_LOOP;
219 
220 // inter-material sounds
221 bool ARX_MATERIAL_GetNameById(long id, char * name);
222 
223 bool ARX_SOUND_Init();
224 void ARX_SOUND_LoadData();
225 void ARX_SOUND_Release();
226 
227 long ARX_SOUND_IsEnabled();
228 
229 void ARX_SOUND_SetListener(const Vec3f * position, const Vec3f * front, const Vec3f * up);
230 
231 audio::SampleId ARX_SOUND_Load(const res::path & name);
232 void ARX_SOUND_Free(const audio::SampleId & sample);
233 
234 long ARX_SOUND_PlaySFX(audio::SourceId & sample_id, const Vec3f * position = NULL, float pitch = 1.0F, const SoundLoopMode = ARX_SOUND_PLAY_ONCE);
235 long ARX_SOUND_PlayInterface(audio::SourceId & sample_id, float pitch = 1.0F, SoundLoopMode loop = ARX_SOUND_PLAY_ONCE);
236 
237 long ARX_SOUND_PlaySpeech(const res::path & name, const Entity * io = NULL);
238 long ARX_SOUND_PlayCollision(long mat1, long mat2, float volume, float power, Vec3f * position, Entity * source);
239 long ARX_SOUND_PlayCollision(const std::string& name1, const std::string& name2, float volume, float power, Vec3f* position, Entity* source);
240 
241 long ARX_SOUND_PlayScript(const res::path & name, const Entity * io = NULL, float pitch = 1.0F, SoundLoopMode loop = ARX_SOUND_PLAY_ONCE);
242 long ARX_SOUND_PlayAnim(audio::SourceId & sample_id, const Vec3f * position = NULL);
243 long ARX_SOUND_PlayCinematic(const res::path & name, bool isSpeech);
244 long ARX_SOUND_PlayMenu(audio::SourceId & sample_id, float pitch = 1.0F, SoundLoopMode loop = ARX_SOUND_PLAY_ONCE);
245 long ARX_SOUND_IsPlaying(audio::SourceId & sample_id);
246 float ARX_SOUND_GetDuration(audio::SampleId & sample_id);
247 
248 void ARX_SOUND_RefreshVolume(audio::SourceId & sample_id, float volume);
249 void ARX_SOUND_RefreshPosition(audio::SourceId & sample_id, const Vec3f * position = NULL);
250 void ARX_SOUND_RefreshPitch(audio::SourceId & sample_id, float pitch);
251 void ARX_SOUND_RefreshSpeechPosition(audio::SourceId & sample_id, const Entity * io = NULL);
252 
253 void ARX_SOUND_Stop(audio::SourceId & sample_id);
254 
255 bool ARX_SOUND_PlayScriptAmbiance(const res::path & ambiance_name, SoundLoopMode loop = ARX_SOUND_PLAY_LOOPED, float volume = 1.0F);
256 bool ARX_SOUND_PlayZoneAmbiance(const res::path & ambiance_name, SoundLoopMode loop = ARX_SOUND_PLAY_LOOPED, float volume = 1.0F);
257 audio::AmbianceId ARX_SOUND_PlayMenuAmbiance(const res::path & ambiance_name);
258 audio::AmbianceId ARX_SOUND_SetAmbianceTrackStatus(const res::path & ambiance_name, const std::string & track_name, unsigned long status); //0 = off; 1 = on TODO this is wrong?
259 void ARX_SOUND_KillAmbiances();
260 char * ARX_SOUND_AmbianceSavePlayList(size_t & size);
261 void ARX_SOUND_AmbianceRestorePlayList(const char * play_list, size_t size);
262 
263 void ARX_SOUND_MixerSetVolume(audio::MixerId mixer_id, float volume);
264 void ARX_SOUND_MixerStop(audio::MixerId mixer_id);
265 void ARX_SOUND_MixerPause(audio::MixerId mixer_id);
266 void ARX_SOUND_MixerResume(audio::MixerId mixer_id);
267 void ARX_SOUND_MixerSwitch(audio::MixerId from, audio::MixerId to);
268 
269 #endif // ARX_SCENE_GAMESOUND_H
270