platformAL.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _PLATFORMAL_H_
  23. #define _PLATFORMAL_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #define AL_NO_PROTOTYPES
  28. #include <al/al.h>
  29. #include <al/alc.h>
  30. #include <al/alut.h>
  31. // extra enums for win32/miles implementation
  32. enum {
  33. // error values
  34. AL_CONTEXT_ALREADY_INSTANTIATED = 0xbaadf00d,
  35. AL_ENVIRONMENT_ALREADY_INSTANTIATED,
  36. AL_UNSUPPORTED,
  37. AL_INVALID_BUFFER,
  38. AL_ERROR,
  39. // context extention
  40. ALC_PROVIDER,
  41. ALC_PROVIDER_COUNT,
  42. ALC_PROVIDER_NAME,
  43. ALC_SPEAKER,
  44. ALC_SPEAKER_COUNT,
  45. ALC_SPEAKER_NAME,
  46. ALC_BUFFER_DYNAMIC_MEMORY_SIZE,
  47. ALC_BUFFER_DYNAMIC_MEMORY_USAGE,
  48. ALC_BUFFER_DYNAMIC_COUNT,
  49. ALC_BUFFER_MEMORY_USAGE,
  50. ALC_BUFFER_COUNT,
  51. ALC_BUFFER_LATENCY,
  52. // misc 3d params
  53. AL_MIN_DISTANCE,
  54. AL_MAX_DISTANCE,
  55. AL_CONE_OUTER_GAIN,
  56. // relative with pos(0,0,0) won't work for ambient sounds with miles
  57. AL_SOURCE_AMBIENT,
  58. AL_PAN,
  59. // other extensions
  60. AL_BUFFER_KEEP_RESIDENT,
  61. AL_FORMAT_WAVE_EXT,
  62. // Environment extensions:
  63. AL_ENV_EFFECT_VOLUME_EXT,
  64. AL_ENV_FLAGS_EXT,
  65. AL_ENV_DAMPING_EXT,
  66. AL_ENV_ENVIRONMENT_SIZE_EXT,
  67. AL_ENV_ROOM_VOLUME_EXT,
  68. };
  69. enum {
  70. // sample level environment:
  71. AL_ENV_SAMPLE_REVERB_MIX_EXT = 0,
  72. AL_ENV_SAMPLE_DIRECT_EXT,
  73. AL_ENV_SAMPLE_DIRECT_HF_EXT,
  74. AL_ENV_SAMPLE_ROOM_EXT,
  75. AL_ENV_SAMPLE_ROOM_HF_EXT,
  76. AL_ENV_SAMPLE_OBSTRUCTION_EXT,
  77. AL_ENV_SAMPLE_OBSTRUCTION_LF_RATIO_EXT,
  78. AL_ENV_SAMPLE_OCCLUSION_EXT,
  79. AL_ENV_SAMPLE_OCCLUSION_LF_RATIO_EXT,
  80. AL_ENV_SAMPLE_OCCLUSION_ROOM_RATIO_EXT,
  81. AL_ENV_SAMPLE_ROOM_ROLLOFF_EXT,
  82. AL_ENV_SAMPLE_AIR_ABSORPTION_EXT,
  83. AL_ENV_SAMPLE_OUTSIDE_VOLUME_HF_EXT,
  84. AL_ENV_SAMPLE_FLAGS_EXT,
  85. AL_ENV_SAMPLE_COUNT,
  86. };
  87. // room types: same as miles/eax
  88. enum {
  89. AL_ENVIRONMENT_GENERIC = 0,
  90. AL_ENVIRONMENT_PADDEDCELL,
  91. AL_ENVIRONMENT_ROOM,
  92. AL_ENVIRONMENT_BATHROOM,
  93. AL_ENVIRONMENT_LIVINGROOM,
  94. AL_ENVIRONMENT_STONEROOM,
  95. AL_ENVIRONMENT_AUDITORIUM,
  96. AL_ENVIRONMENT_CONCERTHALL,
  97. AL_ENVIRONMENT_CAVE,
  98. AL_ENVIRONMENT_ARENA,
  99. AL_ENVIRONMENT_HANGAR,
  100. AL_ENVIRONMENT_CARPETEDHALLWAY,
  101. AL_ENVIRONMENT_HALLWAY,
  102. AL_ENVIRONMENT_STONECORRIDOR,
  103. AL_ENVIRONMENT_ALLEY,
  104. AL_ENVIRONMENT_FOREST,
  105. AL_ENVIRONMENT_CITY,
  106. AL_ENVIRONMENT_MOUNTAINS,
  107. AL_ENVIRONMENT_QUARRY,
  108. AL_ENVIRONMENT_PLAIN,
  109. AL_ENVIRONMENT_PARKINGLOT,
  110. AL_ENVIRONMENT_SEWERPIPE,
  111. AL_ENVIRONMENT_UNDERWATER,
  112. AL_ENVIRONMENT_DRUGGED,
  113. AL_ENVIRONMENT_DIZZY,
  114. AL_ENVIRONMENT_PSYCHOTIC,
  115. AL_ENVIRONMENT_COUNT
  116. };
  117. // declare OpenAL functions
  118. #define AL_EXTENSION(ext_name) extern bool gDoesSupport_##ext_name;
  119. #define AL_FUNCTION(fn_return,fn_name,fn_args) extern fn_return (FN_CDECL *fn_name)fn_args;
  120. #define AL_EXT_FUNCTION(ext_name,fn_return,fn_name,fn_args) extern fn_return (FN_CDECL *fn_name)fn_args;
  121. #ifndef _OPENALFN_H_
  122. #include <openALFn.h>
  123. #endif
  124. namespace Audio
  125. {
  126. bool libraryInit(const char *library);
  127. void libraryInitExtensions();
  128. void libraryShutdown();
  129. inline bool doesSupportIASIG()
  130. {
  131. return gDoesSupport_AL_EXT_IASIG;
  132. }
  133. inline bool doesSupportDynamix()
  134. {
  135. return gDoesSupport_AL_EXT_DYNAMIX;
  136. }
  137. // helpers
  138. F32 DBToLinear(F32 value);
  139. F32 linearToDB(F32 value);
  140. } // end namespace Audio
  141. #endif // _H_PLATFORMAL_