// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "EdGraph/EdGraph.h" #include "MetasoundAssetBase.h" #include "MetasoundFrontend.h" #include "MetasoundFrontendDocument.h" #include "MetasoundOperatorSettings.h" #include "MetasoundRouter.h" #include "MetasoundSource.h" #include "Metasound.generated.h" /** * This asset type is used for Metasound assets that can only be used as nodes in other Metasound graphs. * Because of this, they contain no required inputs or outputs. */ UCLASS(hidecategories = object, BlueprintType) class METASOUNDENGINE_API UMetaSound : public UObject, public FMetasoundAssetBase { GENERATED_BODY() protected: UPROPERTY(EditAnywhere, Category = CustomView) FMetasoundFrontendDocument RootMetaSoundDocument; #if WITH_EDITORONLY_DATA UPROPERTY(AssetRegistrySearchable) FMetasoundFrontendClassAssetTags AssetTags; UPROPERTY() UMetasoundEditorGraphBase* Graph; #endif // WITH_EDITORONLY_DATA public: UMetaSound(const FObjectInitializer& ObjectInitializer); #if WITH_EDITORONLY_DATA // Returns document name (for editor purposes, and avoids making document public for edit // while allowing editor to reference directly) static FName GetDocumentPropertyName() { return GET_MEMBER_NAME_CHECKED(UMetaSound, RootMetaSoundDocument); } // Name to display in editors virtual FText GetDisplayName() const override; // Returns the graph associated with this Metasound. Graph is required to be referenced on // Metasound UObject for editor serialization purposes. // @return Editor graph associated with UMetaSoundSource. virtual UEdGraph* GetGraph() override; virtual const UEdGraph* GetGraph() const override; virtual UEdGraph& GetGraphChecked() override; virtual const UEdGraph& GetGraphChecked() const override; // Sets the graph associated with this Metasound. Graph is required to be referenced on // Metasound UObject for editor serialization purposes. // @param Editor graph associated with UMetaSoundSource. virtual void SetGraph(UEdGraph* InGraph) override { Graph = CastChecked(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(); UObject* GetOwningAsset() override { return this; } const UObject* GetOwningAsset() const override { return this; } TUniquePtr CreateInstanceTransmitter(const FAudioInstanceTransmitterInitParams& InParams) const; // Get the most up to date archetype for metasound sources. const TArray& GetPreferredArchetypes() const override; protected: 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(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(RootMetaSoundDocument.AccessPoint, RootMetaSoundDocument); } bool CopyDocumentAndInjectReceiveNodes(uint64 InInstanceID, const FMetasoundFrontendDocument& InSourceDoc, FMetasoundFrontendDocument& OutDestDoc) const; private: TArray 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(); };