GenerateSoundBanksCommandlet.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #include "AssetManagement/GenerateSoundBanksCommandlet.h"
  16. #if WITH_EDITOR
  17. #include "AkAudioBankGenerationHelpers.h"
  18. #include "AkSoundBankGenerationManager.h"
  19. #include "AkSettings.h"
  20. #include "AkSettingsPerUser.h"
  21. #include "Containers/Ticker.h"
  22. #include "Framework/Application/SlateApplication.h"
  23. #include "IAudiokineticTools.h"
  24. #include "ISourceControlModule.h"
  25. #include "SourceControlHelpers.h"
  26. #include "AssetManagement/WwiseProjectInfo.h"
  27. #define LOCTEXT_NAMESPACE "AkAudio"
  28. #endif
  29. static constexpr auto HelpSwitch = TEXT("help");
  30. static constexpr auto LanguagesSwitch = TEXT("languages");
  31. static constexpr auto PlatformsSwitch = TEXT("platforms");
  32. static constexpr auto WwiseConsolePathSwitch = TEXT("wwiseConsolePath");
  33. UGenerateSoundBanksCommandlet::UGenerateSoundBanksCommandlet()
  34. {
  35. IsClient = false;
  36. IsEditor = true;
  37. IsServer = false;
  38. LogToConsole = true;
  39. HelpDescription = TEXT("Commandlet allowing to generate Wwise SoundBanks.");
  40. HelpParamNames.Add(PlatformsSwitch);
  41. HelpParamDescriptions.Add(TEXT("(Optional) Comma separated list of platforms for which SoundBanks will be generated, as specified in the Wwise project. If not specified, SoundBanks will be generated for all platforms."));
  42. HelpParamNames.Add(LanguagesSwitch);
  43. HelpParamDescriptions.Add(TEXT("(Optional) Comma separated list of languages for which SoundBanks will be generated, as specified in the Wwise project. If not specified, SoundBanks will be generated for all platforms."));
  44. HelpParamNames.Add(WwiseConsolePathSwitch);
  45. HelpParamDescriptions.Add(TEXT("(Optional) Full path to the Wwise command-line application to use to generate the SoundBanks. If not specified, the path found in the Wwise settings will be used."));
  46. HelpParamNames.Add(HelpSwitch);
  47. HelpParamDescriptions.Add(TEXT("(Optional) Print this help message. This will quit the commandlet immediately."));
  48. HelpUsage = TEXT("<Editor.exe> <path_to_uproject> -run=GenerateSoundBanks [-platforms=listOfPlatforms] [-languages=listOfLanguages] [-rebuild]");
  49. HelpWebLink = TEXT("https://www.audiokinetic.com/library/edge/?source=UE4&id=using_features_generatecommandlet.html");
  50. }
  51. void UGenerateSoundBanksCommandlet::PrintHelp() const
  52. {
  53. UE_LOG(LogAudiokineticTools, Display, TEXT("%s"), *HelpDescription);
  54. UE_LOG(LogAudiokineticTools, Display, TEXT("Usage: %s"), *HelpUsage);
  55. UE_LOG(LogAudiokineticTools, Display, TEXT("Parameters:"));
  56. for (int32 i = 0; i < HelpParamNames.Num(); ++i)
  57. {
  58. UE_LOG(LogAudiokineticTools, Display, TEXT("\t- %s: %s"), *HelpParamNames[i], *HelpParamDescriptions[i]);
  59. }
  60. UE_LOG(LogAudiokineticTools, Display, TEXT("For more information, see %s"), *HelpWebLink);
  61. }
  62. int32 UGenerateSoundBanksCommandlet::Main(const FString& Params)
  63. {
  64. int32 ReturnCode = 0;
  65. #if WITH_EDITOR
  66. AkSoundBankGenerationManager::FInitParameters InitParameters;
  67. TArray<FString> Tokens;
  68. TArray<FString> Switches;
  69. TMap<FString, FString> ParamVals;
  70. ParseCommandLine(*Params, Tokens, Switches, ParamVals);
  71. if (Switches.Contains(HelpSwitch))
  72. {
  73. PrintHelp();
  74. return 0;
  75. }
  76. WwiseProjectInfo wwiseProjectInfo;
  77. wwiseProjectInfo.Parse();
  78. const FString* PlatformValue = ParamVals.Find(PlatformsSwitch);
  79. if (PlatformValue)
  80. {
  81. TArray<FString> PlatformNames;
  82. PlatformValue->ParseIntoArray(PlatformNames, TEXT(","));
  83. InitParameters.Platforms.Append(PlatformNames);
  84. }
  85. const FString* LanguageValue = ParamVals.Find(LanguagesSwitch);
  86. if (LanguageValue)
  87. {
  88. TArray<FString> LanguageNames;
  89. LanguageValue->ParseIntoArray(LanguageNames, TEXT(","));
  90. InitParameters.Languages.Append(LanguageNames);
  91. }
  92. InitParameters.GenerationMode = AkSoundBankGenerationManager::ESoundBankGenerationMode::Commandlet;
  93. auto AkSettings = GetMutableDefault<UAkSettings>();
  94. auto AkSettingsPerUser = GetMutableDefault<UAkSettingsPerUser>();
  95. auto SoundBankGenerationManager = MakeShared<AkSoundBankGenerationManager, ESPMode::ThreadSafe>(InitParameters);
  96. if (const FString* overrideWwiseConsolePath = ParamVals.Find(WwiseConsolePathSwitch))
  97. {
  98. SoundBankGenerationManager->SetOverrideWwiseConsolePath(*overrideWwiseConsolePath);
  99. }
  100. SoundBankGenerationManager->Init();
  101. SoundBankGenerationManager->DoGeneration();
  102. #endif
  103. return ReturnCode;
  104. }
  105. #undef LOCTEXT_NAMESPACE