2020-07-23 20:32:26 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2021-03-02 21:39:09 -04:00
|
|
|
#include "EdGraph/EdGraph.h"
|
2021-01-22 03:05:22 -04:00
|
|
|
#include "MetasoundAssetBase.h"
|
2020-07-23 20:32:26 -04:00
|
|
|
#include "MetasoundFrontend.h"
|
2021-01-13 10:48:59 -04:00
|
|
|
#include "MetasoundFrontendDocument.h"
|
2021-01-22 03:05:22 -04:00
|
|
|
#include "MetasoundInstanceTransmitter.h"
|
2021-02-16 01:26:50 -04:00
|
|
|
#include "MetasoundOperatorSettings.h"
|
2021-01-22 03:05:22 -04:00
|
|
|
#include "MetasoundRouter.h"
|
2020-07-23 20:32:26 -04:00
|
|
|
#include "Sound/SoundWaveProcedural.h"
|
|
|
|
|
|
|
|
|
|
#include "MetasoundSource.generated.h"
|
|
|
|
|
|
2021-04-02 02:09:50 -04:00
|
|
|
/** Declares the output audio format of the UMetaSoundSource */
|
2020-12-14 15:48:27 -04:00
|
|
|
UENUM()
|
|
|
|
|
enum class EMetasoundSourceAudioFormat : uint8
|
|
|
|
|
{
|
|
|
|
|
Mono, //< Mono audio output.
|
|
|
|
|
Stereo //< Stereo audio output.
|
|
|
|
|
};
|
2020-07-23 20:32:26 -04:00
|
|
|
|
2021-03-02 21:39:09 -04:00
|
|
|
UCLASS()
|
|
|
|
|
class METASOUNDENGINE_API UMetasoundEditorGraphBase : public UEdGraph
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void Synchronize() { }
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-23 20:32:26 -04:00
|
|
|
/**
|
2020-07-28 16:32:56 -04:00
|
|
|
* This Metasound type can be played as an audio source.
|
2020-07-23 20:32:26 -04:00
|
|
|
*/
|
|
|
|
|
UCLASS(hidecategories = object, BlueprintType)
|
2021-04-02 02:09:50 -04:00
|
|
|
class METASOUNDENGINE_API UMetaSoundSource : public USoundWaveProcedural, public FMetasoundAssetBase
|
2020-07-23 20:32:26 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
protected:
|
2020-08-05 12:47:19 -04:00
|
|
|
UPROPERTY(EditAnywhere, Category = CustomView)
|
2021-01-13 10:48:59 -04:00
|
|
|
FMetasoundFrontendDocument RootMetasoundDocument;
|
2020-12-14 15:48:27 -04:00
|
|
|
|
2020-07-23 20:32:26 -04:00
|
|
|
#if WITH_EDITORONLY_DATA
|
2021-02-24 02:02:03 -04:00
|
|
|
UPROPERTY(EditAnywhere, Category = CustomView)
|
2021-03-02 21:39:09 -04:00
|
|
|
UMetasoundEditorGraphBase* Graph;
|
2020-07-23 20:32:26 -04:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
|
|
|
|
|
|
public:
|
2021-04-02 02:09:50 -04:00
|
|
|
UMetaSoundSource(const FObjectInitializer& ObjectInitializer);
|
2020-07-23 20:32:26 -04:00
|
|
|
|
2020-12-14 15:48:27 -04:00
|
|
|
// The output audio format of the metasound source.
|
2021-03-24 16:42:25 -04:00
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Metasound)
|
2020-12-14 15:48:27 -04:00
|
|
|
EMetasoundSourceAudioFormat OutputFormat;
|
|
|
|
|
|
2021-03-02 21:39:09 -04:00
|
|
|
#if WITH_EDITOR
|
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-04-02 02:09:50 -04:00
|
|
|
return GET_MEMBER_NAME_CHECKED(UMetaSoundSource, RootMetasoundDocument);
|
2020-07-30 16:57:04 -04:00
|
|
|
}
|
2020-07-23 20:32:26 -04:00
|
|
|
|
2021-03-02 21:39:09 -04:00
|
|
|
virtual void PostEditUndo() override;
|
|
|
|
|
|
2020-07-23 20:32:26 -04:00
|
|
|
// Returns the graph associated with this Metasound. Graph is required to be referenced on
|
|
|
|
|
// Metasound UObject for editor serialization purposes.
|
2021-04-02 02:09:50 -04:00
|
|
|
// @return Editor graph associated with UMetaSoundSource.
|
2020-07-23 20:32:26 -04:00
|
|
|
virtual UEdGraph* GetGraph() override
|
|
|
|
|
{
|
|
|
|
|
return Graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual const UEdGraph* GetGraph() const override
|
|
|
|
|
{
|
|
|
|
|
return Graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual UEdGraph& GetGraphChecked() override
|
|
|
|
|
{
|
|
|
|
|
check(Graph);
|
|
|
|
|
return *Graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual const UEdGraph& GetGraphChecked() const override
|
|
|
|
|
{
|
|
|
|
|
check(Graph);
|
|
|
|
|
return *Graph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sets the graph associated with this Metasound. Graph is required to be referenced on
|
|
|
|
|
// Metasound UObject for editor serialization purposes.
|
2021-04-02 02:09:50 -04:00
|
|
|
// @param Editor graph associated with UMetaSoundSource.
|
2020-07-23 20:32:26 -04:00
|
|
|
virtual void SetGraph(UEdGraph* InGraph) override
|
|
|
|
|
{
|
2021-03-02 21:39:09 -04:00
|
|
|
Graph = CastChecked<UMetasoundEditorGraphBase>(InGraph);
|
2020-07-23 20:32:26 -04:00
|
|
|
}
|
|
|
|
|
|
2021-04-02 02:09:50 -04:00
|
|
|
virtual bool GetRedrawThumbnail() const override
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetRedrawThumbnail(bool bInRedraw) override
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool CanVisualizeAsset() const override
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 15:48:27 -04:00
|
|
|
void PostEditChangeProperty(FPropertyChangedEvent& InEvent);
|
|
|
|
|
|
|
|
|
|
#endif // WITH_EDITOR
|
2020-07-23 20:32:26 -04:00
|
|
|
|
2021-02-01 15:59:27 -04:00
|
|
|
UObject* GetOwningAsset() override
|
2020-07-23 20:32:26 -04:00
|
|
|
{
|
2021-02-01 15:59:27 -04:00
|
|
|
return this;
|
2020-07-23 20:32:26 -04:00
|
|
|
}
|
|
|
|
|
|
2021-02-01 15:59:27 -04:00
|
|
|
const UObject* GetOwningAsset() const override
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2020-07-23 20:32:26 -04:00
|
|
|
|
|
|
|
|
bool IsPlayable() const override;
|
|
|
|
|
bool SupportsSubtitles() const override;
|
|
|
|
|
float GetDuration() override;
|
|
|
|
|
ISoundGeneratorPtr CreateSoundGenerator(const FSoundGeneratorInitParams& InParams) override;
|
2021-01-22 03:05:22 -04:00
|
|
|
TUniquePtr<IAudioInstanceTransmitter> CreateInstanceTransmitter(const FAudioInstanceTransmitterInitParams& InParams) const override;
|
2020-07-23 20:32:26 -04:00
|
|
|
|
|
|
|
|
// Get the most up to date archetype for metasound sources.
|
2021-01-22 03:05:22 -04:00
|
|
|
const TArray<FMetasoundFrontendArchetype>& GetPreferredMetasoundArchetypes() const override;
|
2020-12-14 15:48:27 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
Metasound::Frontend::TAccessPtr<FMetasoundFrontendDocument> GetDocument() override
|
2020-12-14 15:48:27 -04:00
|
|
|
{
|
|
|
|
|
// Return document using FAccessPoint to inform the TAccessPtr when the
|
|
|
|
|
// object is no longer valid.
|
2021-01-13 10:48:59 -04:00
|
|
|
return Metasound::Frontend::MakeAccessPtr<FMetasoundFrontendDocument>(RootMetasoundDocument.AccessPoint, RootMetasoundDocument);
|
2020-12-14 15:48:27 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
Metasound::Frontend::TAccessPtr<const FMetasoundFrontendDocument> GetDocument() const override
|
2020-12-14 15:48:27 -04:00
|
|
|
{
|
|
|
|
|
// Return document using FAccessPoint to inform the TAccessPtr when the
|
|
|
|
|
// object is no longer valid.
|
2021-01-13 10:48:59 -04:00
|
|
|
return Metasound::Frontend::MakeAccessPtr<const FMetasoundFrontendDocument>(RootMetasoundDocument.AccessPoint, RootMetasoundDocument);
|
2020-12-14 15:48:27 -04:00
|
|
|
}
|
2020-07-23 20:32:26 -04:00
|
|
|
|
|
|
|
|
private:
|
2021-01-22 03:05:22 -04:00
|
|
|
struct FSendInfoAndVertexName
|
|
|
|
|
{
|
|
|
|
|
Metasound::FMetasoundInstanceTransmitter::FSendInfo SendInfo;
|
|
|
|
|
FString VertexName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool GetReceiveNodeMetadataForDataType(const FName& InTypeName, FMetasoundFrontendClassMetadata& OutMetadata) const;
|
|
|
|
|
Metasound::Frontend::FNodeHandle AddInputPinForSendAddress(const Metasound::FMetasoundInstanceTransmitter::FSendInfo& InSendInfo, Metasound::Frontend::FGraphHandle InGraph) const;
|
|
|
|
|
bool CopyDocumentAndInjectReceiveNodes(uint64 InInstanceID, const FMetasoundFrontendDocument& InSourceDoc, FMetasoundFrontendDocument& OutDestDoc) const;
|
|
|
|
|
TArray<FString> GetTransmittableInputVertexNames() const;
|
2021-02-16 01:26:50 -04:00
|
|
|
Metasound::FOperatorSettings GetOperatorSettings(Metasound::FSampleRate InSampleRate) const;
|
2021-02-19 14:00:43 -04:00
|
|
|
Metasound::FSendAddress CreateSendAddress(uint64 InInstanceID, const FString& InVertexName, const FName& InDataTypeName) const;
|
2021-01-22 03:05:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TArray<FSendInfoAndVertexName> GetSendInfos(uint64 InInstanceID) const;
|
|
|
|
|
|
2020-07-23 20:32:26 -04:00
|
|
|
|
|
|
|
|
static const FString& GetOnPlayInputName();
|
|
|
|
|
static const FString& GetAudioOutputName();
|
|
|
|
|
static const FString& GetIsFinishedOutputName();
|
2020-11-17 17:52:08 -04:00
|
|
|
static const FString& GetAudioDeviceHandleVariableName();
|
2021-03-15 14:00:26 -04:00
|
|
|
static const FString& GetSoundUniqueIdName();
|
2021-04-03 18:41:39 -04:00
|
|
|
static const FString& GetIsPreviewSoundName();
|
2021-01-13 10:48:59 -04:00
|
|
|
static const FMetasoundFrontendArchetype& GetBaseArchetype();
|
|
|
|
|
static const FMetasoundFrontendArchetype& GetMonoSourceArchetype();
|
|
|
|
|
static const FMetasoundFrontendArchetype& GetStereoSourceArchetype();
|
2020-11-17 17:52:08 -04:00
|
|
|
};
|