AudioUtils.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. AudioUtils = {
  12. -- these names should exactly match those defined in ATLEntities.cpp and in libs/gameaudio/wwise/default_controls.xml
  13. sObstructionCalcSwitchName = "ObstructionOcclusionCalculationType",
  14. sObstructionStateNames = {"Ignore", "SingleRay", "MultiRay"},
  15. }
  16. ----------------------------------------------------------------------------------------
  17. function AudioUtils.LookupTriggerID(sTriggerName)
  18. local hTriggerID = nil;
  19. if ((sTriggerName ~= nil) and (sTriggerName ~= "")) then
  20. hTriggerID = Sound.GetAudioTriggerID(sTriggerName);
  21. end
  22. return hTriggerID;
  23. end
  24. ----------------------------------------------------------------------------------------
  25. function AudioUtils.LookupRtpcID(sRtpcName)
  26. local hRtpcID = nil;
  27. if ((sRtpcName ~= nil) and (sRtpcName ~= "")) then
  28. hRtpcID = Sound.GetAudioRtpcID(sRtpcName);
  29. end
  30. return hRtpcID;
  31. end
  32. ----------------------------------------------------------------------------------------
  33. function AudioUtils.LookupSwitchID(sSwitchName)
  34. local hSwitchID = nil;
  35. if ((sSwitchName ~= nil) and (sSwitchName ~= "")) then
  36. hSwitchID = Sound.GetAudioSwitchID(sSwitchName);
  37. end
  38. return hSwitchID;
  39. end
  40. ----------------------------------------------------------------------------------------
  41. function AudioUtils.LookupSwitchStateIDs(hSwitchID, tStateNames)
  42. local tStateIDs = {};
  43. if ((hSwitchID ~= nil) and (tStateNames ~= nil)) then
  44. for i, name in ipairs(tStateNames) do
  45. tStateIDs[i] = Sound.GetAudioSwitchStateID(hSwitchID, name);
  46. end
  47. end
  48. return tStateIDs;
  49. end
  50. ----------------------------------------------------------------------------------------
  51. function AudioUtils.LookupAudioEnvironmentID(sEnvironmentName)
  52. local hEnvironmentID = nil;
  53. if ((sEnvironmentName ~= nil) and (sEnvironmentName ~= "")) then
  54. hEnvironmentID = Sound.GetAudioEnvironmentID(sEnvironmentName);
  55. end
  56. return hEnvironmentID;
  57. end
  58. ----------------------------------------------------------------------------------------
  59. function AudioUtils.LookupObstructionSwitchAndStates()
  60. local nSwitch = AudioUtils.LookupSwitchID(AudioUtils.sObstructionCalcSwitchName);
  61. local tStates = AudioUtils.LookupSwitchStateIDs(nSwitch, AudioUtils.sObstructionStateNames);
  62. return {hSwitchID = nSwitch, tStateIDs = tStates};
  63. end