au.MetaSound.EnableCookDeterministicIDGeneration
au.MetaSound.EnableCookDeterministicIDGeneration
#Overview
name: au.MetaSound.EnableCookDeterministicIDGeneration
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable moving MetaSound registration operations like AutoUpdate and some template node transformations from runtime to cook using deterministic ID generation \n0: Disabled, !0: Enabled (default)
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.MetaSound.EnableCookDeterministicIDGeneration is to control the generation of deterministic IDs for MetaSound registration operations during the cooking process. This setting is primarily used for the MetaSound system, which is part of Unreal Engine’s audio framework.
This setting variable is primarily relied upon by the MetaSound plugin, specifically within the MetasoundFrontend and MetasoundEngine modules. It affects various operations related to MetaSound asset registration, document processing, and ID generation.
The value of this variable is set through a console variable (cvar) system. It is initialized with a default value of 1 (enabled) but can be changed at runtime using console commands.
The associated variable MetaSoundEnableCookDeterministicIDGeneration interacts directly with au.MetaSound.EnableCookDeterministicIDGeneration. They share the same value and are used interchangeably in the code.
Developers must be aware of several things when using this variable:
- When enabled (value != 0), it moves certain MetaSound registration operations from runtime to cook time, using deterministic ID generation.
- It affects operations like AutoUpdate and some template node transformations.
- In non-editor builds, when enabled, it disables AutoUpdate and ResolveDocument operations at runtime, as these are expected to happen during cook or save.
- It influences whether node template transformations are performed on local documents before registration.
Best practices when using this variable include:
- Keep it enabled (default value) unless there’s a specific reason to disable it, as it helps in creating more deterministic behavior during the cooking process.
- Be aware of its impact on runtime behavior, especially in non-editor builds.
- Consider its effects when debugging MetaSound-related issues, as it can change when certain operations occur (cook time vs. runtime).
- When making changes to MetaSound assets or systems, test with both enabled and disabled states to ensure compatibility and correct behavior in all scenarios.
Regarding the associated variable MetaSoundEnableCookDeterministicIDGeneration:
This variable serves the same purpose as au.MetaSound.EnableCookDeterministicIDGeneration and is used interchangeably in the code. It’s an int32 variable that controls the same functionality. The best practices and considerations mentioned above apply equally to this associated variable. Developers should treat them as effectively the same control mechanism for the MetaSound deterministic ID generation feature.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Private/MetasoundFrontendDocumentIdGenerator.cpp:13
Scope (from outer to inner):
file
namespace Metasound
namespace Frontend
Source code excerpt:
int32 MetaSoundEnableCookDeterministicIDGeneration = 1;
FAutoConsoleVariableRef CVarMetaSoundEnableCookDeterministicIDGeneration(
TEXT("au.MetaSound.EnableCookDeterministicIDGeneration"),
MetaSoundEnableCookDeterministicIDGeneration,
TEXT("Enable moving MetaSound registration operations like AutoUpdate and some template node transformations from runtime to cook using deterministic ID generation \n")
TEXT("0: Disabled, !0: Enabled (default)"),
ECVF_Default);
FDocumentIDGenerator::FScopeDeterminism::FScopeDeterminism(bool bInIsDeterministic)
#Associated Variable and Callsites
This variable is associated with another variable named MetaSoundEnableCookDeterministicIDGeneration
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundEngine/Private/MetasoundEngineAsset.h:113
Scope (from outer to inner):
file
namespace Metasound
function static void PreSaveAsset
Source code excerpt:
{
// Use deterministic ID generation so more can be done at cook rather than runtime
if (MetaSoundEnableCookDeterministicIDGeneration != 0)
{
{
constexpr bool bIsDeterministic = true;
FDocumentIDGenerator::FScopeDeterminism DeterminismScope = FDocumentIDGenerator::FScopeDeterminism(bIsDeterministic);
InMetaSound.CookMetaSound();
}
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundEngine/Private/MetasoundSource.cpp:93
Scope (from outer to inner):
file
namespace Metasound
namespace SourcePrivate
function Frontend::FMetaSoundAssetRegistrationOptions GetInitRegistrationOptions
Source code excerpt:
RegOptions.bForceReregister = false;
#if !WITH_EDITOR
if (Frontend::MetaSoundEnableCookDeterministicIDGeneration != 0)
{
// When without editor, don't AutoUpdate or ResolveDocument at runtime. This only happens at cook or save.
// When with editor, those are needed because sounds are not necessarily saved before previewing.
RegOptions.bAutoUpdate = false;
}
#endif // !WITH_EDITOR
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Private/MetasoundFrontendDocumentIdGenerator.cpp:11
Scope (from outer to inner):
file
namespace Metasound
namespace Frontend
Source code excerpt:
}
int32 MetaSoundEnableCookDeterministicIDGeneration = 1;
FAutoConsoleVariableRef CVarMetaSoundEnableCookDeterministicIDGeneration(
TEXT("au.MetaSound.EnableCookDeterministicIDGeneration"),
MetaSoundEnableCookDeterministicIDGeneration,
TEXT("Enable moving MetaSound registration operations like AutoUpdate and some template node transformations from runtime to cook using deterministic ID generation \n")
TEXT("0: Disabled, !0: Enabled (default)"),
ECVF_Default);
FDocumentIDGenerator::FScopeDeterminism::FScopeDeterminism(bool bInIsDeterministic)
{
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Private/MetasoundFrontendRegistryContainerImpl.cpp:54
Scope (from outer to inner):
file
namespace Metasound::Frontend
namespace RegistryPrivate
function TScriptInterface<IMetaSoundDocumentInterface> BuildRegistryDocument
Source code excerpt:
// Node template transform is performed on local document only if cook determinism ID generation
// is enabled to avoid transforms potentially creating new edges with non-deterministic IDs.
const bool bTransformDocumentBeforeRegistering = MetaSoundEnableCookDeterministicIDGeneration == 0;
#endif // !WITH_EDITOR
if (bTransformDocumentBeforeRegistering)
{
// 1. Find template dependencies to build prior to making new document/builder as an optimization
// (no sense in creating new document/builder if no templates need processing)
#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Public/MetasoundFrontendDocumentIdGenerator.h:9
Scope (from outer to inner):
file
namespace Metasound
namespace Frontend
Source code excerpt:
namespace Frontend
{
extern METASOUNDFRONTEND_API int32 MetaSoundEnableCookDeterministicIDGeneration;
/***
* For generating IDs using a given document.
* USAGE:
*
* If you want everything within the calling scope to be deterministic, use