FS2_Open
Open source remastering of the Freespace 2 engine
openal.h
Go to the documentation of this file.
1 
2 #ifndef _AL_H
3 #define _AL_H
4 
5 
6 #if !(defined(__APPLE__) || defined(_WIN32))
7  #include <AL/al.h>
8  #include <AL/alc.h>
9 #else
10  #include "al.h"
11  #include "alc.h"
12 #endif // !__APPLE__ && !_WIN32
13 
14 #include <string>
15 
16 
17 const char* openal_error_string(int get_alc = 0);
18 bool openal_init_device(SCP_string *playback, SCP_string *capture);
19 
21 
22 
23 // if an error occurs after executing 'x' then do 'y'
24 #define OpenAL_ErrorCheck( x, y ) do { \
25  x; \
26  const char *error_text = openal_error_string(0); \
27  if ( error_text != NULL ) { \
28  nprintf(("Warning", "SOUND: %s:%d - OpenAL error = '%s'\n", __FILE__, __LINE__, error_text)); \
29  y; \
30  } \
31 } while (0);
32 
33 // like OpenAL_ErrorCheck() except that it gives the error message from x but does nothing about it
34 #define OpenAL_ErrorPrint( x ) do { \
35  x; \
36  const char *error_text = openal_error_string(0); \
37  if ( error_text != NULL ) { \
38  nprintf(("Sound", "OpenAL ERROR: \"%s\" in %s, line %i\n", error_text, __FILE__, __LINE__)); \
39  } \
40 } while (0);
41 
42 // same as the above two, but looks for ALC errors instead of standard AL errors
43 #define OpenAL_C_ErrorCheck( x, y ) do { \
44  x; \
45  const char *error_text = openal_error_string(1); \
46  if ( error_text != NULL ) { \
47  nprintf(("Warning", "SOUND: %s:%d - OpenAL error = '%s'\n", __FILE__, __LINE__, error_text)); \
48  y; \
49  } \
50 } while (0);
51 
52 // like OpenAL_ErrorCheck() except that it gives the error message from x but does nothing about it
53 #define OpenAL_C_ErrorPrint( x ) do { \
54  x; \
55  const char *error_text = openal_error_string(1); \
56  if ( error_text != NULL ) { \
57  nprintf(("Sound", "OpenAL ERROR: \"%s\" in %s, line %i\n", error_text, __FILE__, __LINE__)); \
58  } \
59 } while (0);
60 
61 
62 #ifndef AL_BYTE_LOKI
63 // in case it's not defined by older/other drivers
64 #define AL_BYTE_LOKI 0x100C
65 #endif
66 
67 // not define by older OpenAL versions
68 #ifndef AL_BYTE_OFFSET
69 #define AL_BYTE_OFFSET 0x1026
70 #endif
71 
72 #ifndef ALC_EXT_EFX
73 #define ALC_EXT_EFX 1
74 #define AL_FILTER_TYPE 0x8001
75 #define AL_EFFECT_TYPE 0x8001
76 #define AL_FILTER_NULL 0x0000
77 #define AL_FILTER_LOWPASS 0x0001
78 #define AL_EFFECT_NULL 0x0000
79 #define AL_EFFECT_EAXREVERB 0x8000
80 #define AL_EFFECT_REVERB 0x0001
81 #define AL_EFFECT_ECHO 0x0004
82 #define ALC_EFX_MAJOR_VERSION 0x20001
83 #define ALC_EFX_MINOR_VERSION 0x20002
84 #define ALC_MAX_AUXILIARY_SENDS 0x20003
85 
86 #define AL_AUXILIARY_SEND_FILTER 0x20006
87 
88 #define AL_EAXREVERB_DENSITY 0x0001
89 #define AL_EAXREVERB_DIFFUSION 0x0002
90 #define AL_EAXREVERB_GAIN 0x0003
91 #define AL_EAXREVERB_GAINHF 0x0004
92 #define AL_EAXREVERB_GAINLF 0x0005
93 #define AL_EAXREVERB_DECAY_TIME 0x0006
94 #define AL_EAXREVERB_DECAY_HFRATIO 0x0007
95 #define AL_EAXREVERB_DECAY_LFRATIO 0x0008
96 #define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009
97 #define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A
98 #define AL_EAXREVERB_REFLECTIONS_PAN 0x000B
99 #define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C
100 #define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D
101 #define AL_EAXREVERB_LATE_REVERB_PAN 0x000E
102 #define AL_EAXREVERB_ECHO_TIME 0x000F
103 #define AL_EAXREVERB_ECHO_DEPTH 0x0010
104 #define AL_EAXREVERB_MODULATION_TIME 0x0011
105 #define AL_EAXREVERB_MODULATION_DEPTH 0x0012
106 #define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013
107 #define AL_EAXREVERB_HFREFERENCE 0x0014
108 #define AL_EAXREVERB_LFREFERENCE 0x0015
109 #define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016
110 #define AL_EAXREVERB_DECAY_HFLIMIT 0x0017
111 
112 #define AL_EFFECTSLOT_NULL 0x0000
113 #define AL_EFFECTSLOT_EFFECT 0x0001
114 #endif
115 
116 #ifndef AL_EXT_float32
117 #define AL_EXT_float32 1
118 #define AL_FORMAT_MONO_FLOAT32 0x10010
119 #define AL_FORMAT_STEREO_FLOAT32 0x10011
120 #endif
121 
122 #endif // _AL_H
ALenum openal_get_format(ALint bits, ALint n_channels)
Definition: openal.cpp:78
ALuint *typedef ALuint *typedef ALenum
Definition: ds.cpp:133
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
bool openal_init_device(SCP_string *playback, SCP_string *capture)
Definition: openal.cpp:323
ALuint *typedef ALuint *typedef ALint
Definition: ds.cpp:133
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: Glext.h:10400
const char * openal_error_string(int get_alc=0)
Definition: openal.cpp:56