2020-07-15 00:16:40 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2021-06-08 10:52:31 -04:00
|
|
|
#include "EdGraph/EdGraph.h"
|
2021-05-10 19:52:56 -04:00
|
|
|
#include "MetasoundAssetBase.h"
|
2020-07-15 00:16:40 -04:00
|
|
|
#include "MetasoundFrontend.h"
|
2021-01-13 10:48:59 -04:00
|
|
|
#include "MetasoundFrontendDocument.h"
|
2021-06-08 10:52:31 -04:00
|
|
|
#include "MetasoundOperatorSettings.h"
|
|
|
|
|
#include "MetasoundRouter.h"
|
|
|
|
|
#include "MetasoundSource.h"
|
2020-07-15 12:59:38 -04:00
|
|
|
|
2020-07-15 00:16:40 -04:00
|
|
|
#include "Metasound.generated.h"
|
|
|
|
|
|
2020-07-22 14:52:03 -04:00
|
|
|
|
2020-07-15 00:16:40 -04:00
|
|
|
/**
|
|
|
|
|
* This asset type is used for Metasound assets that can only be used as nodes in other Metasound graphs.
|
2021-06-08 10:52:31 -04:00
|
|
|
* Because of this, they contain no required inputs or outputs.
|
2020-07-15 00:16:40 -04:00
|
|
|
*/
|
2020-07-15 12:59:38 -04:00
|
|
|
UCLASS(hidecategories = object, BlueprintType)
|
2021-04-02 02:09:50 -04:00
|
|
|
class METASOUNDENGINE_API UMetaSound : public UObject, public FMetasoundAssetBase
|
2020-07-15 00:16:40 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
protected:
|
2020-08-05 12:47:19 -04:00
|
|
|
UPROPERTY(EditAnywhere, Category = CustomView)
|
2021-06-08 10:52:31 -04:00
|
|
|
FMetasoundFrontendDocument RootMetaSoundDocument;
|
2020-07-15 00:16:40 -04:00
|
|
|
|
2020-07-15 12:59:38 -04:00
|
|
|
#if WITH_EDITORONLY_DATA
|
2021-06-08 10:52:31 -04:00
|
|
|
UPROPERTY(AssetRegistrySearchable)
|
|
|
|
|
FMetasoundFrontendClassAssetTags AssetTags;
|
|
|
|
|
|
2020-07-15 12:59:38 -04:00
|
|
|
UPROPERTY()
|
2021-06-08 10:52:31 -04:00
|
|
|
UMetasoundEditorGraphBase* Graph;
|
2020-07-15 12:59:38 -04:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
|
|
2020-07-15 00:16:40 -04:00
|
|
|
public:
|
2021-04-02 02:09:50 -04:00
|
|
|
UMetaSound(const FObjectInitializer& ObjectInitializer);
|
2020-07-15 00:16:40 -04:00
|
|
|
|
2020-07-15 12:59:38 -04:00
|
|
|
#if WITH_EDITORONLY_DATA
|
2020-07-30 16:57:04 -04:00
|
|
|
// Returns document name (for editor purposes, and avoids making document public for edit
|
|
|
|
|
// while allowing editor to reference directly)
|
|
|
|
|
static FName GetDocumentPropertyName()
|
|
|
|
|
{
|
2021-06-08 10:52:31 -04:00
|
|
|
return GET_MEMBER_NAME_CHECKED(UMetaSound, RootMetaSoundDocument);
|
2020-07-30 16:57:04 -04:00
|
|
|
}
|
2020-07-15 12:59:38 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
// Name to display in editors
|
|
|
|
|
virtual FText GetDisplayName() const override;
|
|
|
|
|
|
2020-07-15 12:59:38 -04:00
|
|
|
// Returns the graph associated with this Metasound. Graph is required to be referenced on
|
|
|
|
|
// Metasound UObject for editor serialization purposes.
|
2021-06-08 10:52:31 -04:00
|
|
|
// @return Editor graph associated with UMetaSoundSource.
|
2020-07-23 20:32:26 -04:00
|
|
|
virtual UEdGraph* GetGraph() override;
|
|
|
|
|
virtual const UEdGraph* GetGraph() const override;
|
|
|
|
|
virtual UEdGraph& GetGraphChecked() override;
|
|
|
|
|
virtual const UEdGraph& GetGraphChecked() const override;
|
2020-07-15 12:59:38 -04:00
|
|
|
|
|
|
|
|
// Sets the graph associated with this Metasound. Graph is required to be referenced on
|
|
|
|
|
// Metasound UObject for editor serialization purposes.
|
2021-06-08 10:52:31 -04:00
|
|
|
// @param Editor graph associated with UMetaSoundSource.
|
|
|
|
|
virtual void SetGraph(UEdGraph* InGraph) override
|
|
|
|
|
{
|
|
|
|
|
Graph = CastChecked<UMetasoundEditorGraphBase>(InGraph);
|
|
|
|
|
}
|
|
|
|
|
#endif // #if WITH_EDITORONLY_DATA
|
|
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
|
|
|
|
|
virtual void PostEditUndo() override;
|
|
|
|
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& InEvent) override;
|
|
|
|
|
#endif // WITH_EDITOR
|
|
|
|
|
|
|
|
|
|
virtual const FMetasoundFrontendArchetype& GetArchetype() const override;
|
|
|
|
|
|
|
|
|
|
// If set to be a preset, converts to a full-access MetaSound,
|
|
|
|
|
// removing edit restrictions and excluding it from automatic
|
|
|
|
|
// interface versioning.
|
|
|
|
|
UFUNCTION(Category = Metasound, meta = (CallInEditor = "true"))
|
|
|
|
|
void ConvertFromPreset();
|
2020-07-15 12:59:38 -04:00
|
|
|
|
2021-02-01 15:59:27 -04:00
|
|
|
UObject* GetOwningAsset() override
|
2020-07-23 16:39:56 -04:00
|
|
|
{
|
2021-02-01 15:59:27 -04:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UObject* GetOwningAsset() const override
|
|
|
|
|
{
|
|
|
|
|
return this;
|
2020-07-17 16:43:42 -04:00
|
|
|
}
|
2020-07-15 00:16:40 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
TUniquePtr<IAudioInstanceTransmitter> CreateInstanceTransmitter(const FAudioInstanceTransmitterInitParams& InParams) const;
|
2020-12-14 15:48:27 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
// Get the most up to date archetype for metasound sources.
|
|
|
|
|
const TArray<FMetasoundFrontendArchetype>& GetPreferredArchetypes() const override;
|
2020-12-14 15:48:27 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
protected:
|
2020-12-14 15:48:27 -04:00
|
|
|
|
2021-06-08 10:52:31 -04:00
|
|
|
Metasound::Frontend::FDocumentAccessPtr GetDocument() override
|
|
|
|
|
{
|
|
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
// Return document using FAccessPoint to inform the TAccessPtr when the
|
|
|
|
|
// object is no longer valid.
|
|
|
|
|
return MakeAccessPtr<FDocumentAccessPtr>(RootMetaSoundDocument.AccessPoint, RootMetaSoundDocument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Metasound::Frontend::FConstDocumentAccessPtr GetDocument() const override
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CopyDocumentAndInjectReceiveNodes(uint64 InInstanceID, const FMetasoundFrontendDocument& InSourceDoc, FMetasoundFrontendDocument& OutDestDoc) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TArray<FString> GetTransmittableInputVertexNames() const;
|
|
|
|
|
Metasound::FOperatorSettings GetOperatorSettings(Metasound::FSampleRate InSampleRate) const;
|
|
|
|
|
Metasound::FSendAddress CreateSendAddress(uint64 InInstanceID, const FString& InVertexName, const FName& InDataTypeName) const;
|
|
|
|
|
static const FString& GetAudioDeviceHandleVariableName();
|
|
|
|
|
static const FMetasoundFrontendArchetype& GetBaseArchetype();
|
2020-12-14 15:48:27 -04:00
|
|
|
};
|