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"
|
|
|
|
|
#include "MetasoundAudioFormats.h"
|
2023-05-10 20:28:39 -04:00
|
|
|
#include "MetasoundBuilderSubsystem.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"
|
|
|
|
|
#include "MetasoundFrontendQuery.h"
|
|
|
|
|
#include "MetasoundFrontendQuerySteps.h"
|
2021-08-18 15:16:57 -04:00
|
|
|
#include "MetasoundFrontendRegistries.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)
|
|
|
|
|
|
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-05-10 20:28:39 -04:00
|
|
|
const UClass& UMetaSoundPatch::GetBaseMetaSoundUClass() const
|
|
|
|
|
{
|
|
|
|
|
return *UMetaSoundPatch::StaticClass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FMetasoundFrontendDocument& UMetaSoundPatch::GetDocument() const
|
|
|
|
|
{
|
|
|
|
|
return RootMetaSoundDocument;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
#if WITH_EDITOR
|
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);
|
2021-11-22 15:55:50 -05:00
|
|
|
|
|
|
|
|
// Guid is reset as asset may share implementation from
|
|
|
|
|
// asset duplicated from but should not be registered as such.
|
|
|
|
|
if (InDuplicateMode == EDuplicateMode::Normal)
|
|
|
|
|
{
|
2022-03-10 21:19:13 -05:00
|
|
|
AssetClassID = FGuid::NewGuid();
|
|
|
|
|
Metasound::Frontend::FRenameRootGraphClass::Generate(GetDocumentHandle(), AssetClassID);
|
2021-11-22 15:55:50 -05:00
|
|
|
}
|
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();
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::PostEditUndo(*this);
|
2021-06-08 10:52:31 -04:00
|
|
|
}
|
|
|
|
|
#endif // WITHEDITOR
|
|
|
|
|
|
2022-08-12 14:54:54 -04:00
|
|
|
void UMetaSoundPatch::BeginDestroy()
|
2021-07-27 15:36:03 -04:00
|
|
|
{
|
|
|
|
|
UnregisterGraphWithFrontend();
|
|
|
|
|
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);
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::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);
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::SerializeToArchive(*this, InArchive);
|
2021-07-27 15:36:03 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-15 12:59:38 -04:00
|
|
|
#if WITH_EDITORONLY_DATA
|
2022-08-12 14:54:54 -04:00
|
|
|
UEdGraph* UMetaSoundPatch::GetGraph()
|
2020-07-15 12:59:38 -04:00
|
|
|
{
|
|
|
|
|
return Graph;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 14:54:54 -04:00
|
|
|
const UEdGraph* UMetaSoundPatch::GetGraph() const
|
2020-07-17 16:43:42 -04:00
|
|
|
{
|
|
|
|
|
return Graph;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 14:54:54 -04:00
|
|
|
UEdGraph& UMetaSoundPatch::GetGraphChecked()
|
2020-07-15 12:59:38 -04:00
|
|
|
{
|
|
|
|
|
check(Graph);
|
|
|
|
|
return *Graph;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 14:54:54 -04:00
|
|
|
const UEdGraph& UMetaSoundPatch::GetGraphChecked() const
|
2020-07-17 16:43:42 -04:00
|
|
|
{
|
|
|
|
|
check(Graph);
|
|
|
|
|
return *Graph;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::SetMetaSoundRegistryAssetClassInfo(*this, InNodeInfo);
|
2021-06-16 11:21:13 -04:00
|
|
|
}
|
2020-07-15 12:59:38 -04:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
|
|
2022-10-13 17:38:11 -04:00
|
|
|
void UMetaSoundPatch::PostLoad()
|
|
|
|
|
{
|
|
|
|
|
Super::PostLoad();
|
|
|
|
|
Metasound::FMetaSoundEngineAssetHelper::PostLoad(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 14:54:54 -04:00
|
|
|
Metasound::Frontend::FNodeClassInfo UMetaSoundPatch::GetAssetClassInfo() const
|
2020-12-14 15:48:27 -04:00
|
|
|
{
|
2022-09-12 19:52:49 -04:00
|
|
|
return { GetDocumentChecked().RootGraph, FSoftObjectPath(this) };
|
2020-12-14 15:48:27 -04:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::SetReferencedAssetClasses(*this, MoveTemp(InAssetClasses));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
TArray<FMetasoundAssetBase*> UMetaSoundPatch::GetReferencedAssets()
|
|
|
|
|
{
|
|
|
|
|
return Metasound::FMetaSoundEngineAssetHelper::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
|
|
|
{
|
2022-10-13 17:38:11 -04:00
|
|
|
Metasound::FMetaSoundEngineAssetHelper::OnAsyncReferencedAssetsLoaded(*this, InAsyncReferences);
|
2021-08-18 15:16:57 -04:00
|
|
|
}
|
2022-10-13 17:38:11 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE // MetaSound
|
2022-09-28 01:06:15 -04:00
|
|
|
|