2020-07-17 16:43:42 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "MetasoundAssetBase.h"
2020-12-14 15:48:27 -04:00
# include "Algo/AnyOf.h"
2022-08-18 13:55:13 -04:00
# include "Algo/Copy.h"
2022-03-01 16:31:55 -05:00
# include "Algo/ForEach.h"
2021-06-16 11:21:13 -04:00
# include "Algo/Transform.h"
2021-09-16 14:46:43 -04:00
# include "Containers/Set.h"
2020-07-21 14:34:07 -04:00
# include "HAL/FileManager.h"
2022-11-03 14:18:47 -04:00
# include "HAL/IConsoleManager.h"
2021-11-22 15:55:50 -05:00
# include "IAudioParameterTransmitter.h"
2022-08-19 12:14:31 -04:00
# include "Interfaces/MetasoundFrontendInterface.h"
2023-03-13 17:23:05 -04:00
# include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
2021-06-08 10:52:31 -04:00
# include "Internationalization/Text.h"
2020-07-17 16:43:42 -04:00
# include "IStructSerializerBackend.h"
2021-07-27 15:36:03 -04:00
# include "Logging/LogMacros.h"
2021-11-07 23:43:01 -05:00
# include "MetasoundAssetManager.h"
2023-09-05 17:54:02 -04:00
# include "MetasoundDocumentInterface.h"
2021-01-13 10:48:59 -04:00
# include "MetasoundFrontendController.h"
2021-07-12 16:13:03 -04:00
# include "MetasoundFrontendDocument.h"
2023-03-07 17:01:52 -05:00
# include "MetasoundFrontendDocumentBuilder.h"
2023-06-20 13:12:39 -04:00
# include "MetasoundFrontendDocumentIdGenerator.h"
2022-08-19 12:14:31 -04:00
# include "MetasoundFrontendDocumentVersioning.h"
2022-08-10 14:18:10 -04:00
# include "MetasoundFrontendNodeTemplateRegistry.h"
2023-09-13 14:21:35 -04:00
# include "MetasoundFrontendProxyDataCache.h"
2021-08-18 15:16:57 -04:00
# include "MetasoundFrontendRegistries.h"
2023-12-15 13:21:12 -05:00
# include "MetasoundFrontendRegistryContainerImpl.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundFrontendSearchEngine.h"
2021-01-13 10:48:59 -04:00
# include "MetasoundFrontendTransform.h"
2024-06-17 12:51:18 -04:00
# include "MetasoundGlobals.h"
2023-10-10 11:32:28 -04:00
# include "MetasoundGraph.h"
2020-12-14 15:48:27 -04:00
# include "MetasoundJsonBackend.h"
2021-01-13 10:48:59 -04:00
# include "MetasoundLog.h"
2023-03-07 17:01:52 -05:00
# include "MetasoundParameterPack.h"
2021-08-30 14:08:45 -04:00
# include "MetasoundParameterTransmitter.h"
2021-08-11 15:22:01 -04:00
# include "MetasoundTrace.h"
2021-09-13 14:14:37 -04:00
# include "MetasoundVertex.h"
2020-07-17 16:43:42 -04:00
# include "StructSerializer.h"
2022-08-10 14:18:10 -04:00
# include "Templates/SharedPointer.h"
2021-06-16 11:21:13 -04:00
# include "UObject/MetaData.h"
2020-07-17 16:43:42 -04:00
2021-06-08 10:52:31 -04:00
# define LOCTEXT_NAMESPACE "MetaSound"
2021-06-16 11:21:13 -04:00
namespace Metasound
{
2022-05-10 16:51:39 -04:00
namespace Frontend
2021-07-27 15:36:03 -04:00
{
2022-05-10 16:51:39 -04:00
namespace AssetBasePrivate
2021-07-27 15:36:03 -04:00
{
2023-10-10 13:37:20 -04:00
// Zero values means, that these don't do anything.
static float BlockRateOverride = 0 ;
static int32 SampleRateOverride = 0 ;
2023-09-19 18:30:29 -04:00
2022-05-10 16:51:39 -04:00
void DepthFirstTraversal ( const FMetasoundAssetBase & InInitAsset , TFunctionRef < TSet < const FMetasoundAssetBase * > ( const FMetasoundAssetBase & ) > InVisitFunction )
2021-07-27 15:36:03 -04:00
{
2022-05-10 16:51:39 -04:00
// Non recursive depth first traversal.
TArray < const FMetasoundAssetBase * > Stack ( { & InInitAsset } ) ;
TSet < const FMetasoundAssetBase * > Visited ;
2021-07-27 15:36:03 -04:00
2022-05-10 16:51:39 -04:00
while ( ! Stack . IsEmpty ( ) )
{
const FMetasoundAssetBase * CurrentNode = Stack . Pop ( ) ;
if ( ! Visited . Contains ( CurrentNode ) )
{
TArray < const FMetasoundAssetBase * > Children = InVisitFunction ( * CurrentNode ) . Array ( ) ;
Stack . Append ( Children ) ;
Visited . Add ( CurrentNode ) ;
}
2021-07-27 15:36:03 -04:00
}
}
2022-10-10 15:44:28 -04:00
2022-10-13 17:38:11 -04:00
// Registers node by copying document. Updates to document require re-registration.
2023-09-22 15:01:07 -04:00
// This registry entry does not support node creation as it is only intended to be
2024-07-19 17:36:32 -04:00
// used when serializing MetaSounds in contexts not requiring any runtime model to
// be generated (ex. cooking commandlets that don't play or are validating MetaSounds, etc.).
class FDocumentNodeRegistryEntryForSerialization : public INodeRegistryEntry
2022-10-13 17:38:11 -04:00
{
public :
2024-07-19 17:36:32 -04:00
FDocumentNodeRegistryEntryForSerialization ( const FMetasoundFrontendDocument & InDocument , const FTopLevelAssetPath & InAssetPath )
2023-09-22 15:01:07 -04:00
: Interfaces ( InDocument . Interfaces )
, FrontendClass ( InDocument . RootGraph )
, ClassInfo ( InDocument . RootGraph , InAssetPath )
2022-10-13 17:38:11 -04:00
{
// Copy FrontendClass to preserve original document.
FrontendClass . Metadata . SetType ( EMetasoundFrontendClassType : : External ) ;
2023-09-13 20:11:49 -04:00
}
2022-10-13 17:38:11 -04:00
2024-07-19 17:36:32 -04:00
FDocumentNodeRegistryEntryForSerialization ( const FDocumentNodeRegistryEntryForSerialization & InOther ) = default ;
2022-10-13 17:38:11 -04:00
2024-07-19 17:36:32 -04:00
virtual ~ FDocumentNodeRegistryEntryForSerialization ( ) = default ;
2022-10-13 17:38:11 -04:00
virtual const FNodeClassInfo & GetClassInfo ( ) const override
{
return ClassInfo ;
}
2023-09-22 15:01:07 -04:00
virtual TUniquePtr < INode > CreateNode ( const FNodeInitData & ) const override { return nullptr ; }
2022-10-13 17:38:11 -04:00
virtual TUniquePtr < INode > CreateNode ( FDefaultLiteralNodeConstructorParams & & ) const override { return nullptr ; }
virtual TUniquePtr < INode > CreateNode ( FDefaultNamedVertexNodeConstructorParams & & ) const override { return nullptr ; }
virtual TUniquePtr < INode > CreateNode ( FDefaultNamedVertexWithLiteralNodeConstructorParams & & ) const override { return nullptr ; }
virtual const FMetasoundFrontendClass & GetFrontendClass ( ) const override
{
return FrontendClass ;
}
virtual TUniquePtr < INodeRegistryEntry > Clone ( ) const override
{
2024-07-19 17:36:32 -04:00
return MakeUnique < FDocumentNodeRegistryEntryForSerialization > ( * this ) ;
2022-10-13 17:38:11 -04:00
}
2023-09-13 20:11:49 -04:00
virtual const TSet < FMetasoundFrontendVersion > * GetImplementedInterfaces ( ) const override
2023-06-22 14:51:42 -04:00
{
2023-09-22 15:01:07 -04:00
return & Interfaces ;
2023-06-22 14:51:42 -04:00
}
2022-10-13 17:38:11 -04:00
virtual bool IsNative ( ) const override
{
return false ;
}
private :
2023-09-22 15:01:07 -04:00
TSet < FMetasoundFrontendVersion > Interfaces ;
2022-10-13 17:38:11 -04:00
FMetasoundFrontendClass FrontendClass ;
FNodeClassInfo ClassInfo ;
} ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
void GetUpdatePathForDocument ( const FMetasoundFrontendVersion & InCurrentVersion , const FMetasoundFrontendVersion & InTargetVersion , TArray < const IInterfaceRegistryEntry * > & OutUpgradePath )
{
if ( InCurrentVersion . Name = = InTargetVersion . Name )
{
// Get all associated registered interfaces
TArray < FMetasoundFrontendVersion > RegisteredVersions = ISearchEngine : : Get ( ) . FindAllRegisteredInterfacesWithName ( InTargetVersion . Name ) ;
// Filter registry entries that exist between current version and target version
auto FilterRegistryEntries = [ & InCurrentVersion , & InTargetVersion ] ( const FMetasoundFrontendVersion & InVersion )
{
const bool bIsGreaterThanCurrent = InVersion . Number > InCurrentVersion . Number ;
const bool bIsLessThanOrEqualToTarget = InVersion . Number < = InTargetVersion . Number ;
return bIsGreaterThanCurrent & & bIsLessThanOrEqualToTarget ;
} ;
RegisteredVersions = RegisteredVersions . FilterByPredicate ( FilterRegistryEntries ) ;
// sort registry entries to create an ordered upgrade path.
RegisteredVersions . Sort ( ) ;
// Get registry entries from registry keys.
auto GetRegistryEntry = [ ] ( const FMetasoundFrontendVersion & InVersion )
{
FInterfaceRegistryKey Key = GetInterfaceRegistryKey ( InVersion ) ;
return IInterfaceRegistry : : Get ( ) . FindInterfaceRegistryEntry ( Key ) ;
} ;
Algo : : Transform ( RegisteredVersions , OutUpgradePath , GetRegistryEntry ) ;
}
}
bool UpdateDocumentInterface ( const TArray < const IInterfaceRegistryEntry * > & InUpgradePath , const FMetasoundFrontendVersion & InterfaceVersion , FDocumentHandle InDocument )
{
const FMetasoundFrontendVersionNumber * LastVersionUpdated = nullptr ;
for ( const IInterfaceRegistryEntry * Entry : InUpgradePath )
{
if ( ensure ( nullptr ! = Entry ) )
{
if ( Entry - > UpdateRootGraphInterface ( InDocument ) )
{
LastVersionUpdated = & Entry - > GetInterface ( ) . Version . Number ;
}
}
}
if ( LastVersionUpdated )
{
# if WITH_EDITOR
const FString AssetName = * InDocument - > GetRootGraphClass ( ) . Metadata . GetDisplayName ( ) . ToString ( ) ;
# else
const FString AssetName = * InDocument - > GetRootGraphClass ( ) . Metadata . GetClassName ( ) . ToString ( ) ;
# endif // !WITH_EDITOR
UE_LOG ( LogMetaSound , Display , TEXT ( " Asset '%s' interface '%s' updated: '%s' --> '%s' " ) ,
* AssetName ,
* InterfaceVersion . Name . ToString ( ) ,
* InterfaceVersion . Number . ToString ( ) ,
* LastVersionUpdated - > ToString ( ) ) ;
return true ;
}
return false ;
}
2022-05-10 16:51:39 -04:00
} // namespace AssetBasePrivate
2023-10-10 13:37:20 -04:00
FConsoleVariableMulticastDelegate CVarMetaSoundBlockRateChanged ;
2023-10-03 12:17:13 -04:00
2022-05-10 16:51:39 -04:00
FAutoConsoleVariableRef CVarMetaSoundBlockRate (
TEXT ( " au.MetaSound.BlockRate " ) ,
2023-10-10 13:37:20 -04:00
AssetBasePrivate : : BlockRateOverride ,
2022-05-10 16:51:39 -04:00
TEXT ( " Sets block rate (blocks per second) of MetaSounds. \n " )
TEXT ( " Default: 100.0f, Min: 1.0f, Max: 1000.0f " ) ,
2023-10-10 13:37:20 -04:00
FConsoleVariableDelegate : : CreateLambda ( [ ] ( IConsoleVariable * Var ) { CVarMetaSoundBlockRateChanged . Broadcast ( Var ) ; } ) ,
2022-05-10 16:51:39 -04:00
ECVF_Default ) ;
2023-10-10 13:37:20 -04:00
FConsoleVariableMulticastDelegate CVarMetaSoundSampleRateChanged ;
2023-09-19 18:30:29 -04:00
FAutoConsoleVariableRef CVarMetaSoundSampleRate (
TEXT ( " au.MetaSound.SampleRate " ) ,
2023-10-10 13:37:20 -04:00
AssetBasePrivate : : SampleRateOverride ,
2023-09-19 18:30:29 -04:00
TEXT ( " Overrides the sample rate of metasounds. Negative values default to audio mixer sample rate. \n " )
2023-10-10 13:37:20 -04:00
TEXT ( " Default: 0, Min: 8000, Max: 48000 " ) ,
FConsoleVariableDelegate : : CreateLambda ( [ ] ( IConsoleVariable * Var ) { CVarMetaSoundSampleRateChanged . Broadcast ( Var ) ; } ) ,
2023-09-19 18:30:29 -04:00
ECVF_Default ) ;
2023-10-10 13:37:20 -04:00
float GetBlockRateOverride ( )
2022-05-10 16:51:39 -04:00
{
2023-10-10 13:37:20 -04:00
if ( AssetBasePrivate : : BlockRateOverride > 0 )
{
return FMath : : Clamp ( AssetBasePrivate : : BlockRateOverride ,
GetBlockRateClampRange ( ) . GetLowerBoundValue ( ) ,
GetBlockRateClampRange ( ) . GetUpperBoundValue ( )
) ;
}
return AssetBasePrivate : : BlockRateOverride ;
2023-10-06 19:42:56 -04:00
}
2023-10-10 13:37:20 -04:00
FConsoleVariableMulticastDelegate & GetBlockRateOverrideChangedDelegate ( )
2023-10-06 19:42:56 -04:00
{
2023-10-10 13:37:20 -04:00
return CVarMetaSoundBlockRateChanged ;
}
int32 GetSampleRateOverride ( )
{
if ( AssetBasePrivate : : SampleRateOverride > 0 )
2023-10-06 18:51:06 -04:00
{
2023-10-10 13:37:20 -04:00
return FMath : : Clamp ( AssetBasePrivate : : SampleRateOverride ,
GetSampleRateClampRange ( ) . GetLowerBoundValue ( ) ,
GetSampleRateClampRange ( ) . GetUpperBoundValue ( )
) ;
2023-10-06 18:51:06 -04:00
}
2023-10-10 13:37:20 -04:00
return AssetBasePrivate : : SampleRateOverride ;
}
FConsoleVariableMulticastDelegate & GetSampleRateOverrideChangedDelegate ( )
{
return CVarMetaSoundSampleRateChanged ;
}
TRange < float > GetBlockRateClampRange ( )
{
2024-03-04 17:47:30 -05:00
return TRange < float > ( 1.f , 1000.f ) ;
2023-10-10 13:37:20 -04:00
}
TRange < int32 > GetSampleRateClampRange ( )
{
return TRange < int32 > ( 8000 , 96000 ) ;
2023-09-19 18:30:29 -04:00
}
2022-05-10 16:51:39 -04:00
} // namespace Frontend
2021-06-16 11:21:13 -04:00
} // namespace Metasound
2020-07-23 16:39:56 -04:00
const FString FMetasoundAssetBase : : FileExtension ( TEXT ( " .metasound " ) ) ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
bool FMetasoundAssetBase : : ConformObjectDataToInterfaces ( )
{
return false ;
}
2024-06-27 14:58:15 -04:00
TSharedPtr < Audio : : IProxyData > FMetasoundAssetBase : : CreateProxyData ( const Audio : : FProxyDataInitParams & InitParams )
{
using namespace Metasound : : Frontend ;
TScriptInterface < const IMetaSoundDocumentInterface > DocInterface = GetOwningAsset ( ) ;
const FGraphRegistryKey & Key = GetGraphRegistryKey ( ) ;
FMetasoundAssetProxy : : FParameters Args ;
Args . Interfaces = DocInterface - > GetConstDocument ( ) . Interfaces ;
Args . Graph = FMetasoundFrontendRegistryContainer : : Get ( ) - > GetGraph ( Key ) ;
if ( Args . Graph . IsValid ( ) )
{
return MakeShared < FMetasoundAssetProxy > ( Args ) ;
}
return nullptr ;
}
2021-11-07 23:43:01 -05:00
void FMetasoundAssetBase : : RegisterGraphWithFrontend ( Metasound : : Frontend : : FMetaSoundAssetRegistrationOptions InRegistrationOptions )
2024-06-17 12:51:18 -04:00
{
UpdateAndRegisterForExecution ( MoveTemp ( InRegistrationOptions ) ) ;
}
void FMetasoundAssetBase : : UpdateAndRegisterForExecution ( Metasound : : Frontend : : FMetaSoundAssetRegistrationOptions InRegistrationOptions )
2020-07-23 16:39:56 -04:00
{
2021-06-08 10:52:31 -04:00
using namespace Metasound ;
using namespace Metasound : : Frontend ;
2020-07-23 16:39:56 -04:00
2023-10-03 12:17:13 -04:00
// Graph registration must only happen on one thread to avoid race conditions on graph registration.
checkf ( IsInGameThread ( ) , TEXT ( " MetaSound %s graph can only be registered on the GameThread " ) , * GetOwningAssetName ( ) ) ;
2024-06-17 12:51:18 -04:00
checkf ( Metasound : : CanEverExecuteGraph ( ) , TEXT ( " Cannot generate proxies/runtime graph when graph execution is not enabled. " ) ) ;
2023-10-03 12:17:13 -04:00
2024-06-17 12:51:18 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : UpdateAndRegisterForExecution ) ;
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE_TEXT ( * FString : : Printf ( TEXT ( " MetaSoundAssetBase::UpdateAndRegisterForExecution asset %s " ) , * this - > GetOwningAssetName ( ) ) ) ;
2021-08-18 15:16:57 -04:00
if ( ! InRegistrationOptions . bForceReregister )
2021-06-08 10:52:31 -04:00
{
2021-08-18 15:16:57 -04:00
if ( IsRegistered ( ) )
{
return ;
}
}
2022-10-13 17:38:11 -04:00
# if WITH_EDITOR
if ( InRegistrationOptions . bRebuildReferencedAssetClasses )
2021-08-18 15:16:57 -04:00
{
2022-10-13 17:38:11 -04:00
RebuildReferencedAssetClasses ( ) ;
2021-08-18 15:16:57 -04:00
}
2022-10-13 17:38:11 -04:00
# endif
2021-08-18 15:16:57 -04:00
if ( InRegistrationOptions . bRegisterDependencies )
{
2022-10-13 17:38:11 -04:00
RegisterAssetDependencies ( InRegistrationOptions ) ;
2021-08-18 15:16:57 -04:00
}
2024-05-08 14:53:53 -04:00
2024-08-23 21:59:54 -04:00
UObject * Owner = GetOwningAsset ( ) ;
check ( Owner ) ;
2024-05-08 14:53:53 -04:00
// This should not be necessary as it should be added on asset load,
// but currently registration is required to be called prior to adding
// an object-defined graph class to the registry so it was placed here.
2024-08-23 21:59:54 -04:00
IMetaSoundAssetManager : : GetChecked ( ) . AddOrUpdateAsset ( * Owner ) ;
2021-08-18 15:16:57 -04:00
// Auto update must be done after all referenced asset classes are registered
if ( InRegistrationOptions . bAutoUpdate )
{
2024-08-23 21:59:54 -04:00
# if WITH_EDITORONLY_DATA
2024-08-23 23:03:23 -04:00
bool bDidUpdate = false ;
// Only attempt asset versioning if owner is asset (dependency versioning on runtime MetaSound instances isn't supported nor necessary).
if ( Owner - > IsAsset ( ) )
{
FMetaSoundFrontendDocumentBuilder & DocBuilder = IDocumentBuilderRegistry : : GetChecked ( ) . FindOrBeginBuilding ( Owner ) ;
VersionDependencies ( DocBuilder , InRegistrationOptions . bAutoUpdateLogWarningOnDroppedConnection ) ;
}
2024-08-23 21:59:54 -04:00
# else // !WITH_EDITORONLY_DATA
constexpr bool bDidUpdate = false ;
# endif // WITH_EDITORONLY_DATA
2022-02-10 18:36:26 -05:00
# if WITH_EDITOR
2022-10-13 17:38:11 -04:00
if ( bDidUpdate | | InRegistrationOptions . bForceViewSynchronization )
2022-02-02 02:19:16 -05:00
{
2022-09-22 15:02:24 -04:00
GetModifyContext ( ) . SetForceRefreshViews ( ) ;
2022-02-02 02:19:16 -05:00
}
2022-02-10 18:36:26 -05:00
# endif // WITH_EDITOR
2022-02-02 02:19:16 -05:00
}
else
{
2022-02-10 18:36:26 -05:00
# if WITH_EDITOR
2022-02-02 02:19:16 -05:00
if ( InRegistrationOptions . bForceViewSynchronization )
2022-01-18 18:06:06 -05:00
{
2022-09-22 15:02:24 -04:00
GetModifyContext ( ) . SetForceRefreshViews ( ) ;
2021-11-18 14:37:34 -05:00
}
2022-02-10 18:36:26 -05:00
# endif // WITH_EDITOR
2021-06-08 10:52:31 -04:00
}
2022-02-10 18:36:26 -05:00
# if WITH_EDITOR
2022-01-20 19:19:55 -05:00
// Must be completed after auto-update to ensure all non-transient referenced dependency data is up-to-date (ex.
// class version), which is required for most accurately caching current registry metadata.
2022-01-26 18:11:52 -05:00
CacheRegistryMetadata ( ) ;
2022-02-10 18:36:26 -05:00
# endif // WITH_EDITOR
2022-01-20 19:19:55 -05:00
2024-04-24 10:36:28 -04:00
GraphRegistryKey = FRegistryContainerImpl : : Get ( ) . RegisterGraph ( Owner ) ;
2023-12-15 13:21:12 -05:00
if ( GraphRegistryKey . IsValid ( ) )
2021-06-16 11:21:13 -04:00
{
# if WITH_EDITORONLY_DATA
2022-10-13 17:38:11 -04:00
UpdateAssetRegistry ( ) ;
2021-06-16 11:21:13 -04:00
# endif // WITH_EDITORONLY_DATA
}
else
2021-06-08 10:52:31 -04:00
{
2023-09-13 20:11:49 -04:00
UClass * Class = Owner - > GetClass ( ) ;
2023-09-05 17:54:02 -04:00
check ( Class ) ;
const FString ClassName = Class - > GetName ( ) ;
2024-08-23 21:59:54 -04:00
const FString AssetName = Owner - > GetName ( ) ;
2021-08-18 15:16:57 -04:00
UE_LOG ( LogMetaSound , Error , TEXT ( " Registration failed for MetaSound node class '%s' of UObject class '%s' " ) , * AssetName , * ClassName ) ;
2021-06-08 10:52:31 -04:00
}
2020-07-23 16:39:56 -04:00
}
2023-09-05 17:54:02 -04:00
void FMetasoundAssetBase : : CookMetaSound ( )
2024-06-14 13:05:35 -04:00
{
# if WITH_EDITORONLY_DATA
2024-06-17 12:51:18 -04:00
UpdateAndRegisterForSerialization ( ) ;
2024-06-14 13:05:35 -04:00
# endif // WITH_EDITORONLY_DATA
}
# if WITH_EDITORONLY_DATA
2024-08-23 21:59:54 -04:00
void FMetasoundAssetBase : : UpdateAndRegisterForSerialization ( FName CookPlatformName )
2023-08-21 12:25:01 -04:00
{
using namespace Metasound ;
using namespace Metasound : : Frontend ;
2024-06-17 12:51:18 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : UpdateAndRegisterForSerialization ) ;
2024-06-14 13:05:35 -04:00
// If already registered, nothing to condition for presaving
2023-08-21 12:25:01 -04:00
if ( IsRegistered ( ) )
{
return ;
}
2024-08-23 21:59:54 -04:00
UpdateAndRegisterReferencesForSerialization ( CookPlatformName ) ;
2023-08-21 12:25:01 -04:00
IMetaSoundAssetManager : : GetChecked ( ) . AddOrUpdateAsset ( * GetOwningAsset ( ) ) ;
2024-08-23 21:59:54 -04:00
UObject * Owner = GetOwningAsset ( ) ;
check ( Owner ) ;
bool bDidUpdate = false ;
FMetaSoundFrontendDocumentBuilder & DocBuilder = IDocumentBuilderRegistry : : GetChecked ( ) . FindOrBeginBuilding ( Owner ) ;
if ( CookPlatformName . IsValid ( ) )
{
bDidUpdate | = IDocumentBuilderRegistry : : GetChecked ( ) . CookPages ( CookPlatformName , DocBuilder ) ;
}
2023-08-21 12:25:01 -04:00
// Auto update must be done after all referenced asset classes are registered
2024-08-23 21:59:54 -04:00
bDidUpdate | = VersionDependencies ( DocBuilder , /*bAutoUpdateLogWarningOnDroppedConnection=*/ true ) ;
2023-08-21 12:25:01 -04:00
# if WITH_EDITOR
if ( bDidUpdate )
{
GetModifyContext ( ) . SetForceRefreshViews ( ) ;
}
# endif // WITH_EDITOR
# if WITH_EDITOR
// Must be completed after auto-update to ensure all non-transient referenced dependency data is up-to-date (ex.
// class version), which is required for most accurately caching current registry metadata.
CacheRegistryMetadata ( ) ;
# endif // WITH_EDITOR
2023-09-13 20:11:49 -04:00
{
2024-05-08 14:53:53 -04:00
// Performs document transforms on local copy, which reduces document footprint & renders transforming unnecessary at runtime
2023-09-13 20:11:49 -04:00
const bool bContainsTemplateDependency = DocBuilder . ContainsDependencyOfType ( EMetasoundFrontendClassType : : Template ) ;
if ( bContainsTemplateDependency )
{
DocBuilder . TransformTemplateNodes ( ) ;
}
2023-08-21 12:25:01 -04:00
2023-12-19 15:55:04 -05:00
if ( GraphRegistryKey . IsValid ( ) )
{
FRegistryContainerImpl : : Get ( ) . UnregisterNode ( GraphRegistryKey . NodeKey ) ;
GraphRegistryKey = { } ;
}
2024-06-14 13:05:35 -04:00
// Need to register the node so that it is available for other graphs, but avoids creating proxies.
// This is accomplished by using a special node registration object which reflects the necessary
// information for the node registry, but does not create the runtime graph model (i.e. INodes).
2023-12-15 13:21:12 -05:00
TScriptInterface < IMetaSoundDocumentInterface > DocInterface ( Owner ) ;
const FMetasoundFrontendDocument & Document = DocInterface - > GetConstDocument ( ) ;
const FTopLevelAssetPath AssetPath = DocInterface - > GetAssetPathChecked ( ) ;
2024-07-19 17:36:32 -04:00
TUniquePtr < INodeRegistryEntry > RegistryEntry = MakeUnique < AssetBasePrivate : : FDocumentNodeRegistryEntryForSerialization > ( Document , AssetPath ) ;
2023-12-15 13:21:12 -05:00
2023-12-19 15:55:04 -05:00
const FNodeRegistryKey NodeKey = FRegistryContainerImpl : : Get ( ) . RegisterNode ( MoveTemp ( RegistryEntry ) ) ;
2023-12-15 13:21:12 -05:00
GraphRegistryKey = FGraphRegistryKey { NodeKey , AssetPath } ;
2023-09-13 20:11:49 -04:00
}
2023-08-21 12:25:01 -04:00
2023-12-15 13:21:12 -05:00
if ( GraphRegistryKey . IsValid ( ) )
2023-08-21 12:25:01 -04:00
{
UpdateAssetRegistry ( ) ;
}
else
{
2023-09-13 20:11:49 -04:00
const UClass * Class = Owner - > GetClass ( ) ;
2023-09-05 17:54:02 -04:00
check ( Class ) ;
const FString ClassName = Class - > GetName ( ) ;
2024-06-14 13:05:35 -04:00
UE_LOG ( LogMetaSound , Error , TEXT ( " Presave failed for MetaSound node class '%s' of UObject class '%s' " ) , * GetOwningAssetName ( ) , * ClassName ) ;
2023-08-21 12:25:01 -04:00
}
}
2024-06-14 13:05:35 -04:00
# endif // WITH_EDITORONLY_DATA
2023-08-21 12:25:01 -04:00
2023-12-19 15:55:04 -05:00
void FMetasoundAssetBase : : OnNotifyBeginDestroy ( )
{
2024-06-14 13:05:35 -04:00
using namespace Metasound ;
2023-12-19 15:55:04 -05:00
using namespace Metasound : : Frontend ;
2024-05-14 20:20:01 -04:00
UObject * OwningAsset = GetOwningAsset ( ) ;
check ( OwningAsset ) ;
2024-06-14 13:05:35 -04:00
// Unregistration of graph using local call is not necessary when cooking as deserialized objects are not mutable and, should they be
// reloaded, omitting unregistration avoids potentially kicking off an invalid asynchronous task to unregister a non-existent runtime graph.
2024-06-17 12:51:18 -04:00
if ( Metasound : : CanEverExecuteGraph ( ) )
2024-06-14 13:05:35 -04:00
{
UnregisterGraphWithFrontend ( ) ;
}
else
2023-12-19 15:55:04 -05:00
{
if ( GraphRegistryKey . IsValid ( ) )
{
FRegistryContainerImpl : : Get ( ) . UnregisterNode ( GraphRegistryKey . NodeKey ) ;
GraphRegistryKey = { } ;
}
}
2024-05-14 20:20:01 -04:00
if ( IMetaSoundAssetManager * AssetManager = IMetaSoundAssetManager : : Get ( ) )
{
AssetManager - > RemoveAsset ( * OwningAsset ) ;
} ;
2023-12-19 15:55:04 -05:00
}
2021-07-27 15:36:03 -04:00
void FMetasoundAssetBase : : UnregisterGraphWithFrontend ( )
{
2024-06-14 13:05:35 -04:00
using namespace Metasound ;
2021-07-27 15:36:03 -04:00
using namespace Metasound : : Frontend ;
2021-08-11 15:22:01 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : UnregisterGraphWithFrontend ) ;
2021-07-27 15:36:03 -04:00
2023-10-09 11:42:49 -04:00
check ( IsInGameThread ( ) ) ;
2024-06-17 12:51:18 -04:00
checkf ( Metasound : : CanEverExecuteGraph ( ) , TEXT ( " If execution is not supported, UnregisterNode must be called directly to avoid async attempt at destroying runtime graph that does not exist. " ) ) ;
2023-12-19 15:55:04 -05:00
2023-12-15 13:21:12 -05:00
if ( GraphRegistryKey . IsValid ( ) )
2021-07-27 15:36:03 -04:00
{
2023-12-15 13:21:12 -05:00
UObject * OwningAsset = GetOwningAsset ( ) ;
if ( ensureAlways ( OwningAsset ) )
{
2024-04-24 10:36:28 -04:00
const bool bSuccess = FRegistryContainerImpl : : Get ( ) . UnregisterGraph ( GraphRegistryKey , OwningAsset ) ;
2023-12-15 13:21:12 -05:00
if ( ! bSuccess )
{
UE_LOG ( LogMetaSound , Verbose , TEXT ( " Failed to unregister node with key %s for asset %s. No registry entry exists with that key. " ) , * GraphRegistryKey . ToString ( ) , * GetOwningAssetName ( ) ) ;
}
}
2023-12-11 20:36:24 -05:00
2023-12-15 13:21:12 -05:00
GraphRegistryKey = { } ;
2023-12-11 20:36:24 -05:00
}
2021-07-27 15:36:03 -04:00
}
2021-12-10 20:37:31 -05:00
bool FMetasoundAssetBase : : IsInterfaceDeclared ( const FMetasoundFrontendVersion & InVersion ) const
2021-11-22 15:55:50 -05:00
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return GetConstDocumentChecked ( ) . Interfaces . Contains ( InVersion ) ;
2021-07-28 17:12:57 -04:00
}
2023-09-13 20:11:49 -04:00
Metasound : : Frontend : : FNodeClassInfo FMetasoundAssetBase : : GetAssetClassInfo ( ) const
{
using namespace Metasound : : Frontend ;
const UObject * Owner = GetOwningAsset ( ) ;
check ( Owner ) ;
2023-12-15 13:21:12 -05:00
TScriptInterface < const IMetaSoundDocumentInterface > DocInterface ( ( UObject * ) Owner ) ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return FNodeClassInfo { GetConstDocumentChecked ( ) . RootGraph , DocInterface - > GetAssetPathChecked ( ) } ;
2023-09-13 20:11:49 -04:00
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
void FMetasoundAssetBase : : SetDocument ( FMetasoundFrontendDocument InDocument , bool bMarkDirty )
2020-12-14 15:48:27 -04:00
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
FMetasoundFrontendDocument * Document = GetDocumentAccessPtr ( ) . Get ( ) ;
* Document = MoveTemp ( InDocument ) ;
2023-08-21 12:25:01 -04:00
if ( bMarkDirty )
{
MarkMetasoundDocumentDirty ( ) ;
}
2023-03-07 17:01:52 -05:00
}
2024-05-30 18:56:24 -04:00
# if WITH_EDITORONLY_DATA
bool FMetasoundAssetBase : : VersionAsset ( FMetaSoundFrontendDocumentBuilder & Builder )
2021-06-23 20:08:21 -04:00
{
using namespace Metasound ;
2023-08-21 12:25:01 -04:00
2021-08-11 15:22:01 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : VersionAsset ) ;
2021-06-23 20:08:21 -04:00
2024-07-26 14:23:35 -04:00
bool bDidEdit = Frontend : : VersionDocument ( Builder ) ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
2024-05-30 18:56:24 -04:00
// TODO: Move this logic to builder API above, which will require rewriting update transforms to
// take in builder instead of DocumentHandle.
2021-11-22 15:55:50 -05:00
{
2024-05-30 18:56:24 -04:00
const FMetasoundFrontendDocument & Document = Builder . GetConstDocumentChecked ( ) ;
2021-11-22 15:55:50 -05:00
bool bInterfaceUpdated = false ;
2021-12-16 19:59:03 -05:00
bool bPassUpdated = true ;
2024-05-30 18:56:24 -04:00
// Has to be re-run until no pass reports an update in case versions
// fork (ex. an interface splits into two newly named interfaces).
2021-12-16 19:59:03 -05:00
while ( bPassUpdated )
2021-08-18 15:16:57 -04:00
{
2021-12-16 19:59:03 -05:00
bPassUpdated = false ;
2024-05-30 18:56:24 -04:00
const TArray < FMetasoundFrontendVersion > Versions = Document . Interfaces . Array ( ) ;
2024-07-26 14:23:35 -04:00
2021-12-16 19:59:03 -05:00
for ( const FMetasoundFrontendVersion & Version : Versions )
{
2024-05-30 18:56:24 -04:00
bPassUpdated | = TryUpdateInterfaceFromVersion ( Version ) ;
2021-12-16 19:59:03 -05:00
}
bInterfaceUpdated | = bPassUpdated ;
2021-08-18 15:16:57 -04:00
}
2021-12-16 19:59:03 -05:00
2021-11-22 15:55:50 -05:00
if ( bInterfaceUpdated )
{
2024-05-30 18:56:24 -04:00
TScriptInterface < IMetaSoundDocumentInterface > Interface ( GetOwningAsset ( ) ) ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
Interface - > ConformObjectToDocument ( ) ;
2021-11-22 15:55:50 -05:00
}
bDidEdit | = bInterfaceUpdated ;
2021-06-23 20:08:21 -04:00
}
2021-07-27 15:36:03 -04:00
return bDidEdit ;
2021-02-01 15:59:27 -04:00
}
2024-05-30 18:56:24 -04:00
# endif // WITH_EDITORONLY_DATA
2021-02-01 15:59:27 -04:00
2022-02-10 18:36:26 -05:00
# if WITH_EDITOR
2022-01-26 18:11:52 -05:00
void FMetasoundAssetBase : : CacheRegistryMetadata ( )
{
using namespace Metasound : : Frontend ;
2023-03-07 17:01:52 -05:00
FMetasoundFrontendDocument * Document = GetDocumentAccessPtr ( ) . Get ( ) ;
2022-01-26 18:11:52 -05:00
if ( ! ensure ( Document ) )
{
return ;
}
using FNameDataTypePair = TPair < FName , FName > ;
const TSet < FMetasoundFrontendVersion > & InterfaceVersions = Document - > Interfaces ;
FMetasoundFrontendClassInterface & RootGraphClassInterface = Document - > RootGraph . Interface ;
// 1. Gather inputs/outputs managed by interfaces
TMap < FNameDataTypePair , FMetasoundFrontendClassInput * > Inputs ;
for ( FMetasoundFrontendClassInput & Input : RootGraphClassInterface . Inputs )
{
FNameDataTypePair NameDataTypePair = FNameDataTypePair ( Input . Name , Input . TypeName ) ;
Inputs . Add ( MoveTemp ( NameDataTypePair ) , & Input ) ;
}
TMap < FNameDataTypePair , FMetasoundFrontendClassOutput * > Outputs ;
for ( FMetasoundFrontendClassOutput & Output : RootGraphClassInterface . Outputs )
{
FNameDataTypePair NameDataTypePair = FNameDataTypePair ( Output . Name , Output . TypeName ) ;
Outputs . Add ( MoveTemp ( NameDataTypePair ) , & Output ) ;
}
// 2. Copy metadata for inputs/outputs managed by interfaces, removing them from maps generated
2024-05-29 15:33:29 -04:00
auto CacheInterfaceMetadata = [ ] ( const FMetasoundFrontendVertexMetadata & InRegistryMetadata , FMetasoundFrontendVertexMetadata & OutMetadata )
2022-03-01 16:31:55 -05:00
{
const int32 CachedSortOrderIndex = OutMetadata . SortOrderIndex ;
OutMetadata = InRegistryMetadata ;
OutMetadata . SortOrderIndex = CachedSortOrderIndex ;
} ;
2022-01-26 18:11:52 -05:00
for ( const FMetasoundFrontendVersion & Version : InterfaceVersions )
{
const FInterfaceRegistryKey InterfaceKey = GetInterfaceRegistryKey ( Version ) ;
const IInterfaceRegistryEntry * Entry = IInterfaceRegistry : : Get ( ) . FindInterfaceRegistryEntry ( InterfaceKey ) ;
2024-03-25 13:35:20 -04:00
UE_CLOG ( nullptr = = Entry , LogMetaSound , Error , TEXT ( " Failed to find interface (%s) when caching registry data for %s. MetaSound inputs and outputs for asset may not function correctly. " ) , * Version . ToString ( ) , * GetOwningAssetName ( ) ) ;
if ( Entry )
2022-01-26 18:11:52 -05:00
{
for ( const FMetasoundFrontendClassInput & InterfaceInput : Entry - > GetInterface ( ) . Inputs )
{
const FNameDataTypePair NameDataTypePair = FNameDataTypePair ( InterfaceInput . Name , InterfaceInput . TypeName ) ;
if ( FMetasoundFrontendClassInput * Input = Inputs . FindRef ( NameDataTypePair ) )
{
2022-03-01 16:31:55 -05:00
CacheInterfaceMetadata ( InterfaceInput . Metadata , Input - > Metadata ) ;
2022-01-26 18:11:52 -05:00
Inputs . Remove ( NameDataTypePair ) ;
}
}
for ( const FMetasoundFrontendClassOutput & InterfaceOutput : Entry - > GetInterface ( ) . Outputs )
{
const FNameDataTypePair NameDataTypePair = FNameDataTypePair ( InterfaceOutput . Name , InterfaceOutput . TypeName ) ;
if ( FMetasoundFrontendClassOutput * Output = Outputs . FindRef ( NameDataTypePair ) )
{
2022-03-01 16:31:55 -05:00
CacheInterfaceMetadata ( InterfaceOutput . Metadata , Output - > Metadata ) ;
2022-01-26 18:11:52 -05:00
Outputs . Remove ( NameDataTypePair ) ;
}
}
}
}
// 3. Iterate remaining inputs/outputs not managed by interfaces and set to serialize text
// (in case they were orphaned by an interface no longer being implemented).
for ( TPair < FNameDataTypePair , FMetasoundFrontendClassInput * > & Pair : Inputs )
{
Pair . Value - > Metadata . SetSerializeText ( true ) ;
}
for ( TPair < FNameDataTypePair , FMetasoundFrontendClassOutput * > & Pair : Outputs )
{
Pair . Value - > Metadata . SetSerializeText ( true ) ;
}
2022-03-01 16:31:55 -05:00
// 4. Refresh style as order of members could've changed
{
FMetasoundFrontendInterfaceStyle InputStyle ;
Algo : : ForEach ( RootGraphClassInterface . Inputs , [ & InputStyle ] ( const FMetasoundFrontendClassInput & Input )
{
InputStyle . DefaultSortOrder . Add ( Input . Metadata . SortOrderIndex ) ;
} ) ;
RootGraphClassInterface . SetInputStyle ( InputStyle ) ;
}
{
FMetasoundFrontendInterfaceStyle OutputStyle ;
Algo : : ForEach ( RootGraphClassInterface . Outputs , [ & OutputStyle ] ( const FMetasoundFrontendClassOutput & Output )
{
OutputStyle . DefaultSortOrder . Add ( Output . Metadata . SortOrderIndex ) ;
} ) ;
RootGraphClassInterface . SetOutputStyle ( OutputStyle ) ;
}
// 5. Cache registry data on document dependencies
2022-01-27 01:31:46 -05:00
for ( FMetasoundFrontendClass & Dependency : Document - > Dependencies )
2022-01-26 18:11:52 -05:00
{
2022-01-27 01:31:46 -05:00
if ( ! FMetasoundFrontendClass : : CacheGraphDependencyMetadataFromRegistry ( Dependency ) )
2022-01-26 18:11:52 -05:00
{
UE_LOG ( LogMetaSound , Warning ,
TEXT ( " '%s' failed to cache dependency registry data: Registry missing class with key '%s' " ) ,
* GetOwningAssetName ( ) ,
2022-01-27 01:31:46 -05:00
* Dependency . Metadata . GetClassName ( ) . ToString ( ) ) ;
2022-01-26 18:11:52 -05:00
UE_LOG ( LogMetaSound , Warning ,
TEXT ( " Asset '%s' may fail to build runtime graph unless re-registered after dependency with given key is loaded. " ) ,
* GetOwningAssetName ( ) ) ;
}
}
}
2022-09-22 15:02:24 -04:00
FMetasoundFrontendDocumentModifyContext & FMetasoundAssetBase : : GetModifyContext ( )
2021-11-18 14:37:34 -05:00
{
2024-06-21 15:02:09 -04:00
// ModifyContext is now mutable to avoid mutations to it requiring access through
// the deprecated Document controller causing the builder cache to get wiped unnecessarily.
return GetConstDocumentChecked ( ) . Metadata . ModifyContext ;
2021-11-18 14:37:34 -05:00
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
const FMetasoundFrontendDocumentModifyContext & FMetasoundAssetBase : : GetConstModifyContext ( ) const
{
return GetConstDocumentChecked ( ) . Metadata . ModifyContext ;
}
2022-09-22 15:02:24 -04:00
const FMetasoundFrontendDocumentModifyContext & FMetasoundAssetBase : : GetModifyContext ( ) const
2021-11-22 15:55:50 -05:00
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return GetConstDocumentChecked ( ) . Metadata . ModifyContext ;
2021-11-18 14:37:34 -05:00
}
2022-02-10 18:36:26 -05:00
# endif // WITH_EDITOR
2021-11-18 14:37:34 -05:00
2021-08-18 15:16:57 -04:00
bool FMetasoundAssetBase : : IsRegistered ( ) const
2021-07-27 15:36:03 -04:00
{
2021-08-18 15:16:57 -04:00
using namespace Metasound : : Frontend ;
2023-12-15 13:21:12 -05:00
return GraphRegistryKey . IsValid ( ) ;
2021-07-27 15:36:03 -04:00
}
2021-11-18 14:37:34 -05:00
bool FMetasoundAssetBase : : IsReferencedAsset ( const FMetasoundAssetBase & InAsset ) const
{
using namespace Metasound : : Frontend ;
bool bIsReferenced = false ;
2022-05-10 16:51:39 -04:00
AssetBasePrivate : : DepthFirstTraversal ( * this , [ & ] ( const FMetasoundAssetBase & ChildAsset )
2021-11-18 14:37:34 -05:00
{
TSet < const FMetasoundAssetBase * > Children ;
if ( & ChildAsset = = & InAsset )
{
bIsReferenced = true ;
return Children ;
}
TArray < FMetasoundAssetBase * > ChildRefs ;
ensureAlways ( IMetaSoundAssetManager : : GetChecked ( ) . TryLoadReferencedAssets ( ChildAsset , ChildRefs ) ) ;
Algo : : Transform ( ChildRefs , Children , [ ] ( FMetasoundAssetBase * Child ) { return Child ; } ) ;
return Children ;
} ) ;
return bIsReferenced ;
}
2024-05-08 14:53:53 -04:00
bool FMetasoundAssetBase : : AddingReferenceCausesLoop ( const FMetasoundAssetBase & InMetaSound ) const
2021-07-27 15:36:03 -04:00
{
2021-11-07 23:43:01 -05:00
using namespace Metasound : : Frontend ;
2021-07-27 15:36:03 -04:00
bool bCausesLoop = false ;
const FMetasoundAssetBase * Parent = this ;
2024-05-08 14:53:53 -04:00
AssetBasePrivate : : DepthFirstTraversal ( InMetaSound , [ & ] ( const FMetasoundAssetBase & ChildAsset )
2021-07-27 15:36:03 -04:00
{
TSet < const FMetasoundAssetBase * > Children ;
if ( Parent = = & ChildAsset )
{
bCausesLoop = true ;
return Children ;
}
2021-11-07 23:43:01 -05:00
TArray < FMetasoundAssetBase * > ChildRefs ;
2021-11-18 14:37:34 -05:00
ensureAlways ( IMetaSoundAssetManager : : GetChecked ( ) . TryLoadReferencedAssets ( ChildAsset , ChildRefs ) ) ;
2024-05-08 14:53:53 -04:00
Algo : : Transform ( ChildRefs , Children , [ ] ( FMetasoundAssetBase * Child ) { return Child ; } ) ;
2021-07-27 15:36:03 -04:00
return Children ;
} ) ;
return bCausesLoop ;
}
2024-05-08 14:53:53 -04:00
bool FMetasoundAssetBase : : AddingReferenceCausesLoop ( const FSoftObjectPath & InReferencePath ) const
{
using namespace Metasound : : Frontend ;
const FMetasoundAssetBase * ReferenceAsset = IMetaSoundAssetManager : : GetChecked ( ) . TryLoadAsset ( InReferencePath ) ;
if ( ! ensureAlways ( ReferenceAsset ) )
{
return false ;
}
return AddingReferenceCausesLoop ( * ReferenceAsset ) ;
}
2021-06-08 10:52:31 -04:00
TArray < FMetasoundAssetBase : : FSendInfoAndVertexName > FMetasoundAssetBase : : GetSendInfos ( uint64 InInstanceID ) const
{
2023-10-03 12:17:13 -04:00
return TArray < FSendInfoAndVertexName > ( ) ;
2021-06-08 10:52:31 -04:00
}
2022-02-10 18:36:26 -05:00
# if WITH_EDITOR
2021-06-08 10:52:31 -04:00
FText FMetasoundAssetBase : : GetDisplayName ( FString & & InTypeName ) const
{
using namespace Metasound : : Frontend ;
FConstGraphHandle GraphHandle = GetRootGraphHandle ( ) ;
const bool bIsPreset = ! GraphHandle - > GetGraphStyle ( ) . bIsGraphEditable ;
if ( ! bIsPreset )
{
return FText : : FromString ( MoveTemp ( InTypeName ) ) ;
}
return FText : : Format ( LOCTEXT ( " PresetDisplayNameFormat " , " {0} (Preset) " ) , FText : : FromString ( MoveTemp ( InTypeName ) ) ) ;
}
2022-02-10 18:36:26 -05:00
# endif // WITH_EDITOR
2021-06-08 10:52:31 -04:00
2021-02-01 15:59:27 -04:00
bool FMetasoundAssetBase : : MarkMetasoundDocumentDirty ( ) const
{
if ( const UObject * OwningAsset = GetOwningAsset ( ) )
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return OwningAsset - > MarkPackageDirty ( ) ;
2021-02-01 15:59:27 -04:00
}
return false ;
2020-07-23 20:32:26 -04:00
}
2021-01-13 10:48:59 -04:00
Metasound : : Frontend : : FDocumentHandle FMetasoundAssetBase : : GetDocumentHandle ( )
{
2023-03-07 17:01:52 -05:00
return Metasound : : Frontend : : IDocumentController : : CreateDocumentHandle ( GetDocumentAccessPtr ( ) ) ;
2021-01-13 10:48:59 -04:00
}
2020-07-17 16:43:42 -04:00
2021-01-13 19:18:22 -04:00
Metasound : : Frontend : : FConstDocumentHandle FMetasoundAssetBase : : GetDocumentHandle ( ) const
{
2023-03-07 17:01:52 -05:00
return Metasound : : Frontend : : IDocumentController : : CreateDocumentHandle ( GetDocumentConstAccessPtr ( ) ) ;
2021-01-13 19:18:22 -04:00
}
2020-12-14 15:48:27 -04:00
Metasound : : Frontend : : FGraphHandle FMetasoundAssetBase : : GetRootGraphHandle ( )
2020-07-17 16:43:42 -04:00
{
2021-01-13 10:48:59 -04:00
return GetDocumentHandle ( ) - > GetRootGraph ( ) ;
2020-07-17 16:43:42 -04:00
}
2021-01-13 19:18:22 -04:00
Metasound : : Frontend : : FConstGraphHandle FMetasoundAssetBase : : GetRootGraphHandle ( ) const
{
return GetDocumentHandle ( ) - > GetRootGraph ( ) ;
}
2020-08-05 12:47:19 -04:00
bool FMetasoundAssetBase : : ImportFromJSON ( const FString & InJSON )
2020-07-23 16:39:56 -04:00
{
2021-08-11 15:22:01 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : ImportFromJSON ) ;
2023-03-07 17:01:52 -05:00
FMetasoundFrontendDocument * Document = GetDocumentAccessPtr ( ) . Get ( ) ;
2021-07-12 16:13:03 -04:00
if ( ensure ( nullptr ! = Document ) )
2020-12-14 15:48:27 -04:00
{
2021-02-01 15:59:27 -04:00
bool bSuccess = Metasound : : Frontend : : ImportJSONToMetasound ( InJSON , * Document ) ;
if ( bSuccess )
{
ensure ( MarkMetasoundDocumentDirty ( ) ) ;
}
return bSuccess ;
2020-12-14 15:48:27 -04:00
}
return false ;
2020-07-23 16:39:56 -04:00
}
2020-08-05 12:47:19 -04:00
bool FMetasoundAssetBase : : ImportFromJSONAsset ( const FString & InAbsolutePath )
2020-07-17 16:43:42 -04:00
{
2021-08-11 15:22:01 -04:00
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE ( MetaSoundAssetBase : : ImportFromJSONAsset ) ;
2023-03-07 17:01:52 -05:00
Metasound : : Frontend : : FDocumentAccessPtr DocumentPtr = GetDocumentAccessPtr ( ) ;
2021-07-12 16:13:03 -04:00
if ( FMetasoundFrontendDocument * Document = DocumentPtr . Get ( ) )
2020-12-14 15:48:27 -04:00
{
2021-02-01 15:59:27 -04:00
bool bSuccess = Metasound : : Frontend : : ImportJSONAssetToMetasound ( InAbsolutePath , * Document ) ;
if ( bSuccess )
{
ensure ( MarkMetasoundDocumentDirty ( ) ) ;
}
return bSuccess ;
2020-12-14 15:48:27 -04:00
}
return false ;
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
const FMetasoundFrontendDocument & FMetasoundAssetBase : : GetConstDocumentChecked ( ) const
{
const UObject * Owner = GetOwningAsset ( ) ;
check ( Owner ) ;
2024-05-30 18:56:24 -04:00
TScriptInterface < const IMetaSoundDocumentInterface > DocInterface = Owner ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return DocInterface - > GetConstDocument ( ) ;
}
2021-01-13 10:48:59 -04:00
FMetasoundFrontendDocument & FMetasoundAssetBase : : GetDocumentChecked ( )
2020-12-14 15:48:27 -04:00
{
2023-03-07 17:01:52 -05:00
FMetasoundFrontendDocument * Document = GetDocumentAccessPtr ( ) . Get ( ) ;
2021-07-12 16:13:03 -04:00
check ( nullptr ! = Document ) ;
return * Document ;
2020-12-14 15:48:27 -04:00
}
2021-01-13 10:48:59 -04:00
const FMetasoundFrontendDocument & FMetasoundAssetBase : : GetDocumentChecked ( ) const
2020-12-14 15:48:27 -04:00
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return GetConstDocumentChecked ( ) ;
2020-08-05 12:47:19 -04:00
}
2021-07-28 17:12:57 -04:00
2023-12-15 13:21:12 -05:00
const Metasound : : Frontend : : FGraphRegistryKey & FMetasoundAssetBase : : GetGraphRegistryKey ( ) const
{
return GraphRegistryKey ;
}
2023-03-23 14:04:36 -04:00
const Metasound : : Frontend : : FNodeRegistryKey & FMetasoundAssetBase : : GetRegistryKey ( ) const
{
2023-12-15 13:21:12 -05:00
return GraphRegistryKey . NodeKey ;
2023-03-23 14:04:36 -04:00
}
2021-07-28 17:12:57 -04:00
FString FMetasoundAssetBase : : GetOwningAssetName ( ) const
{
if ( const UObject * OwningAsset = GetOwningAsset ( ) )
{
2022-01-27 00:45:28 -05:00
return OwningAsset - > GetPathName ( ) ;
2021-07-28 17:12:57 -04:00
}
return FString ( ) ;
}
2022-10-13 17:38:11 -04:00
# if WITH_EDITOR
void FMetasoundAssetBase : : RebuildReferencedAssetClasses ( )
2022-01-21 15:40:14 -05:00
{
using namespace Metasound : : Frontend ;
2022-10-13 17:38:11 -04:00
IMetaSoundAssetManager & AssetManager = IMetaSoundAssetManager : : GetChecked ( ) ;
2024-06-05 11:00:21 -04:00
AssetManager . AddAssetReferences ( * this ) ;
TSet < IMetaSoundAssetManager : : FAssetInfo > ReferencedAssetClasses = AssetManager . GetReferencedAssetClasses ( * this ) ;
SetReferencedAssetClasses ( MoveTemp ( ReferencedAssetClasses ) ) ;
2022-10-13 17:38:11 -04:00
}
# endif // WITH_EDITOR
void FMetasoundAssetBase : : RegisterAssetDependencies ( const Metasound : : Frontend : : FMetaSoundAssetRegistrationOptions & InRegistrationOptions )
{
using namespace Metasound : : Frontend ;
IMetaSoundAssetManager & AssetManager = IMetaSoundAssetManager : : GetChecked ( ) ;
TArray < FMetasoundAssetBase * > References = GetReferencedAssets ( ) ;
for ( FMetasoundAssetBase * Reference : References )
{
if ( InRegistrationOptions . bForceReregister | | ! Reference - > IsRegistered ( ) )
{
// TODO: Check for infinite recursion and error if so
AssetManager . AddOrUpdateAsset ( * ( Reference - > GetOwningAsset ( ) ) ) ;
2024-06-17 12:51:18 -04:00
Reference - > UpdateAndRegisterForExecution ( InRegistrationOptions ) ;
2022-10-13 17:38:11 -04:00
}
}
}
2023-09-05 17:54:02 -04:00
void FMetasoundAssetBase : : CookReferencedMetaSounds ( )
2024-06-14 13:05:35 -04:00
{
# if WITH_EDITORONLY_DATA
2024-08-23 21:59:54 -04:00
UpdateAndRegisterReferencesForSerialization ( { } ) ;
2024-06-14 13:05:35 -04:00
# endif // WITH_EDITORONLY_DATA
}
# if WITH_EDITORONLY_DATA
2024-08-23 21:59:54 -04:00
void FMetasoundAssetBase : : UpdateAndRegisterReferencesForSerialization ( FName CookPlatformName )
2023-08-21 12:25:01 -04:00
{
using namespace Metasound : : Frontend ;
IMetaSoundAssetManager & AssetManager = IMetaSoundAssetManager : : GetChecked ( ) ;
TArray < FMetasoundAssetBase * > References = GetReferencedAssets ( ) ;
for ( FMetasoundAssetBase * Reference : References )
{
if ( ! Reference - > IsRegistered ( ) )
{
// TODO: Check for infinite recursion and error if so
AssetManager . AddOrUpdateAsset ( * ( Reference - > GetOwningAsset ( ) ) ) ;
2024-08-23 21:59:54 -04:00
Reference - > UpdateAndRegisterForSerialization ( CookPlatformName ) ;
2023-08-21 12:25:01 -04:00
}
}
}
2024-06-14 13:05:35 -04:00
# endif // WITH_EDITORONLY_DATA
2023-08-21 12:25:01 -04:00
2022-10-13 17:38:11 -04:00
bool FMetasoundAssetBase : : AutoUpdate ( bool bInLogWarningsOnDroppedConnection )
{
using namespace Metasound : : Frontend ;
2024-08-23 21:59:54 -04:00
UObject * Owner = GetOwningAsset ( ) ;
check ( Owner ) ;
# if WITH_EDITORONLY_DATA
FMetaSoundFrontendDocumentBuilder & DocBuilder = IDocumentBuilderRegistry : : GetChecked ( ) . FindOrBeginBuilding ( Owner ) ;
return VersionDependencies ( DocBuilder , bInLogWarningsOnDroppedConnection ) ;
# else // !WITH_EDITORONLY_DATA
return false ;
# endif // !WITH_EDITORONLY_DATA
2022-10-13 17:38:11 -04:00
}
# if WITH_EDITORONLY_DATA
void FMetasoundAssetBase : : UpdateAssetRegistry ( )
{
using namespace Metasound ;
using namespace Metasound : : Frontend ;
2023-12-15 13:21:12 -05:00
UObject * Owner = GetOwningAsset ( ) ;
2023-09-13 20:11:49 -04:00
check ( Owner ) ;
2024-05-08 14:53:53 -04:00
const FMetasoundFrontendGraphClass & DocumentClassGraph = GetDocumentChecked ( ) . RootGraph ;
2023-12-15 13:21:12 -05:00
TScriptInterface < IMetaSoundDocumentInterface > DocInterface ( Owner ) ;
2024-05-08 14:53:53 -04:00
FNodeClassInfo AssetClassInfo ( DocumentClassGraph , DocInterface - > GetAssetPathChecked ( ) ) ;
2023-09-13 20:11:49 -04:00
2022-10-13 17:38:11 -04:00
// Refresh Asset Registry Info if successfully registered with Frontend
const FMetasoundFrontendClassMetadata & DocumentClassMetadata = DocumentClassGraph . Metadata ;
AssetClassInfo . AssetClassID = FGuid ( DocumentClassMetadata . GetClassName ( ) . Name . ToString ( ) ) ;
FNodeClassName ClassName = DocumentClassMetadata . GetClassName ( ) . ToNodeClassName ( ) ;
FMetasoundFrontendClass GraphClass ;
2023-09-12 13:54:05 -04:00
AssetClassInfo . bIsPreset = DocumentClassGraph . PresetOptions . bIsPreset ;
2022-10-13 17:38:11 -04:00
AssetClassInfo . Version = DocumentClassMetadata . GetVersion ( ) ;
AssetClassInfo . InputTypes . Reset ( ) ;
Algo : : Transform ( GraphClass . Interface . Inputs , AssetClassInfo . InputTypes , [ ] ( const FMetasoundFrontendClassInput & Input ) { return Input . TypeName ; } ) ;
AssetClassInfo . OutputTypes . Reset ( ) ;
Algo : : Transform ( GraphClass . Interface . Outputs , AssetClassInfo . OutputTypes , [ ] ( const FMetasoundFrontendClassOutput & Output ) { return Output . TypeName ; } ) ;
SetRegistryAssetClassInfo ( MoveTemp ( AssetClassInfo ) ) ;
}
# endif
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
bool FMetasoundAssetBase : : TryUpdateInterfaceFromVersion ( const FMetasoundFrontendVersion & Version )
{
using namespace Metasound : : Frontend ;
using namespace AssetBasePrivate ;
2024-05-30 18:56:24 -04:00
FMetasoundFrontendInterface TargetInterface = GetInterfaceToVersion ( Version ) ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
if ( TargetInterface . Version . IsValid ( ) )
{
TArray < const IInterfaceRegistryEntry * > UpgradePath ;
GetUpdatePathForDocument ( Version , TargetInterface . Version , UpgradePath ) ;
const bool bUpdated = UpdateDocumentInterface ( UpgradePath , Version , GetDocumentHandle ( ) ) ;
ensureMsgf ( bUpdated , TEXT ( " Target interface '%s' was out-of-date but interface failed to be updated " ) , * TargetInterface . Version . ToString ( ) ) ;
return bUpdated ;
}
return false ;
}
2024-08-23 21:59:54 -04:00
bool FMetasoundAssetBase : : VersionDependencies ( FMetaSoundFrontendDocumentBuilder & Builder , bool bInLogWarningsOnDroppedConnection )
{
using namespace Metasound : : Frontend ;
bool bDocumentModified = false ;
# if WITH_EDITORONLY_DATA
const FGuid InitBuildPageID = Builder . GetBuildPageID ( ) ;
Metasound : : Frontend : : FDocumentHandle DocHandle = GetDocumentHandle ( ) ;
const FMetasoundFrontendGraphClass & RootGraph = Builder . GetConstDocumentChecked ( ) . RootGraph ;
2024-08-30 12:53:13 -04:00
constexpr bool bBroadcastPageIDDelegate = false ;
2024-10-04 14:27:34 -04:00
FAutoUpdateRootGraph AutoUpdateTransform ( GetOwningAssetName ( ) , bInLogWarningsOnDroppedConnection ) ;
2024-08-23 21:59:54 -04:00
RootGraph . IterateGraphPages ( [ & ] ( const FMetasoundFrontendGraph & Graph )
{
// Set the build page ID to this graph as a hack to apply dependency versioning logic using
// the controller/handle API until auto-update is renamed & moved to use document builder API.
2024-08-30 12:53:13 -04:00
Builder . SetBuildPageID ( Graph . PageID , bBroadcastPageIDDelegate ) ;
2024-10-04 14:27:34 -04:00
bDocumentModified | = AutoUpdateTransform . Transform ( DocHandle ) ;
2024-08-23 21:59:54 -04:00
} ) ;
2024-08-30 12:53:13 -04:00
Builder . SetBuildPageID ( InitBuildPageID , bBroadcastPageIDDelegate ) ;
2024-08-23 21:59:54 -04:00
# endif // WITH_EDITORONLY_DATA
return bDocumentModified ;
}
2024-05-30 18:56:24 -04:00
FMetasoundFrontendInterface FMetasoundAssetBase : : GetInterfaceToVersion ( const FMetasoundFrontendVersion & InterfaceVersion ) const
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
{
using namespace Metasound : : Frontend ;
// Find registered target interface.
FMetasoundFrontendInterface TargetInterface ;
bool bFoundTargetInterface = ISearchEngine : : Get ( ) . FindInterfaceWithHighestVersion ( InterfaceVersion . Name , TargetInterface ) ;
if ( ! bFoundTargetInterface )
{
UE_LOG ( LogMetaSound , Warning ,
TEXT ( " Could not check for interface updates. Target interface is not registered [InterfaceVersion:%s] when attempting to update root graph of asset (%s). "
" Ensure that the module which registers the interface has been loaded before the asset is loaded. " ) ,
* InterfaceVersion . ToString ( ) ,
* GetOwningAssetName ( ) ) ;
return { } ;
}
if ( TargetInterface . Version = = InterfaceVersion )
{
return { } ;
}
return TargetInterface ;
}
2022-10-13 17:38:11 -04:00
TSharedPtr < FMetasoundFrontendDocument > FMetasoundAssetBase : : PreprocessDocument ( )
{
2023-09-05 17:54:02 -04:00
return nullptr ;
2022-01-21 15:40:14 -05:00
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
# if WITH_EDITORONLY_DATA
bool FMetasoundAssetBase : : GetVersionedOnLoad ( ) const
{
return bVersionedOnLoad ;
}
void FMetasoundAssetBase : : ClearVersionedOnLoad ( )
{
bVersionedOnLoad = false ;
}
void FMetasoundAssetBase : : SetVersionedOnLoad ( )
{
bVersionedOnLoad = true ;
}
# endif // WITH_EDITORONLY_DATA
2023-10-03 12:17:13 -04:00
PRAGMA_DISABLE_DEPRECATION_WARNINGS
2022-03-10 22:07:08 -05:00
const FMetasoundAssetBase : : FRuntimeData & FMetasoundAssetBase : : GetRuntimeData ( ) const
{
2023-10-03 12:17:13 -04:00
static const FRuntimeData PlaceholderForDeprecatedMethod ;
return PlaceholderForDeprecatedMethod ;
2022-03-10 22:07:08 -05:00
}
2023-10-03 12:17:13 -04:00
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2022-03-10 22:07:08 -05:00
2024-06-27 14:58:15 -04:00
FMetasoundAssetProxy : : FMetasoundAssetProxy ( const FParameters & InParams )
{
Interfaces = InParams . Interfaces ;
Graph = InParams . Graph ;
}
FMetasoundAssetProxy : : FMetasoundAssetProxy ( const FMetasoundAssetProxy & Other )
{
Interfaces = Other . Interfaces ;
Graph = Other . Graph ;
}
2021-06-08 10:52:31 -04:00
# undef LOCTEXT_NAMESPACE // "MetaSound"