2020-07-15 00:16:40 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "Metasound.h"
2022-05-02 18:59:38 -04:00
# include "AssetRegistry/AssetRegistryModule.h"
2021-06-08 10:52:31 -04:00
# include "Internationalization/Text.h"
2022-09-14 18:49:46 -04:00
# include "Logging/TokenizedMessage.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundAssetBase.h"
2024-06-06 18:50:18 -04:00
# include "MetasoundAssetManager.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundAudioFormats.h"
2023-05-10 20:28:39 -04:00
# include "MetasoundBuilderSubsystem.h"
2024-05-08 14:53:53 -04:00
# include "MetasoundDocumentInterface.h"
2022-10-13 17:38:11 -04:00
# include "MetasoundEngineAsset.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundEngineEnvironment.h"
2021-07-27 15:36:03 -04:00
# include "MetasoundEnvironment.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundFrontendController.h"
- 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
# include "MetasoundFrontendDocument.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundFrontendQuery.h"
# include "MetasoundFrontendQuerySteps.h"
2021-08-18 15:16:57 -04:00
# include "MetasoundFrontendRegistries.h"
2023-12-15 13:21:12 -05:00
# include "MetasoundFrontendRegistryContainer.h"
# include "MetasoundFrontendRegistryKey.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundFrontendSearchEngine.h"
# include "MetasoundGenerator.h"
# include "MetasoundLog.h"
# include "MetasoundOperatorSettings.h"
2021-08-30 14:08:45 -04:00
# include "MetasoundParameterTransmitter.h"
2021-06-08 10:52:31 -04:00
# include "MetasoundPrimitives.h"
# include "MetasoundReceiveNode.h"
# include "MetasoundTrigger.h"
2021-07-27 15:36:03 -04:00
# include "MetasoundUObjectRegistry.h"
2021-06-08 10:52:31 -04:00
# include "UObject/ObjectSaveContext.h"
2020-07-23 16:39:56 -04:00
2022-09-28 01:06:15 -04:00
# include UE_INLINE_GENERATED_CPP_BY_NAME(Metasound)
2024-08-30 12:53:13 -04:00
# if WITH_EDITOR
# include "Misc/DataValidation.h"
# endif // WITH_EDITOR
2021-06-08 10:52:31 -04:00
# if WITH_EDITORONLY_DATA
# include "EdGraph/EdGraph.h"
# endif // WITH_EDITORONLY_DATA
# define LOCTEXT_NAMESPACE "MetaSound"
2021-06-16 11:21:13 -04:00
2022-09-14 18:49:46 -04:00
int32 UMetasoundEditorGraphBase : : GetHighestMessageSeverity ( ) const
{
int32 HighestMessageSeverity = EMessageSeverity : : Info ;
for ( const UEdGraphNode * Node : Nodes )
{
// Lower integer value is "higher severity"
if ( Node - > ErrorType < HighestMessageSeverity )
{
HighestMessageSeverity = Node - > ErrorType ;
}
}
return HighestMessageSeverity ;
}
2022-08-12 14:54:54 -04:00
UMetaSoundPatch : : UMetaSoundPatch ( const FObjectInitializer & ObjectInitializer )
2020-07-15 00:16:40 -04:00
: Super ( ObjectInitializer )
2021-06-08 10:52:31 -04:00
, FMetasoundAssetBase ( )
2020-07-15 00:16:40 -04:00
{
}
2023-09-14 16:54:36 -04:00
Metasound : : Frontend : : FDocumentAccessPtr UMetaSoundPatch : : GetDocumentAccessPtr ( )
{
using namespace Metasound : : Frontend ;
// Mutation of a document via the soft deprecated access ptr/controller system is not tracked by
2024-05-08 14:53:53 -04:00
// the builder registry, so the document cache is invalidated here.
2024-06-20 15:27:03 -04:00
if ( IDocumentBuilderRegistry * BuilderRegistry = IDocumentBuilderRegistry : : Get ( ) )
2023-09-15 02:05:23 -04:00
{
2024-06-20 15:27:03 -04:00
BuilderRegistry - > ReloadBuilder ( RootMetaSoundDocument . RootGraph . Metadata . GetClassName ( ) ) ;
2023-09-15 02:05:23 -04:00
}
2024-06-20 15:27:03 -04:00
2023-09-14 16:54:36 -04:00
// Return document using FAccessPoint to inform the TAccessPtr when the
// object is no longer valid.
return MakeAccessPtr < FDocumentAccessPtr > ( RootMetaSoundDocument . AccessPoint , RootMetaSoundDocument ) ;
}
Metasound : : Frontend : : FConstDocumentAccessPtr UMetaSoundPatch : : GetDocumentConstAccessPtr ( ) const
{
using namespace Metasound : : Frontend ;
// Return document using FAccessPoint to inform the TAccessPtr when the
// object is no longer valid.
return MakeAccessPtr < FConstDocumentAccessPtr > ( RootMetaSoundDocument . AccessPoint , RootMetaSoundDocument ) ;
}
2023-05-10 20:28:39 -04:00
const UClass & UMetaSoundPatch : : GetBaseMetaSoundUClass ( ) const
{
return * UMetaSoundPatch : : StaticClass ( ) ;
}
2024-05-08 14:53:53 -04:00
const UClass & UMetaSoundPatch : : GetBuilderUClass ( ) const
{
return * UMetaSoundPatchBuilder : : StaticClass ( ) ;
}
2023-09-22 15:01:07 -04:00
const FMetasoundFrontendDocument & UMetaSoundPatch : : GetConstDocument ( ) const
2023-05-10 20:28:39 -04:00
{
return RootMetaSoundDocument ;
}
2021-06-08 10:52:31 -04:00
# if WITH_EDITOR
2024-06-10 13:52:48 -04:00
void UMetaSoundPatch : : PreDuplicate ( FObjectDuplicationParameters & DupParams )
{
Super : : PreDuplicate ( DupParams ) ;
Metasound : : Engine : : FAssetHelper : : PreDuplicate ( this , DupParams ) ;
}
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : PostDuplicate ( EDuplicateMode : : Type InDuplicateMode )
2021-07-28 16:21:39 -04:00
{
Super : : PostDuplicate ( InDuplicateMode ) ;
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : PostDuplicate ( this , InDuplicateMode , AssetClassID ) ;
2021-07-28 16:21:39 -04:00
}
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : PostEditUndo ( )
2021-06-08 10:52:31 -04:00
{
Super : : PostEditUndo ( ) ;
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : PostEditUndo ( * this ) ;
2021-06-08 10:52:31 -04:00
}
2024-06-20 16:42:12 -04:00
EDataValidationResult UMetaSoundPatch : : IsDataValid ( FDataValidationContext & Context ) const
{
2024-08-30 12:53:13 -04:00
const EDataValidationResult Result = Metasound : : Engine : : FAssetHelper : : IsDataValid ( * this , RootMetaSoundDocument , Context ) ;
2024-06-20 16:42:12 -04:00
return CombineDataValidationResults ( Result , Super : : IsDataValid ( Context ) ) ;
}
2024-08-30 12:53:13 -04:00
# endif // WITH_EDITOR
2021-06-08 10:52:31 -04:00
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : BeginDestroy ( )
2021-07-27 15:36:03 -04:00
{
2023-12-19 15:55:04 -05:00
OnNotifyBeginDestroy ( ) ;
2021-07-27 15:36:03 -04:00
Super : : BeginDestroy ( ) ;
}
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : PreSave ( FObjectPreSaveContext InSaveContext )
2021-07-27 15:36:03 -04:00
{
Super : : PreSave ( InSaveContext ) ;
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : PreSaveAsset ( * this , InSaveContext ) ;
2021-07-27 15:36:03 -04:00
}
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : Serialize ( FArchive & InArchive )
2021-07-27 15:36:03 -04:00
{
Super : : Serialize ( InArchive ) ;
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : SerializeToArchive ( * this , InArchive ) ;
2021-07-27 15:36:03 -04:00
}
2020-07-15 12:59:38 -04:00
# if WITH_EDITORONLY_DATA
- 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 UMetaSoundPatch : : MigrateEditorGraph ( FMetaSoundFrontendDocumentBuilder & OutBuilder )
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
if ( Graph )
{
Graph - > MigrateEditorDocumentData ( OutBuilder ) ;
Graph = nullptr ;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
}
2024-05-08 14:53:53 -04:00
UEdGraph * UMetaSoundPatch : : GetGraph ( ) const
2020-07-15 12:59:38 -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 EditorGraph ;
2020-07-15 12:59:38 -04:00
}
2024-05-08 14:53:53 -04:00
UEdGraph & UMetaSoundPatch : : GetGraphChecked ( ) const
2020-07-17 16:43:42 -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
check ( EditorGraph ) ;
return * EditorGraph ;
2020-07-17 16:43:42 -04:00
}
2022-08-12 14:54:54 -04:00
FText UMetaSoundPatch : : GetDisplayName ( ) const
2020-07-15 12:59:38 -04:00
{
2022-08-12 14:54:54 -04:00
FString TypeName = UMetaSoundPatch : : StaticClass ( ) - > GetName ( ) ;
2021-06-08 10:52:31 -04:00
return FMetasoundAssetBase : : GetDisplayName ( MoveTemp ( TypeName ) ) ;
2020-07-15 12:59:38 -04:00
}
2021-06-16 11:21:13 -04:00
2022-10-13 17:38:11 -04:00
2022-08-12 14:54:54 -04:00
void UMetaSoundPatch : : SetRegistryAssetClassInfo ( const Metasound : : Frontend : : FNodeClassInfo & InNodeInfo )
2021-06-16 11:21:13 -04:00
{
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : SetMetaSoundRegistryAssetClassInfo ( * this , InNodeInfo ) ;
2021-06-16 11:21:13 -04:00
}
2020-07-15 12:59:38 -04:00
# endif // WITH_EDITORONLY_DATA
2023-12-15 13:21:12 -05:00
FTopLevelAssetPath UMetaSoundPatch : : GetAssetPathChecked ( ) const
{
2024-05-30 18:56:24 -04:00
return Metasound : : Engine : : FAssetHelper : : GetAssetPathChecked ( * this ) ;
2023-12-15 13:21:12 -05:00
}
2022-10-13 17:38:11 -04:00
void UMetaSoundPatch : : PostLoad ( )
{
Super : : PostLoad ( ) ;
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : PostLoad ( * this ) ;
2022-10-13 17:38:11 -04:00
}
# if WITH_EDITOR
void UMetaSoundPatch : : SetReferencedAssetClasses ( TSet < Metasound : : Frontend : : IMetaSoundAssetManager : : FAssetInfo > & & InAssetClasses )
2021-08-18 15:16:57 -04:00
{
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : SetReferencedAssetClasses ( * this , MoveTemp ( InAssetClasses ) ) ;
2022-10-13 17:38:11 -04:00
}
# endif
TArray < FMetasoundAssetBase * > UMetaSoundPatch : : GetReferencedAssets ( )
{
2024-05-30 18:56:24 -04:00
return Metasound : : Engine : : FAssetHelper : : GetReferencedAssets ( * this ) ;
2021-08-18 15:16:57 -04:00
}
2022-10-13 17:38:11 -04:00
const TSet < FSoftObjectPath > & UMetaSoundPatch : : GetAsyncReferencedAssetClassPaths ( ) const
2021-11-07 23:43:01 -05:00
{
return ReferenceAssetClassCache ;
}
2022-10-13 17:38:11 -04:00
void UMetaSoundPatch : : OnAsyncReferencedAssetsLoaded ( const TArray < FMetasoundAssetBase * > & InAsyncReferences )
2021-08-18 15:16:57 -04:00
{
2024-05-30 18:56:24 -04:00
Metasound : : Engine : : FAssetHelper : : OnAsyncReferencedAssetsLoaded ( * this , InAsyncReferences ) ;
2021-08-18 15:16:57 -04:00
}
2022-10-13 17:38:11 -04:00
2024-04-24 10:36:28 -04:00
bool UMetaSoundPatch : : IsActivelyBuilding ( ) const
2023-09-22 15:01:07 -04:00
{
return bIsBuilderActive ;
}
void UMetaSoundPatch : : OnBeginActiveBuilder ( )
{
2023-12-15 13:21:12 -05:00
using namespace Metasound : : Frontend ;
2023-09-22 15:01:07 -04:00
if ( bIsBuilderActive )
{
UE_LOG ( LogMetaSound , Error , TEXT ( " OnBeginActiveBuilder() call while prior builder is still active. This may indicate that multiple builders are attempting to modify the MetaSound %s concurrently. " ) , * GetOwningAssetName ( ) )
}
// If a builder is activating, make sure any in-flight registration
// tasks have completed. Async registration tasks use the FMetasoundFrontendDocument
// that lives on this object. We need to make sure that registration task
// completes so that the FMetasoundFrontendDocument does not get modified
// by a builder while it is also being read by async registration.
2023-12-15 13:21:12 -05:00
const FGraphRegistryKey GraphKey = GetGraphRegistryKey ( ) ;
if ( GraphKey . IsValid ( ) )
{
FMetasoundFrontendRegistryContainer : : Get ( ) - > WaitForAsyncGraphRegistration ( GraphKey ) ;
}
2023-09-22 15:01:07 -04:00
bIsBuilderActive = true ;
}
void UMetaSoundPatch : : OnFinishActiveBuilder ( )
{
bIsBuilderActive = false ;
}
2021-06-08 10:52:31 -04:00
# undef LOCTEXT_NAMESPACE // MetaSound
2022-09-28 01:06:15 -04:00