From 4407891740f4e0366a52c0a5be833d434c5af473 Mon Sep 17 00:00:00 2001 From: amzn-phist <52085794+amzn-phist@users.noreply.github.com> Date: Fri, 16 Jul 2021 12:25:32 -0500 Subject: [PATCH] Update audio cvars from legacy to AZ_CVARs (#2182) * Upgrade s_AudioLoggingOptions to AZ_CVAR Removes this legacy CVar and reimplements it as an AZ_CVAR with similar functionality of setting flags using alpha characters. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Upgrade s_DrawAudioDebug to AZ_CVAR Removes the legacy CVar and reimplements it as an AZ_CVAR with similar functionality and options. Additional updates to the logging options CVar to fix up flag enums. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Upgrade s_FileCacheManagerDebugFilter to AZ_CVAR Removes the legacy CVar and reimplements it as an AZ_CVAR with similar functionality. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Removal of legacy IConsole dependencies from Audio Moves a g_languageAudio cvar from CrySystem to AudioSystem. Convert all cvar commands to AZ_CONSOLEFREEFUNC's. Remove IConsole.h includes from source files. Removes the CSoundCVars class. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Minor update to cvar comments etc. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> --- Code/Legacy/CrySystem/System.cpp | 14 - Code/Legacy/CrySystem/System.h | 1 - Code/Legacy/CrySystem/SystemInit.cpp | 20 +- .../Code/Include/Engine/AudioLogger.h | 37 +- .../Source/AudioSystemGemSystemComponent.cpp | 13 - Gems/AudioSystem/Code/Source/Engine/ATL.cpp | 20 +- .../Code/Source/Engine/ATLAudioObject.cpp | 17 +- .../Code/Source/Engine/ATLComponents.cpp | 1 - .../Source/Engine/AudioInternalInterfaces.h | 47 +- .../Code/Source/Engine/AudioSystem.cpp | 2 +- .../Code/Source/Engine/FileCacheManager.cpp | 27 +- .../Code/Source/Engine/FileCacheManager.h | 12 - .../Code/Source/Engine/SoundCVars.cpp | 786 +++++++++--------- .../Code/Source/Engine/SoundCVars.h | 49 +- 14 files changed, 511 insertions(+), 535 deletions(-) diff --git a/Code/Legacy/CrySystem/System.cpp b/Code/Legacy/CrySystem/System.cpp index f28a540209..9c903e88df 100644 --- a/Code/Legacy/CrySystem/System.cpp +++ b/Code/Legacy/CrySystem/System.cpp @@ -1431,20 +1431,6 @@ void CSystem::OnLanguageCVarChanged(ICVar* language) } } -////////////////////////////////////////////////////////////////////// -void CSystem::OnLanguageAudioCVarChanged(ICVar* language) -{ - static Audio::SAudioRequest oLanguageRequest; - static Audio::SAudioManagerRequestData oLanguageRequestData; - - if (language && (language->GetType() == CVAR_STRING)) - { - oLanguageRequest.pData = &oLanguageRequestData; - oLanguageRequest.nFlags = Audio::eARF_PRIORITY_HIGH; - Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, oLanguageRequest); - } -} - ////////////////////////////////////////////////////////////////////////// void CSystem::OnLocalizationFolderCVarChanged(ICVar* const pLocalizationFolder) { diff --git a/Code/Legacy/CrySystem/System.h b/Code/Legacy/CrySystem/System.h index 0aecbbd799..5fb294af0c 100644 --- a/Code/Legacy/CrySystem/System.h +++ b/Code/Legacy/CrySystem/System.h @@ -277,7 +277,6 @@ public: ~CSystem(); static void OnLanguageCVarChanged(ICVar* language); - static void OnLanguageAudioCVarChanged(ICVar* language); static void OnLocalizationFolderCVarChanged(ICVar* const pLocalizationFolder); // adding CVAR to toggle assert verbosity level static void OnAssertLevelCvarChanged(ICVar* pArgs); diff --git a/Code/Legacy/CrySystem/SystemInit.cpp b/Code/Legacy/CrySystem/SystemInit.cpp index 3c1f1b4cda..7b7418a783 100644 --- a/Code/Legacy/CrySystem/SystemInit.cpp +++ b/Code/Legacy/CrySystem/SystemInit.cpp @@ -892,16 +892,19 @@ void CSystem::InitLocalization() OpenLanguagePak(language); } - pCVar = m_env.pConsole != 0 ? m_env.pConsole->GetCVar("g_languageAudio") : 0; - if (pCVar) + if (auto console = AZ::Interface::Get(); console != nullptr) { - if (strlen(pCVar->GetString()) == 0) + AZ::CVarFixedString languageAudio; + if (auto result = console->GetCvarValue("g_languageAudio", languageAudio); result == AZ::GetValueResult::Success) { - pCVar->Set(language); - } - else - { - language = pCVar->GetString(); + if (languageAudio.size() == 0) + { + console->PerformCommand(AZStd::string::format("g_languageAudio %s", language.c_str()).c_str()); + } + else + { + language.assign(languageAudio.data(), languageAudio.size()); + } } } OpenLanguageAudioPak(language); @@ -2079,7 +2082,6 @@ void CSystem::CreateSystemVars() //Defines selected language. REGISTER_STRING_CB("g_language", "", VF_NULL, "Defines which language pak is loaded", CSystem::OnLanguageCVarChanged); - REGISTER_STRING_CB("g_languageAudio", "", VF_NULL, "Will automatically match g_language setting unless specified otherwise", CSystem::OnLanguageAudioCVarChanged); #if defined(WIN32) REGISTER_CVAR2("sys_display_threads", &g_cvars.sys_display_threads, 0, 0, "Displays Thread info"); diff --git a/Gems/AudioSystem/Code/Include/Engine/AudioLogger.h b/Gems/AudioSystem/Code/Include/Engine/AudioLogger.h index 375cf18bba..ebfe64249a 100644 --- a/Gems/AudioSystem/Code/Include/Engine/AudioLogger.h +++ b/Gems/AudioSystem/Code/Include/Engine/AudioLogger.h @@ -23,16 +23,18 @@ namespace Audio eALT_ALWAYS, }; - enum EAudioLoggingOptions - { - eALO_NONE = 0, - eALO_ERRORS = AUDIO_BIT(6), // a - eALO_WARNINGS = AUDIO_BIT(7), // b - eALO_COMMENTS = AUDIO_BIT(8), // c - }; - namespace Log { + enum Options : AZ::u8 + { + None = 0, + Errors = (1 << 0), + Warnings = (1 << 1), + Comments = (1 << 2), + }; + + inline AZ::u32 s_audioLogOptions = 0; + #if defined(ENABLE_AUDIO_LOGGING) // Eventually will get rid of the CAudioLogger class and objects and convert // all audio log calls to use Audio::Log::Print. @@ -40,19 +42,6 @@ namespace Audio // arguments in CAudioLogger::Log and call this PrintMsg. inline void PrintMsg(const EAudioLogType type, const char* const message) { - EAudioLoggingOptions logLevel = eALO_NONE; - - auto verbosityVar = AZ::Environment::FindVariable("AudioLogVerbosity"); - if (verbosityVar.IsConstructed()) - { - logLevel = static_cast(*(verbosityVar.Get())); - } - - if (logLevel == eALO_NONE) - { - return; - } - static constexpr const char* AudioWindow = "Audio"; switch (type) @@ -64,7 +53,7 @@ namespace Audio } case eALT_ERROR: { - if (logLevel & eALO_ERRORS) + if ((s_audioLogOptions & Log::Options::Errors) != 0) { AZ_Error(AudioWindow, false, message); } @@ -72,7 +61,7 @@ namespace Audio } case eALT_WARNING: { - if (logLevel & eALO_WARNINGS) + if ((s_audioLogOptions & Log::Options::Warnings) != 0) { AZ_Warning(AudioWindow, false, message); } @@ -80,7 +69,7 @@ namespace Audio } case eALT_COMMENT: { - if (logLevel & eALO_COMMENTS) + if ((s_audioLogOptions & Log::Options::Comments) != 0) { AZ_TracePrintf(AudioWindow, message); } diff --git a/Gems/AudioSystem/Code/Source/AudioSystemGemSystemComponent.cpp b/Gems/AudioSystem/Code/Source/AudioSystemGemSystemComponent.cpp index 64846617b2..c818876f95 100644 --- a/Gems/AudioSystem/Code/Source/AudioSystemGemSystemComponent.cpp +++ b/Gems/AudioSystem/Code/Source/AudioSystemGemSystemComponent.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #if defined(AUDIO_SYSTEM_EDITOR) #include @@ -29,9 +28,7 @@ namespace Audio { // Module globals/statics - CSoundCVars g_audioCVars; CAudioLogger g_audioLogger; - AZ::EnvironmentVariable g_audioVerbosityVar; namespace Platform { @@ -134,13 +131,6 @@ namespace AudioSystemGem return CreateNullAudioSystem(); } - g_audioCVars.RegisterVariables(); - - #if !defined(AUDIO_RELEASE) - g_audioVerbosityVar = AZ::Environment::CreateVariable("AudioLogVerbosity"); - g_audioVerbosityVar.Set(&g_audioCVars.m_nAudioLoggingOptions); - #endif // !AUDIO_RELEASE - bool success = false; if (CreateAudioSystem()) @@ -191,9 +181,6 @@ namespace AudioSystemGem // It should be the last object that is freed from the audio system memory pool before the allocator is destroyed. m_audioSystem.reset(); - g_audioVerbosityVar.Reset(); - g_audioCVars.UnregisterVariables(); - GetISystem()->GetISystemEventDispatcher()->RemoveListener(this); } diff --git a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp index 02b69bc204..575143a8b3 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -1896,9 +1895,14 @@ namespace Audio /////////////////////////////////////////////////////////////////////////////////////////////////// void CAudioTranslationLayer::SetImplLanguage() { - if (ICVar* pCVar = gEnv->pConsole->GetCVar("g_languageAudio")) + if (auto console = AZ::Interface::Get(); console != nullptr) { - AudioSystemImplementationRequestBus::Broadcast(&AudioSystemImplementationRequestBus::Events::SetLanguage, pCVar->GetString()); + AZ::CVarFixedString languageAudio; + if (auto result = console->GetCvarValue("g_languageAudio", languageAudio); result == AZ::GetValueResult::Success) + { + AudioSystemImplementationRequestBus::Broadcast( + &AudioSystemImplementationRequestBus::Events::SetLanguage, languageAudio.data()); + } } } @@ -2014,7 +2018,7 @@ namespace Audio AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Audio); // ToDo: Update to work with Atom? LYN-3677 - /*if (g_audioCVars.m_nDrawAudioDebug > 0) + /*if (CVars::s_debugDrawOptions.GetRawFlags() != 0) { DrawAudioObjectDebugInfo(*pAuxGeom); // needs to be called first so that the rest of the labels are printed // on top (Draw2dLabel doesn't provide a way set which labels are printed on top) @@ -2112,23 +2116,23 @@ namespace Audio { m_oFileCacheMgr.DrawDebugInfo(auxGeom, fPosX, fPosY); - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_IMPL_MEMORY_POOL_USAGE) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::MemoryInfo)) { DrawImplMemoryPoolDebugInfo(auxGeom, fPosX, fPosY); } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_ACTIVE_OBJECTS) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ActiveObjects)) { m_oAudioObjectMgr.DrawDebugInfo(auxGeom, fPosX, fPosY); fPosX += 800.0f; } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_ACTIVE_EVENTS) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ActiveEvents)) { m_oAudioEventMgr.DrawDebugInfo(auxGeom, fPosX, fPosY); } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_LISTENER_SPHERE) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawListener)) { m_oAudioListenerMgr.DrawDebugInfo(auxGeom); } diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp index 29a529ed28..4cf668d749 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp @@ -23,7 +23,6 @@ #include #include -#include namespace Audio { @@ -850,7 +849,7 @@ namespace Audio { const float fDist = vPos.GetDistance(vListenerPos); - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_SPHERES) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawObjects)) { const SAuxGeomRenderFlags nPreviousRenderFlags = auxGeom.GetRenderFlags(); SAuxGeomRenderFlags nNewRenderFlags(e_Def3DPublicRenderflags | e_AlphaBlended); @@ -865,7 +864,7 @@ namespace Audio const float fFontSize = 1.3f; const float fLineHeight = 12.0f; - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_STATES) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectStates)) { AZ::Vector3 vSwitchPos(vScreenPos); @@ -901,7 +900,7 @@ namespace Audio const AZ::Color normalTextColor(0.75f, 0.75f, 0.75f, 1.f); const AZ::Color dimmedTextColor(0.5f, 0.5f, 0.5f, 1.f); - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_LABEL) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectLabels)) { const TAudioObjectID nObjectID = GetID(); auxGeom.Draw2dLabel( @@ -931,7 +930,7 @@ namespace Audio ); } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_TRIGGERS) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectTriggers)) { AZStd::string triggerStringFormatted; @@ -963,7 +962,7 @@ namespace Audio triggerStringFormatted.c_str()); } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_RTPCS) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectRtpcs)) { AZ::Vector3 vRtpcPos(vScreenPos); @@ -990,7 +989,7 @@ namespace Audio } } - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBJECT_ENVIRONMENTS) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::ObjectEnvironments)) { AZ::Vector3 vEnvPos(vScreenPos); @@ -1041,8 +1040,8 @@ namespace Audio newRenderFlags.SetCullMode(e_CullModeNone); auxGeom.SetRenderFlags(newRenderFlags); - const bool drawRays = ((g_audioCVars.m_nDrawAudioDebug & eADDF_DRAW_OBSTRUCTION_RAYS) != 0); - const bool drawLabels = ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_OBSTRUCTION_RAY_LABELS) != 0); + const bool drawRays = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawRays); + const bool drawLabels = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::RayLabels); size_t numRays = m_obstOccType == eAOOCT_SINGLE_RAY ? 1 : s_maxRaysPerObject; for (size_t rayIndex = 0; rayIndex < numRays; ++rayIndex) diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp index a2244823eb..c92fe00ba8 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp @@ -29,7 +29,6 @@ #include #include -#include namespace Audio { diff --git a/Gems/AudioSystem/Code/Source/Engine/AudioInternalInterfaces.h b/Gems/AudioSystem/Code/Source/Engine/AudioInternalInterfaces.h index a61ab28c67..8f39bfbb8c 100644 --- a/Gems/AudioSystem/Code/Source/Engine/AudioInternalInterfaces.h +++ b/Gems/AudioSystem/Code/Source/Engine/AudioInternalInterfaces.h @@ -899,25 +899,38 @@ namespace Audio /////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(AUDIO_RELEASE) // Filter for drawing debug info to the screen - enum EAudioDebugDrawFilter : TATLEnumFlagsType + namespace DebugDraw { - eADDF_NONE = 0, - eADDF_DRAW_SPHERES = AUDIO_BIT(6),// a - eADDF_SHOW_OBJECT_LABEL = AUDIO_BIT(7),// b - eADDF_SHOW_OBJECT_TRIGGERS = AUDIO_BIT(8),// c - eADDF_SHOW_OBJECT_STATES = AUDIO_BIT(9),// d - eADDF_SHOW_OBJECT_RTPCS = AUDIO_BIT(10),// e - eADDF_SHOW_OBJECT_ENVIRONMENTS = AUDIO_BIT(11),// f - eADDF_DRAW_OBSTRUCTION_RAYS = AUDIO_BIT(12),// g - eADDF_SHOW_OBSTRUCTION_RAY_LABELS = AUDIO_BIT(13),// h - eADDF_DRAW_LISTENER_SPHERE = AUDIO_BIT(14),// i + enum Options : AZ::u32 + { + None = 0, + DrawObjects = (1 << 0), + ObjectLabels = (1 << 1), + ObjectTriggers = (1 << 2), + ObjectStates = (1 << 3), + ObjectRtpcs = (1 << 4), + ObjectEnvironments = (1 << 5), + DrawRays = (1 << 6), + RayLabels = (1 << 7), + DrawListener = (1 << 8), + ActiveEvents = (1 << 9), + ActiveObjects = (1 << 10), + FileCacheInfo = (1 << 11), + MemoryInfo = (1 << 12), + }; + } - eADDF_SHOW_ACTIVE_EVENTS = AUDIO_BIT(27),// v - eADDF_SHOW_ACTIVE_OBJECTS = AUDIO_BIT(28),// w - eADDF_SHOW_FILECACHE_MANAGER_INFO = AUDIO_BIT(29),// x - - eADDF_SHOW_IMPL_MEMORY_POOL_USAGE = AUDIO_BIT(30),// y - }; + namespace FileCacheManagerDebugDraw + { + enum Options : AZ::u8 + { + All = 0, + Global = (1 << 0), + LevelSpecific = (1 << 1), + UseCounted = (1 << 2), + Loaded = (1 << 3), + }; + } #endif // !AUDIO_RELEASE } // namespace Audio diff --git a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp index d65d27667f..9babbac69d 100644 --- a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp @@ -699,7 +699,7 @@ namespace Audio { AZ_Assert(gEnv->mMainThreadId == CryGetCurrentThreadId(), "AudioSystem::DrawAudioDebugData - called from non-Main thread!"); - if (g_audioCVars.m_nDrawAudioDebug > 0) + if (CVars::s_debugDrawOptions.GetRawFlags() != 0) { SAudioRequest oRequest; oRequest.nFlags = (eARF_PRIORITY_HIGH | eARF_EXECUTE_BLOCKING); diff --git a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp index 4749da5568..6a2e3e36e9 100644 --- a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp @@ -339,20 +339,17 @@ namespace Audio /////////////////////////////////////////////////////////////////////////////////////////////// void CFileCacheManager::DrawDebugInfo(IRenderAuxGeom& auxGeom, const float posX, const float posY) { - if ((g_audioCVars.m_nDrawAudioDebug & eADDF_SHOW_FILECACHE_MANAGER_INFO) != 0) + if (CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::FileCacheInfo)) { EATLDataScope dataScope = eADS_ALL; - if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_ALL) == 0) + if (CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Global)) { - if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_GLOBALS) != 0) - { - dataScope = eADS_GLOBAL; - } - else if ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LEVEL_SPECIFICS) != 0) - { - dataScope = eADS_LEVEL_SPECIFIC; - } + dataScope = eADS_GLOBAL; + } + else if (CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::LevelSpecific)) + { + dataScope = eADS_LEVEL_SPECIFIC; } const auto frameTime = AZStd::chrono::system_clock::now(); @@ -381,11 +378,11 @@ namespace Audio "FileCacheManager (%zu of %zu KiB) [Entries: %zu]", m_currentByteTotal >> 10, m_maxByteTotal >> 10, m_audioFileEntries.size()); positionY += 15.0f; - bool displayAll = (g_audioCVars.m_nFileCacheManagerDebugFilter == eAFCMDF_ALL); - bool displayGlobals = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_GLOBALS) != 0); - bool displayLevels = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LEVEL_SPECIFICS) != 0); - bool displayUseCounted = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_USE_COUNTED) != 0); - bool displayLoaded = ((g_audioCVars.m_nFileCacheManagerDebugFilter & eAFCMDF_LOADED) != 0); + const bool displayAll = CVars::s_fcmDrawOptions.GetRawFlags() == 0; + const bool displayGlobals = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Global); + const bool displayLevels = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::LevelSpecific); + const bool displayUseCounted = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::UseCounted); + const bool displayLoaded = CVars::s_fcmDrawOptions.AreAllFlagsActive(FileCacheManagerDebugDraw::Options::Loaded); for (auto& audioFileEntryPair : m_audioFileEntries) { diff --git a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.h b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.h index a9b62f10b3..e9d63ddd2b 100644 --- a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.h +++ b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.h @@ -100,16 +100,4 @@ namespace Audio size_t m_currentByteTotal; size_t m_maxByteTotal; }; - - /////////////////////////////////////////////////////////////////////////////////////////////// - // Filter for drawing debug info to the screen - enum EAudioFileCacheManagerDebugFilter - { - eAFCMDF_ALL = 0, - eAFCMDF_GLOBALS = AUDIO_BIT(6), // a - eAFCMDF_LEVEL_SPECIFICS = AUDIO_BIT(7), // b - eAFCMDF_USE_COUNTED = AUDIO_BIT(8), // c - eAFCMDF_LOADED = AUDIO_BIT(9), // d - }; - } // namespace Audio diff --git a/Gems/AudioSystem/Code/Source/Engine/SoundCVars.cpp b/Gems/AudioSystem/Code/Source/Engine/SoundCVars.cpp index 83e1139495..c049f76027 100644 --- a/Gems/AudioSystem/Code/Source/Engine/SoundCVars.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/SoundCVars.cpp @@ -8,12 +8,12 @@ #include #include +#include #include +#include #include -#include -#include #include @@ -149,6 +149,18 @@ namespace Audio::CVars "2: All AudioProxy's initialize asynchronously.\n" "Usage: s_AudioProxiesInitType=2\n"); + auto OnChangeAudioLanguage = []([[maybe_unused]] const AZ::CVarFixedString& language) -> void + { + SAudioRequest languageRequest; + SAudioManagerRequestData languageRequestData; + + languageRequest.pData = &languageRequestData; + languageRequest.nFlags = Audio::eARF_PRIORITY_HIGH; + AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequest, languageRequest); + }; + + AZ_CVAR(AZ::CVarFixedString, g_languageAudio, "", OnChangeAudioLanguage, AZ::ConsoleFunctorFlags::Null, ""); + #if !defined(AUDIO_RELEASE) AZ_CVAR(bool, s_IgnoreWindowFocus, false, nullptr, AZ::ConsoleFunctorFlags::Null, @@ -173,368 +185,370 @@ namespace Audio::CVars nullptr, AZ::ConsoleFunctorFlags::Null, "Filters debug drawing to only audio objects whose name matches this filter as a sub-string.\n" "Usage: s_AudioObjectsDebugFilter=weapon_axe\n"); -#endif // !AUDIO_RELEASE -} // namespace Audio::CVars - -namespace Audio -{ - extern CAudioLogger g_audioLogger; - - /////////////////////////////////////////////////////////////////////////////////////////////////// - CSoundCVars::CSoundCVars() - #if !defined(AUDIO_RELEASE) - : m_nDrawAudioDebug(0) - , m_nFileCacheManagerDebugFilter(0) - , m_nAudioLoggingOptions(0) - #endif // !AUDIO_RELEASE + auto OnChangeLogOptions = [](const AZ::CVarFixedString& options) -> void { - } - - /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::RegisterVariables() - { -#if !defined(AUDIO_RELEASE) - REGISTER_COMMAND("s_ExecuteTrigger", CmdExecuteTrigger, VF_CHEAT, - "Execute an Audio Trigger.\n" - "The first argument is the name of the AudioTrigger to be executed, the second argument is an optional AudioObject ID.\n" - "If the second argument is provided, the AudioTrigger is executed on the AudioObject with the given ID,\n" - "otherwise, the AudioTrigger is executed on the GlobalAudioObject\n" - "Usage: s_ExecuteTrigger Play_chicken_idle 605 or s_ExecuteTrigger MuteDialog\n"); - - REGISTER_COMMAND("s_StopTrigger", CmdStopTrigger, VF_CHEAT, - "Execute an Audio Trigger.\n" - "The first argument is the name of the AudioTrigger to be stopped, the second argument is an optional AudioObject ID.\n" - "If the second argument is provided, the AudioTrigger is stopped on the AudioObject with the given ID,\n" - "otherwise, the AudioTrigger is stopped on the GlobalAudioObject\n" - "Usage: s_StopTrigger Play_chicken_idle 605 or s_StopTrigger MuteDialog\n"); - - REGISTER_COMMAND("s_SetRtpc", CmdSetRtpc, VF_CHEAT, - "Set an Audio RTPC value.\n" - "The first argument is the name of the AudioRtpc to be set, the second argument is the float value to be set," - "the third argument is an optional AudioObject ID.\n" - "If the third argument is provided, the AudioRtpc is set on the AudioObject with the given ID,\n" - "otherwise, the AudioRtpc is set on the GlobalAudioObject\n" - "Usage: s_SetRtpc character_speed 0.0 601 or s_SetRtpc volume_music 1.0\n"); - - REGISTER_COMMAND("s_SetSwitchState", CmdSetSwitchState, VF_CHEAT, - "Set an Audio Switch to a provided State.\n" - "The first argument is the name of the AudioSwitch to, the second argument is the name of the SwitchState to be set," - "the third argument is an optional AudioObject ID.\n" - "If the third argument is provided, the AudioSwitch is set on the AudioObject with the given ID,\n" - "otherwise, the AudioSwitch is set on the GlobalAudioObject\n" - "Usage: s_SetSwitchState SurfaceType concrete 601 or s_SetSwitchState weather rain\n"); - - REGISTER_COMMAND("s_LoadPreload", CmdLoadPreload, VF_CHEAT, - "Load an Audio Preload to the FileCacheManager.\n" - "The first argument is the name of the ATL preload.\n" - "Usage: s_LoadPreload GlobalBank\n"); - - REGISTER_COMMAND("s_UnloadPreload", CmdUnloadPreload, VF_CHEAT, - "Unload an Audio Preload from the FileCacheManager.\n" - "The first argument is the name of the ATL Prelaod.\n" - "Usage: s_UnloadPreload GlobalBank\n"); - - REGISTER_COMMAND("s_PlayFile", CmdPlayFile, VF_CHEAT, - "Play an audio file directly. Uses Audio Input Source (Wwise).\n" - "First argument is the name of the file to play. Only .wav and .pcm (raw) files are supported right now.\n" - "Second argument is the name of the audio trigger to use." - "Usage: s_PlayFile \"sounds\\wwise\\external_sources\\sfx\\my_file.wav\" Play_audio_input_2D\n" - ); - - REGISTER_COMMAND("s_Microphone", CmdMicrophone, VF_CHEAT, - "Turn on/off microphone input. Uses Audio Input Source (Wwise).\n" - "First argument is 0 or 1 to turn off or on the Microphone, respectively.\n" - "Second argument is the name of the ATL trigger to use (when turning microphone on) for Audio Input.\n" - "Usage: s_Microphone 1 Play_audio_input_2D\n" - "Usage: s_Microphone 0\n" - ); - - REGISTER_COMMAND("s_PlayExternalSource", CmdPlayExternalSource, VF_CHEAT, - "Execute an 'External Source' audio trigger.\n" - "The first argument is the name of the audio trigger to execute.\n" - "The second argument is the collection Id.\n" - "The third argument is the language Id.\n" - "The fourth argument is the file Id.\n" - "Usage: s_PlayExternalSource Play_ext_vo 0 0 1\n" - ); - - REGISTER_COMMAND("s_SetPanningMode", CmdSetPanningMode, VF_CHEAT, - "Set the Panning mode to either 'speakers' or 'headphones'.\n" - "Speakers will have a 60 degree angle from the listener to the L/R speakers.\n" - "Headphones will have a 180 degree angle from the listener to the L/R speakers.\n" - "Usage: s_SetPanningMode speakers (default)\n" - "Usage: s_SetPanningMode headphones\n" - ); - - REGISTER_CVAR2("s_DrawAudioDebug", &m_nDrawAudioDebug, 0, VF_CHEAT | VF_CHEAT_NOCHECK | VF_BITFIELD, - "Draws AudioTranslationLayer related debug data to the screen.\n" - "Usage: s_DrawAudioDebug [0ab...] (flags can be combined)\n" - "0: No audio debug info on the screen.\n" - "a: Draw spheres around active audio objects.\n" - "b: Show text labels for active audio objects.\n" - "c: Show trigger names for active audio objects.\n" - "d: Show current states for active audio objects.\n" - "e: Show RTPC values for active audio objects.\n" - "f: Show Environment amounts for active audio objects.\n" - "g: Draw occlusion rays.\n" - "h: Show occlusion ray labels.\n" - "i: Draw sphere around active audio listener.\n" - "v: List active Events.\n" - "w: List active Audio Objects.\n" - "x: Show FileCache Manager debug info.\n" - "y: Show memory pool usage info for the audio impl.\n" - ); - - REGISTER_CVAR2("s_FileCacheManagerDebugFilter", &m_nFileCacheManagerDebugFilter, 0, VF_CHEAT | VF_CHEAT_NOCHECK | VF_BITFIELD, - "Allows for filtered display of the different AFCM entries such as Globals, Level Specifics, Game Hints and so on.\n" - "Usage: s_FileCacheManagerDebugFilter [0ab...] (flags can be combined)\n" - "Default: 0 (all)\n" - "a: Globals\n" - "b: Level Specifics\n" - "c: Game Hints\n" - "d: Currently Loaded\n"); - - REGISTER_CVAR2("s_AudioLoggingOptions", &m_nAudioLoggingOptions, AlphaBits("ab"), VF_CHEAT | VF_CHEAT_NOCHECK | VF_BITFIELD, - "Toggles the logging of audio related messages.\n" - "Usage: s_AudioLoggingOptions [ab...] (flags can be combined)\n" - "Default: ab (Errors & Warnings)\n" - "a: Errors\n" - "b: Warnings\n" - "c: Comments\n"); -#endif // !AUDIO_RELEASE - } - - /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::UnregisterVariables() - { -#if !defined(AUDIO_RELEASE) - UNREGISTER_COMMAND("s_ExecuteTrigger"); - UNREGISTER_COMMAND("s_StopTrigger"); - UNREGISTER_COMMAND("s_SetRtpc"); - UNREGISTER_COMMAND("s_SetSwitchState"); - UNREGISTER_COMMAND("s_LoadPreload"); - UNREGISTER_COMMAND("s_UnloadPreload"); - UNREGISTER_COMMAND("s_PlayFile"); - UNREGISTER_COMMAND("s_PlayExternalSource"); - UNREGISTER_COMMAND("s_SetPanningMode"); - UNREGISTER_CVAR("s_DrawAudioDebug"); - UNREGISTER_CVAR("s_FileCacheManagerDebugFilter"); - UNREGISTER_CVAR("s_AudioLoggingOptions"); -#endif // !AUDIO_RELEASE - } - - -#if !defined(AUDIO_RELEASE) - /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdExecuteTrigger(IConsoleCmdArgs* pCmdArgs) - { - const int nArgCount = pCmdArgs->GetArgCount(); - - if ((nArgCount == 2) || (nArgCount == 3)) + if (options == "0") { - TAudioControlID nTriggerID = INVALID_AUDIO_CONTROL_ID; - AudioSystemRequestBus::BroadcastResult(nTriggerID, &AudioSystemRequestBus::Events::GetAudioTriggerID, pCmdArgs->GetArg(1)); + Audio::Log::s_audioLogOptions = Log::Options::None; + return; + } - if (nTriggerID != INVALID_AUDIO_CONTROL_ID) + Audio::Flags flags; + flags.SetFlags(Log::Options::Errors, options.contains("a")); + flags.SetFlags(Log::Options::Warnings, options.contains("b")); + flags.SetFlags(Log::Options::Comments, options.contains("c")); + Audio::Log::s_audioLogOptions = flags.GetRawFlags(); + }; + + AZ_CVAR(AZ::CVarFixedString, s_AudioLoggingOptions, "ab", + OnChangeLogOptions, + AZ::ConsoleFunctorFlags::Null, + "Toggles the log level of audio related messages.\n" + "Usage: s_AudioLoggingOptions=abc (flags can be combined)\n" + "Default: ab (Errors & Warnings)\n" + "a: Errors\n" + "b: Warnings\n" + "c: Comments\n"); + + auto OnChangeDebugDrawOptions = [](const AZ::CVarFixedString& options) -> void + { + s_debugDrawOptions.ClearAllFlags(); + if (options == "0") + { + return; + } + + s_debugDrawOptions.SetFlags(DebugDraw::Options::DrawObjects, options.contains("a")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ObjectLabels, options.contains("b")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ObjectTriggers, options.contains("c")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ObjectStates, options.contains("d")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ObjectRtpcs, options.contains("e")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ObjectEnvironments, options.contains("f")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::DrawRays, options.contains("g")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::RayLabels, options.contains("h")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::DrawListener, options.contains("i")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ActiveEvents, options.contains("v")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::ActiveObjects, options.contains("w")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::FileCacheInfo, options.contains("x")); + s_debugDrawOptions.SetFlags(DebugDraw::Options::MemoryInfo, options.contains("y")); + }; + + AZ_CVAR(AZ::CVarFixedString, s_DrawAudioDebug, "", + OnChangeDebugDrawOptions, + AZ::ConsoleFunctorFlags::IsCheat, + "Draws AudioTranslationLayer related debug data to the screen.\n" + "Usage: s_DrawAudioDebug=abcde (flags can be combined)\n" + "0: Turn off.\n" + "a: Draw spheres around active audio objects.\n" + "b: Show text labels for active audio objects.\n" + "c: Show trigger names for active audio objects.\n" + "d: Show current states for active audio objects.\n" + "e: Show RTPC values for active audio objects.\n" + "f: Show Environment amounts for active audio objects.\n" + "g: Draw occlusion rays.\n" + "h: Show occlusion ray labels.\n" + "i: Draw sphere around active audio listener.\n" + "v: List active Events.\n" + "w: List active Audio Objects.\n" + "x: Show FileCache Manager debug info.\n" + "y: Show memory usage info for the audio engine.\n"); + + auto OnChangeFileCacheManagerFilterOptions = [](const AZ::CVarFixedString& options) -> void + { + s_fcmDrawOptions.ClearAllFlags(); + if (options == "0") + { + return; + } + + s_fcmDrawOptions.SetFlags(FileCacheManagerDebugDraw::Options::Global, options.contains("a")); + s_fcmDrawOptions.SetFlags(FileCacheManagerDebugDraw::Options::LevelSpecific, options.contains("b")); + s_fcmDrawOptions.SetFlags(FileCacheManagerDebugDraw::Options::UseCounted, options.contains("c")); + s_fcmDrawOptions.SetFlags(FileCacheManagerDebugDraw::Options::Loaded, options.contains("d")); + }; + + AZ_CVAR(AZ::CVarFixedString, s_FileCacheManagerDebugFilter, "", + OnChangeFileCacheManagerFilterOptions, + AZ::ConsoleFunctorFlags::IsCheat, + "Allows for filtered display of the file cache entries such as Globals, Level Specifics, Use Counted and so on.\n" + "Usage: s_FileCacheManagerDebugFilter [0ab...] (flags can be combined)\n" + "Default: 0 (all)\n" + "a: Globals\n" + "b: Level Specifics\n" + "c: Use Counted\n" + "d: Currently Loaded\n"); + + static void s_ExecuteTrigger(const AZ::ConsoleCommandContainer& args); + static void s_StopTrigger(const AZ::ConsoleCommandContainer& args); + static void s_SetRtpc(const AZ::ConsoleCommandContainer& args); + static void s_SetSwitchState(const AZ::ConsoleCommandContainer& args); + static void s_LoadPreload(const AZ::ConsoleCommandContainer& args); + static void s_UnloadPreload(const AZ::ConsoleCommandContainer& args); + static void s_PlayFile(const AZ::ConsoleCommandContainer& args); + static void s_Microphone(const AZ::ConsoleCommandContainer& args); + static void s_PlayExternalSource(const AZ::ConsoleCommandContainer& args); + static void s_SetPanningMode(const AZ::ConsoleCommandContainer& args); + + AZ_CONSOLEFREEFUNC(s_ExecuteTrigger, AZ::ConsoleFunctorFlags::IsCheat, + "Execute an Audio Trigger.\n" + "The first argument is the name of the AudioTrigger to be executed, the second argument is an optional AudioObject ID.\n" + "If the second argument is provided, the AudioTrigger is executed on the AudioObject with the given ID,\n" + "otherwise, the AudioTrigger is executed on the GlobalAudioObject\n" + "Usage: s_ExecuteTrigger Play_chicken_idle 605 or s_ExecuteTrigger MuteDialog\n"); + + AZ_CONSOLEFREEFUNC(s_StopTrigger, AZ::ConsoleFunctorFlags::IsCheat, + "Stops an Audio Trigger.\n" + "The first argument is the name of the AudioTrigger to be stopped, the second argument is an optional AudioObject ID.\n" + "If the second argument is provided, the AudioTrigger is stopped on the AudioObject with the given ID,\n" + "otherwise, the AudioTrigger is stopped on the GlobalAudioObject\n" + "Usage: s_StopTrigger Play_chicken_idle 605 or s_StopTrigger MuteDialog\n"); + + AZ_CONSOLEFREEFUNC(s_SetRtpc, AZ::ConsoleFunctorFlags::IsCheat, + "Set an Audio RTPC value.\n" + "The first argument is the name of the AudioRtpc to be set, the second argument is the float value to be set," + "the third argument is an optional AudioObject ID.\n" + "If the third argument is provided, the AudioRtpc is set on the AudioObject with the given ID,\n" + "otherwise, the AudioRtpc is set on the GlobalAudioObject\n" + "Usage: s_SetRtpc character_speed 0.0 601 or s_SetRtpc volume_music 1.0\n"); + + AZ_CONSOLEFREEFUNC(s_SetSwitchState, AZ::ConsoleFunctorFlags::IsCheat, + "Set an Audio Switch to a provided State.\n" + "The first argument is the name of the AudioSwitch to, the second argument is the name of the SwitchState to be set," + "the third argument is an optional AudioObject ID.\n" + "If the third argument is provided, the AudioSwitch is set on the AudioObject with the given ID,\n" + "otherwise, the AudioSwitch is set on the GlobalAudioObject\n" + "Usage: s_SetSwitchState SurfaceType concrete 601 or s_SetSwitchState weather rain\n"); + + AZ_CONSOLEFREEFUNC(s_LoadPreload, AZ::ConsoleFunctorFlags::IsCheat, + "Load an Audio Preload to the FileCacheManager.\n" + "The first argument is the name of the ATL preload.\n" + "Usage: s_LoadPreload GlobalBank\n"); + + AZ_CONSOLEFREEFUNC(s_UnloadPreload, AZ::ConsoleFunctorFlags::IsCheat, + "Unload an Audio Preload from the FileCacheManager.\n" + "The first argument is the name of the ATL Prelaod.\n" + "Usage: s_UnloadPreload GlobalBank\n"); + + AZ_CONSOLEFREEFUNC(s_PlayFile, AZ::ConsoleFunctorFlags::IsCheat, + "Play an audio file directly.\n" + "First argument is the name of the file to play. Only .wav and .pcm (raw) files are supported right now.\n" + "Second argument is the name of the audio trigger to use." + "Usage: s_PlayFile \"sounds\\wwise\\external_sources\\sfx\\my_file.wav\" Play_audio_input_2D\n"); + + AZ_CONSOLEFREEFUNC(s_Microphone, AZ::ConsoleFunctorFlags::IsCheat, + "Turn on/off microphone input.\n" + "First argument is 0 or 1 to turn off or on the Microphone, respectively.\n" + "Second argument is the name of the ATL trigger to use (when turning microphone on) for Audio Input.\n" + "Usage: s_Microphone 1 Play_audio_input_2D\n" + "Usage: s_Microphone 0\n"); + + AZ_CONSOLEFREEFUNC(s_PlayExternalSource, AZ::ConsoleFunctorFlags::IsCheat, + "Execute an 'External Source' audio trigger.\n" + "The first argument is the name of the audio trigger to execute.\n" + "The second argument is the collection Id.\n" + "The third argument is the language Id.\n" + "The fourth argument is the file Id.\n" + "Usage: s_PlayExternalSource Play_external_VO 0 0 1\n"); + + AZ_CONSOLEFREEFUNC(s_SetPanningMode, AZ::ConsoleFunctorFlags::IsCheat, + "Set the Panning mode to either 'speakers' or 'headphones'.\n" + "Speakers will have a 60 degree angle from the listener to the L/R speakers.\n" + "Headphones will have a 180 degree angle from the listener to the L/R speakers.\n" + "Usage: s_SetPanningMode speakers (default)\n" + "Usage: s_SetPanningMode headphones\n"); + + /////////////////////////////////////////////////////////////////////////////////////////////////// + static void s_ExecuteTrigger(const AZ::ConsoleCommandContainer& args) + { + if (args.size() == 1 || args.size() == 2) + { + AZStd::string triggerName(args[0]); + TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID; + AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName.c_str()); + + if (triggerId != INVALID_AUDIO_CONTROL_ID) { - TAudioObjectID nObjectID = INVALID_AUDIO_OBJECT_ID; - if (nArgCount == 3) + TAudioObjectID objectId = INVALID_AUDIO_OBJECT_ID; + if (args.size() == 2) { - const int nTempID = atoi(pCmdArgs->GetArg(2)); - if (nTempID > 0) + if (!AZ::ConsoleTypeHelpers::StringToValue(objectId, args[1])) { - nObjectID = static_cast(nTempID); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %s", pCmdArgs->GetArg(2)); - } - } - - SAudioRequest oRequest; - SAudioObjectRequestData oRequestData(nTriggerID, 0.0f); - - oRequest.nAudioObjectID = nObjectID; - oRequest.nFlags = eARF_PRIORITY_NORMAL; - oRequest.pData = &oRequestData; - - AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, oRequest); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Unknown trigger name: %s", pCmdArgs->GetArg(1)); - } - } - else - { - g_audioLogger.Log(eALT_ERROR, "Usage: s_ExecuteTrigger [TriggerName] [[Optional Object ID]]"); - } - } - - /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdStopTrigger(IConsoleCmdArgs* pCmdArgs) - { - const int nArgCount = pCmdArgs->GetArgCount(); - - if ((nArgCount == 2) || (nArgCount == 3)) - { - TAudioControlID nTriggerID = INVALID_AUDIO_CONTROL_ID; - AudioSystemRequestBus::BroadcastResult(nTriggerID, &AudioSystemRequestBus::Events::GetAudioTriggerID, pCmdArgs->GetArg(1)); - - if (nTriggerID != INVALID_AUDIO_CONTROL_ID) - { - TAudioObjectID nObjectID = INVALID_AUDIO_OBJECT_ID; - if (nArgCount == 3) - { - const int nTempID = atoi(pCmdArgs->GetArg(2)); - if (nTempID > 0) - { - nObjectID = static_cast(nTempID); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %s", pCmdArgs->GetArg(2)); - } - } - - SAudioRequest oRequest; - SAudioObjectRequestData oRequestData(nTriggerID); - - oRequest.nAudioObjectID = nObjectID; - oRequest.nFlags = eARF_PRIORITY_NORMAL; - oRequest.pData = &oRequestData; - - AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, oRequest); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Unknown trigger name: %s", pCmdArgs->GetArg(1)); - } - } - else - { - g_audioLogger.Log(eALT_ERROR, "Usage: s_StopTrigger [TriggerName] [[Optional Object ID]]"); - } - } - - /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdSetRtpc(IConsoleCmdArgs* pCmdArgs) - { - const int nArgCount = pCmdArgs->GetArgCount(); - - if ((nArgCount == 3) || (nArgCount == 4)) - { - TAudioControlID nRtpcID = INVALID_AUDIO_CONTROL_ID; - AudioSystemRequestBus::BroadcastResult(nRtpcID, &AudioSystemRequestBus::Events::GetAudioRtpcID, pCmdArgs->GetArg(1)); - - if (nRtpcID != INVALID_AUDIO_CONTROL_ID) - { - double fValue = atof(pCmdArgs->GetArg(2)); - - TAudioObjectID nObjectID = INVALID_AUDIO_OBJECT_ID; - if (nArgCount == 4) - { - const int nTempID = atoi(pCmdArgs->GetArg(3)); - if (nTempID > 0) - { - nObjectID = static_cast(nTempID); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %s", pCmdArgs->GetArg(3)); + g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %.*s", AZ_STRING_ARG(args[1])); return; } } - SAudioRequest oRequest; - SAudioObjectRequestData oRequestData(nRtpcID, static_cast(fValue)); + SAudioRequest request; + SAudioObjectRequestData requestData(triggerId, 0.0f); - oRequest.nAudioObjectID = nObjectID; - oRequest.nFlags = eARF_PRIORITY_NORMAL; - oRequest.pData = &oRequestData; + request.nAudioObjectID = objectId; + request.nFlags = eARF_PRIORITY_NORMAL; + request.pData = &requestData; - AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, oRequest); + AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request); } else { - g_audioLogger.Log(eALT_ERROR, "Unknown Rtpc name: %s", pCmdArgs->GetArg(1)); + g_audioLogger.Log(eALT_ERROR, "Unknown trigger name: %.*s", AZ_STRING_ARG(args[0])); } } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_SetRtpc [RtpcName] [RtpcValue] [[Optional Object ID]]"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_ExecuteTrigger TriggerName [Optional Object ID]"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdSetSwitchState(IConsoleCmdArgs* pCmdArgs) + static void s_StopTrigger(const AZ::ConsoleCommandContainer& args) { - const int nArgCount = pCmdArgs->GetArgCount(); - - if ((nArgCount == 3) || (nArgCount == 4)) + if (args.size() == 1 || args.size() == 2) { - TAudioControlID nSwitchID = INVALID_AUDIO_CONTROL_ID; - AudioSystemRequestBus::BroadcastResult(nSwitchID, &AudioSystemRequestBus::Events::GetAudioSwitchID, pCmdArgs->GetArg(1)); + AZStd::string triggerName(args[0]); + TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID; + AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName.c_str()); - if (nSwitchID != INVALID_AUDIO_CONTROL_ID) + if (triggerId != INVALID_AUDIO_CONTROL_ID) { - TAudioSwitchStateID nSwitchStateID = INVALID_AUDIO_SWITCH_STATE_ID; - AudioSystemRequestBus::BroadcastResult(nSwitchStateID, &AudioSystemRequestBus::Events::GetAudioSwitchStateID, nSwitchID, pCmdArgs->GetArg(2)); - - if (nSwitchStateID != INVALID_AUDIO_SWITCH_STATE_ID) + TAudioObjectID objectId = INVALID_AUDIO_OBJECT_ID; + if (args.size() == 2) { - TAudioObjectID nObjectID = INVALID_AUDIO_OBJECT_ID; - if (nArgCount == 4) + if (!AZ::ConsoleTypeHelpers::StringToValue(objectId, args[1])) { - const int nTempID = atoi(pCmdArgs->GetArg(3)); - if (nTempID > 0) + g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %.*s", AZ_STRING_ARG(args[1])); + return; + } + } + + SAudioRequest request; + SAudioObjectRequestData requestData(triggerId); + + request.nAudioObjectID = objectId; + request.nFlags = eARF_PRIORITY_NORMAL; + request.pData = &requestData; + + AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request); + } + else + { + g_audioLogger.Log(eALT_ERROR, "Unknown trigger name: %.*s", AZ_STRING_ARG(args[0])); + } + } + else + { + g_audioLogger.Log(eALT_ERROR, "Usage: s_StopTrigger TriggerName [Optional Object ID]"); + } + } + + /////////////////////////////////////////////////////////////////////////////////////////////////// + static void s_SetRtpc(const AZ::ConsoleCommandContainer& args) + { + if (args.size() == 2 || args.size() == 3) + { + AZStd::string rtpcName(args[0]); + TAudioControlID rtpcId = INVALID_AUDIO_CONTROL_ID; + AudioSystemRequestBus::BroadcastResult(rtpcId, &AudioSystemRequestBus::Events::GetAudioRtpcID, rtpcName.c_str()); + + if (rtpcId != INVALID_AUDIO_CONTROL_ID) + { + float value = 0.f; + if (!AZ::ConsoleTypeHelpers::StringToValue(value, args[1])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid float number: %.*s", AZ_STRING_ARG(args[1])); + return; + } + + TAudioObjectID objectId = INVALID_AUDIO_OBJECT_ID; + if (args.size() == 3) + { + if (!AZ::ConsoleTypeHelpers::StringToValue(objectId, args[2])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %.*s", AZ_STRING_ARG(args[2])); + return; + } + } + + SAudioRequest request; + SAudioObjectRequestData requestData(rtpcId, value); + + request.nAudioObjectID = objectId; + request.nFlags = eARF_PRIORITY_NORMAL; + request.pData = &requestData; + + AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request); + } + else + { + g_audioLogger.Log(eALT_ERROR, "Unknown Rtpc name: %.*s", AZ_STRING_ARG(args[0])); + } + } + else + { + g_audioLogger.Log(eALT_ERROR, "Usage: s_SetRtpc RtpcName RtpcValue [Optional Object ID]"); + } + } + + /////////////////////////////////////////////////////////////////////////////////////////////////// + static void s_SetSwitchState(const AZ::ConsoleCommandContainer& args) + { + if (args.size() == 2 || args.size() == 3) + { + AZStd::string switchName(args[0]); + TAudioControlID switchId = INVALID_AUDIO_CONTROL_ID; + AudioSystemRequestBus::BroadcastResult(switchId, &AudioSystemRequestBus::Events::GetAudioSwitchID, switchName.c_str()); + + if (switchId != INVALID_AUDIO_CONTROL_ID) + { + AZStd::string stateName(args[1]); + TAudioSwitchStateID stateId = INVALID_AUDIO_SWITCH_STATE_ID; + AudioSystemRequestBus::BroadcastResult( + stateId, &AudioSystemRequestBus::Events::GetAudioSwitchStateID, switchId, stateName.c_str()); + + if (stateId != INVALID_AUDIO_SWITCH_STATE_ID) + { + TAudioObjectID objectId = INVALID_AUDIO_OBJECT_ID; + if (args.size() == 3) + { + if (!AZ::ConsoleTypeHelpers::StringToValue(objectId, args[2])) { - nObjectID = static_cast(nTempID); - } - else - { - g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %s", pCmdArgs->GetArg(3)); + g_audioLogger.Log(eALT_ERROR, "Invalid Object ID: %.*s", AZ_STRING_ARG(args[2])); return; } } - SAudioRequest oRequest; - SAudioObjectRequestData oRequestData(nSwitchID, nSwitchStateID); + SAudioRequest request; + SAudioObjectRequestData requestData(switchId, stateId); - oRequest.nAudioObjectID = nObjectID; - oRequest.nFlags = eARF_PRIORITY_NORMAL; - oRequest.pData = &oRequestData; + request.nAudioObjectID = objectId; + request.nFlags = eARF_PRIORITY_NORMAL; + request.pData = &requestData; - AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, oRequest); + AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::PushRequest, request); } else { - g_audioLogger.Log(eALT_ERROR, "Invalid Switch State name: %s", pCmdArgs->GetArg(2)); + g_audioLogger.Log(eALT_ERROR, "Invalid Switch State name: %.*s", AZ_STRING_ARG(args[1])); } } else { - g_audioLogger.Log(eALT_ERROR, "Unknown Switch name: %s", pCmdArgs->GetArg(1)); + g_audioLogger.Log(eALT_ERROR, "Unknown Switch name: %.*s", AZ_STRING_ARG(args[0])); } } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_SetSwitchState [SwitchName] [SwitchStateName] [[Optional Object ID]]"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_SetSwitchState SwitchName SwitchStateName [Optional Object ID]"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdLoadPreload(IConsoleCmdArgs* cmdArgs) + static void s_LoadPreload(const AZ::ConsoleCommandContainer& args) { - const int argCount = cmdArgs->GetArgCount(); - - if (argCount == 2) + if (args.size() == 1) { - const char* preloadName = cmdArgs->GetArg(1); - + AZStd::string preloadName(args[0]); TAudioPreloadRequestID preloadId = INVALID_AUDIO_PRELOAD_REQUEST_ID; - AudioSystemRequestBus::BroadcastResult(preloadId, &AudioSystemRequestBus::Events::GetAudioPreloadRequestID, preloadName); + AudioSystemRequestBus::BroadcastResult(preloadId, &AudioSystemRequestBus::Events::GetAudioPreloadRequestID, preloadName.c_str()); if (preloadId != INVALID_AUDIO_PRELOAD_REQUEST_ID) { SAudioRequest request; @@ -546,26 +560,23 @@ namespace Audio } else { - g_audioLogger.Log(eALT_ERROR, "Preload named %s not found", preloadName); + g_audioLogger.Log(eALT_ERROR, "Preload named %.*s not found", AZ_STRING_ARG(args[0])); } } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_LoadPreload [PreloadName]"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_LoadPreload PreloadName"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdUnloadPreload(IConsoleCmdArgs* cmdArgs) + static void s_UnloadPreload(const AZ::ConsoleCommandContainer& args) { - const int argCount = cmdArgs->GetArgCount(); - - if (argCount == 2) + if (args.size() == 1) { - const char* preloadName = cmdArgs->GetArg(1); - + AZStd::string preloadName(args[0]); TAudioPreloadRequestID preloadId = INVALID_AUDIO_PRELOAD_REQUEST_ID; - AudioSystemRequestBus::BroadcastResult(preloadId, &AudioSystemRequestBus::Events::GetAudioPreloadRequestID, preloadName); + AudioSystemRequestBus::BroadcastResult(preloadId, &AudioSystemRequestBus::Events::GetAudioPreloadRequestID, preloadName.c_str()); if (preloadId != INVALID_AUDIO_PRELOAD_REQUEST_ID) { SAudioRequest request; @@ -577,26 +588,25 @@ namespace Audio } else { - g_audioLogger.Log(eALT_ERROR, "Preload named %s not found", preloadName); + g_audioLogger.Log(eALT_ERROR, "Preload named %.*s not found", AZ_STRING_ARG(args[0])); } } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_UnloadPreload [PreloadName]"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_UnloadPreload PreloadName"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdPlayFile(IConsoleCmdArgs* cmdArgs) + static void s_PlayFile(const AZ::ConsoleCommandContainer& args) { - const int argCount = cmdArgs->GetArgCount(); - - if (argCount >= 3) + if (args.size() >= 2) { - const char* filename = cmdArgs->GetArg(1); + AZStd::string filename(args[0]); AZStd::string fileext; - AZ::StringFunc::Path::GetExtension(filename, fileext, false); + AZStd::to_lower(fileext.begin(), fileext.end()); + AZ::StringFunc::Path::GetExtension(filename.c_str(), fileext, false); AudioInputSourceType audioInputType = AudioInputSourceType::Unsupported; @@ -613,20 +623,29 @@ namespace Audio if (audioInputType != AudioInputSourceType::Unsupported) { // Setup the configuration... - SAudioInputConfig audioInputConfig(audioInputType, filename); + SAudioInputConfig audioInputConfig(audioInputType, filename.c_str()); if (audioInputType == AudioInputSourceType::PcmFile) { - if (argCount == 5) + if (args.size() == 4) { audioInputConfig.m_bitsPerSample = 16; - audioInputConfig.m_numChannels = std::strtoul(cmdArgs->GetArg(3), nullptr, 10); - audioInputConfig.m_sampleRate = std::strtoul(cmdArgs->GetArg(4), nullptr, 10); + if (!AZ::ConsoleTypeHelpers::StringToValue(audioInputConfig.m_numChannels, args[2])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid number of channels '%.*s'", AZ_STRING_ARG(args[2])); + return; + } + if (!AZ::ConsoleTypeHelpers::StringToValue(audioInputConfig.m_sampleRate, args[3])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid sample rate '%.*s'", AZ_STRING_ARG(args[3])); + return; + } audioInputConfig.m_sampleType = AudioInputSampleType::Int; } else { - g_audioLogger.Log(eALT_ERROR, "Using PCM file, additional parameters needed: [NumChannels] [SampleRate] (e.g. 2 16000)"); + g_audioLogger.Log( + eALT_ERROR, "Using PCM file, additional parameters needed: [NumChannels] [SampleRate] (e.g. 2 16000)"); return; } } @@ -637,7 +656,8 @@ namespace Audio if (sourceId != INVALID_AUDIO_SOURCE_ID) { TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID; - AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, cmdArgs->GetArg(2)); + AudioSystemRequestBus::BroadcastResult( + triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, args[1].data()); if (triggerId != INVALID_AUDIO_CONTROL_ID) { @@ -651,7 +671,7 @@ namespace Audio else { AudioSystemRequestBus::Broadcast(&AudioSystemRequestBus::Events::DestroyAudioSource, sourceId); - g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named %s", cmdArgs->GetArg(2)); + g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named %.*s", AZ_STRING_ARG(args[1])); } } else @@ -661,36 +681,39 @@ namespace Audio } else { - g_audioLogger.Log(eALT_ERROR, "Audio files with extension .%s are unsupported", fileext.c_str()); + g_audioLogger.Log(eALT_ERROR, "Audio files with extension '.%s' are unsupported", fileext.c_str()); } } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_PlayFile \"path\\to\\myfile.wav\" \"Play_audio_input_2D\""); + g_audioLogger.Log(eALT_ERROR, "Usage: s_PlayFile \"path\\to\\myfile.wav\" Play_audio_input_2D"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdMicrophone(IConsoleCmdArgs* pCmdArgs) + static void s_Microphone(const AZ::ConsoleCommandContainer& args) { - static bool micState = false; // mic is off initially + static bool micState = false; // mic is off initially static TAudioSourceId micSourceId = INVALID_AUDIO_SOURCE_ID; static TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID; - const int argCount = pCmdArgs->GetArgCount(); - - if (argCount == 3) + if (args.size() == 2) { - int state = std::strtol(pCmdArgs->GetArg(1), nullptr, 10); + AZ::u32 state; + if (!AZ::ConsoleTypeHelpers::StringToValue(state, args[0])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid number passed '%.*s', should be 0 or 1", AZ_STRING_ARG(args[0])); + return; + } - const char* triggerName = pCmdArgs->GetArg(2); + AZStd::string triggerName(args[1]); if (state == 1 && !micState && micSourceId == INVALID_AUDIO_SOURCE_ID && triggerId == INVALID_AUDIO_CONTROL_ID) { - g_audioLogger.Log(eALT_ALWAYS, "Turning on Microhpone with %s\n", triggerName); + g_audioLogger.Log(eALT_ALWAYS, "Turning on Microhpone with %s\n", triggerName.c_str()); bool success = true; - AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName); + AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName.c_str()); if (triggerId != INVALID_AUDIO_CONTROL_ID) { // Start the mic session @@ -703,9 +726,9 @@ namespace Audio // If you want to test resampling, set the values here before you create an Audio Source. // In this case, we would be specifying 16kHz, 16-bit integers. - //micConfig.m_sampleRate = 16000; - //micConfig.m_bitsPerSample = 16; - //micConfig.m_sampleType = AudioInputSampleType::Int; + // micConfig.m_sampleRate = 16000; + // micConfig.m_bitsPerSample = 16; + // micConfig.m_sampleType = AudioInputSampleType::Int; AudioSystemRequestBus::BroadcastResult(micSourceId, &AudioSystemRequestBus::Events::CreateAudioSource, micConfig); @@ -733,7 +756,7 @@ namespace Audio else { success = false; - g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named %s", triggerName); + g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named %s", triggerName.c_str()); } if (success) @@ -753,9 +776,14 @@ namespace Audio g_audioLogger.Log(eALT_ERROR, "Error encountered while turning on/off microphone"); } } - else if (argCount == 2) + else if (args.size() == 1) { - int state = std::strtol(pCmdArgs->GetArg(1), nullptr, 10); + AZ::u32 state; + if (!AZ::ConsoleTypeHelpers::StringToValue(state, args[0])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid number passed '%.*s', should be 0 or 1", AZ_STRING_ARG(args[0])); + return; + } if (state == 0 && micState && micSourceId != INVALID_AUDIO_SOURCE_ID && triggerId != INVALID_AUDIO_CONTROL_ID) { @@ -783,34 +811,49 @@ namespace Audio } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_Microphone 1 Play_audio_input_2D / s_Microphone 0"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_Microphone 1 Play_audio_input_2D\nUsage: s_Microphone 0"); } } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdPlayExternalSource(IConsoleCmdArgs* pCmdArgs) + static void s_PlayExternalSource(const AZ::ConsoleCommandContainer& args) { // This cookie value is a hash on the name of the External Source. // By default when you add an External Source to a sound, it gives the name 'External_Source' and has this hash. // Apparently it can be changed in the Wwise project, so it's unfortunately content-dependent. But there's no easy // way to extract that info in this context. - const AZ::u64 externalSourceCookieValue = 618371124ull; + static constexpr AZ::u64 externalSourceCookieValue = 618371124ull; TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID; - if (pCmdArgs->GetArgCount() == 5) + if (args.size() == 4) { - const char* triggerName = pCmdArgs->GetArg(1); - AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName); + AZStd::string triggerName(args[0]); + AudioSystemRequestBus::BroadcastResult(triggerId, &AudioSystemRequestBus::Events::GetAudioTriggerID, triggerName.c_str()); if (triggerId == INVALID_AUDIO_CONTROL_ID) { - g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named '%s'\n", triggerName); + g_audioLogger.Log(eALT_ERROR, "Failed to find the trigger named '%s'\n", triggerName.c_str()); return; } - int collection = std::strtol(pCmdArgs->GetArg(2), nullptr, 10); - int language = std::strtol(pCmdArgs->GetArg(3), nullptr, 10); - int file = std::strtol(pCmdArgs->GetArg(4), nullptr, 10); + AZ::u64 collection; + if (!AZ::ConsoleTypeHelpers::StringToValue(collection, args[1])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid collection number passed '%.*s'", AZ_STRING_ARG(args[1])); + return; + } + AZ::u64 language; + if (!AZ::ConsoleTypeHelpers::StringToValue(language, args[2])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid language number passed '%.*s'", AZ_STRING_ARG(args[2])); + return; + } + AZ::u64 file; + if (!AZ::ConsoleTypeHelpers::StringToValue(file, args[3])) + { + g_audioLogger.Log(eALT_ERROR, "Invalid file number passed '%.*s'", AZ_STRING_ARG(args[3])); + return; + } SAudioSourceInfo sourceInfo(externalSourceCookieValue, file, language, collection, eACT_PCM); @@ -828,25 +871,28 @@ namespace Audio } /////////////////////////////////////////////////////////////////////////////////////////////////// - void CSoundCVars::CmdSetPanningMode(IConsoleCmdArgs* pCmdArgs) + static void s_SetPanningMode(const AZ::ConsoleCommandContainer& args) { - if (pCmdArgs->GetArgCount() == 2) + if (args.size() == 1) { PanningMode panningMode; - const char* mode = pCmdArgs->GetArg(1); - if (azstricmp(mode, "speakers") == 0) + AZStd::string mode(args[0]); + AZStd::to_lower(mode.begin(), mode.end()); + if (mode == "speakers") { panningMode = PanningMode::Speakers; - g_audioLogger.Log(eALT_COMMENT, "Setting Panning Mode to 'Speakers'.\n"); + g_audioLogger.Log(eALT_COMMENT, "Setting Panning Mode to 'Speakers'\n"); } - else if (azstricmp(mode, "headphones") == 0) + else if (mode == "headphones") { panningMode = PanningMode::Headphones; - g_audioLogger.Log(eALT_COMMENT, "Setting Panning Mode to 'Headphones'.\n"); + g_audioLogger.Log(eALT_COMMENT, "Setting Panning Mode to 'Headphones'\n"); } else { - g_audioLogger.Log(eALT_ERROR, "Panning mode '%s' is invalid. Please specify either 'speakers' or 'headphones'\n", mode); + g_audioLogger.Log(eALT_ERROR, + "Panning mode '%.*s' is invalid. Please specify either 'speakers' or 'headphones'\n", + AZ_STRING_ARG(args[0])); return; } @@ -859,10 +905,10 @@ namespace Audio } else { - g_audioLogger.Log(eALT_ERROR, "Usage: s_SetPanningMode speakers\nUsage: s_SetPanningMode headphones"); + g_audioLogger.Log(eALT_ERROR, "Usage: s_SetPanningMode (speakers|headphones)\n"); } } #endif // !AUDIO_RELEASE -} // namespace Audio +} // namespace Audio::CVars diff --git a/Gems/AudioSystem/Code/Source/Engine/SoundCVars.h b/Gems/AudioSystem/Code/Source/Engine/SoundCVars.h index 7cb7c5712c..a4a0e9e755 100644 --- a/Gems/AudioSystem/Code/Source/Engine/SoundCVars.h +++ b/Gems/AudioSystem/Code/Source/Engine/SoundCVars.h @@ -8,14 +8,11 @@ #pragma once -#include +#include #include -struct IConsoleCmdArgs; - namespace Audio::CVars { - /////////////////////////////////////////////////////////////////////////////////////////////////// AZ_CVAR_EXTERNED(AZ::u64, s_ATLMemorySize); AZ_CVAR_EXTERNED(AZ::u64, s_FileCacheManagerMemorySize); AZ_CVAR_EXTERNED(AZ::u64, s_AudioObjectPoolSize); @@ -31,48 +28,18 @@ namespace Audio::CVars AZ_CVAR_EXTERNED(float, s_VelocityTrackingThreshold); AZ_CVAR_EXTERNED(AZ::u32, s_AudioProxiesInitType); + AZ_CVAR_EXTERNED(AZ::CVarFixedString, g_languageAudio); + #if !defined(AUDIO_RELEASE) AZ_CVAR_EXTERNED(bool, s_IgnoreWindowFocus); AZ_CVAR_EXTERNED(bool, s_ShowActiveAudioObjectsOnly); AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioTriggersDebugFilter); AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioObjectsDebugFilter); + AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_AudioLoggingOptions); + AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_DrawAudioDebug); + inline Audio::Flags s_debugDrawOptions; + AZ_CVAR_EXTERNED(AZ::CVarFixedString, s_FileCacheManagerDebugFilter); + inline Audio::Flags s_fcmDrawOptions; #endif // !AUDIO_RELEASE } // namespace Audio::CVars - -namespace Audio -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - class CSoundCVars - { - public: - CSoundCVars(); - ~CSoundCVars() = default; - - CSoundCVars(const CSoundCVars&) = delete; // Copy protection - CSoundCVars& operator=(const CSoundCVars&) = delete; // Copy protection - - void RegisterVariables(); - void UnregisterVariables(); - - #if !defined(AUDIO_RELEASE) - int m_nDrawAudioDebug; - int m_nFileCacheManagerDebugFilter; - int m_nAudioLoggingOptions; - - private: - static void CmdExecuteTrigger(IConsoleCmdArgs* pCmdArgs); - static void CmdStopTrigger(IConsoleCmdArgs* pCmdArgs); - static void CmdSetRtpc(IConsoleCmdArgs* pCmdArgs); - static void CmdSetSwitchState(IConsoleCmdArgs* pCmdArgs); - static void CmdLoadPreload(IConsoleCmdArgs* pCmdArgs); - static void CmdUnloadPreload(IConsoleCmdArgs* pCmdArgs); - static void CmdPlayFile(IConsoleCmdArgs* pCmdArgs); - static void CmdMicrophone(IConsoleCmdArgs* pCmdArgs); - static void CmdPlayExternalSource(IConsoleCmdArgs* pCmdArgs); - static void CmdSetPanningMode(IConsoleCmdArgs* pCmdArgs); - #endif // !AUDIO_RELEASE - }; - - extern CSoundCVars g_audioCVars; -} // namespace Audio