1 /** @file s_environ.cpp Environmental audio effects.
2 *
3 * Calculation of the aural properties of sectors.
4 *
5 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
6 * @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net>
7 *
8 * @par License
9 * GPL: http://www.gnu.org/licenses/gpl.html
10 *
11 * <small>This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version. This program is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details. You should have received a copy of the GNU
18 * General Public License along with this program; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA</small>
21 */
22
23 #include "de_base.h"
24 #include "audio/s_environ.h"
25
26 #include "Sector"
27
28 using namespace de;
29
30 static AudioEnvironment envInfo[1 + NUM_AUDIO_ENVIRONMENTS] = {
31 { "", 0, 0, 0 },
32 { "Metal", 255, 255, 25 },
33 { "Rock", 200, 160, 100 },
34 { "Wood", 80, 50, 200 },
35 { "Cloth", 5, 5, 255 }
36 };
37
S_AudioEnvironmentName(AudioEnvironmentId id)38 char const *S_AudioEnvironmentName(AudioEnvironmentId id)
39 {
40 DENG2_ASSERT(id >= AE_NONE && id < NUM_AUDIO_ENVIRONMENTS);
41 return ::envInfo[1 + dint( id )].name;
42 }
43
S_AudioEnvironment(AudioEnvironmentId id)44 AudioEnvironment const &S_AudioEnvironment(AudioEnvironmentId id)
45 {
46 DENG2_ASSERT(id >= AE_NONE && id < NUM_AUDIO_ENVIRONMENTS);
47 return ::envInfo[1 + dint( id )];
48 }
49
S_AudioEnvironmentId(de::Uri const * uri)50 AudioEnvironmentId S_AudioEnvironmentId(de::Uri const *uri)
51 {
52 if(uri)
53 {
54 for(dint i = 0; i < DED_Definitions()->textureEnv.size(); ++i)
55 {
56 ded_tenviron_t const *env = &DED_Definitions()->textureEnv[i];
57 for(dint k = 0; k < env->materials.size(); ++k)
58 {
59 de::Uri *ref = env->materials[k].uri;
60 if(!ref || *ref != *uri) continue;
61
62 // Is this a known environment?
63 for(dint m = 0; m < NUM_AUDIO_ENVIRONMENTS; ++m)
64 {
65 AudioEnvironment const &envInfo = S_AudioEnvironment(AudioEnvironmentId(m));
66 if(!qstricmp(env->id, envInfo.name))
67 return AudioEnvironmentId(m);
68 }
69 return AE_NONE;
70 }
71 }
72 }
73 return AE_NONE;
74 }
75