2022-12-13 18:22:31 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "MetasoundFrontendController.h"
|
|
|
|
|
#include "MetasoundFrontendDocument.h"
|
2023-03-07 19:10:58 -05:00
|
|
|
#include "MetasoundGenerator.h"
|
2022-12-13 18:22:31 -05:00
|
|
|
#include "MetasoundNodeInterface.h"
|
|
|
|
|
|
|
|
|
|
namespace Metasound::Test
|
|
|
|
|
{
|
|
|
|
|
/** Helper to make testing nodes simpler. */
|
|
|
|
|
class METASOUNDENGINETEST_API FNodeTestGraphBuilder
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FNodeTestGraphBuilder();
|
|
|
|
|
|
|
|
|
|
/** Add a node to the graph */
|
2023-04-10 09:26:19 -04:00
|
|
|
Frontend::FNodeHandle AddNode(const FNodeClassName& ClassName, int32 MajorVersion) const;
|
2022-12-13 18:22:31 -05:00
|
|
|
|
|
|
|
|
/** Add an input node to the graph */
|
2023-05-02 18:18:27 -04:00
|
|
|
Frontend::FNodeHandle AddInput(
|
|
|
|
|
const FName& InputName,
|
|
|
|
|
const FName& TypeName,
|
|
|
|
|
EMetasoundFrontendVertexAccessType AccessType = EMetasoundFrontendVertexAccessType::Reference) const;
|
|
|
|
|
|
|
|
|
|
/** Add a constructor input to the graph */
|
|
|
|
|
template<typename DataType>
|
|
|
|
|
Frontend::FNodeHandle AddConstructorInput(const FName& InputName, const DataType& Value) const
|
|
|
|
|
{
|
|
|
|
|
check(RootGraph->IsValid());
|
|
|
|
|
|
|
|
|
|
FMetasoundFrontendClassInput Input;
|
|
|
|
|
Input.Name = InputName;
|
|
|
|
|
Input.TypeName = GetMetasoundDataTypeName<DataType>();
|
|
|
|
|
Input.VertexID = FGuid::NewGuid();
|
|
|
|
|
Input.AccessType = EMetasoundFrontendVertexAccessType::Value;
|
|
|
|
|
Input.DefaultLiteral.Set(Value);
|
|
|
|
|
return RootGraph->AddInputVertex(Input);
|
|
|
|
|
}
|
2022-12-13 18:22:31 -05:00
|
|
|
|
2023-02-17 12:44:15 -05:00
|
|
|
/** Add an output node to the graph */
|
2022-12-13 18:22:31 -05:00
|
|
|
Frontend::FNodeHandle AddOutput(const FName& OutputName, const FName& TypeName);
|
|
|
|
|
|
2023-04-10 09:26:19 -04:00
|
|
|
TUniquePtr<FMetasoundGenerator> BuildGenerator(FSampleRate SampleRate = 48000, int32 SamplesPerBlock = 256) const;
|
2023-03-07 19:10:58 -05:00
|
|
|
|
2022-12-13 18:22:31 -05:00
|
|
|
/** Helper that will add a single node, wire up the node's inputs and outputs, and hand back the graph's operator */
|
2023-04-10 09:26:19 -04:00
|
|
|
static TUniquePtr<FMetasoundGenerator> MakeSingleNodeGraph(
|
2023-02-17 12:44:15 -05:00
|
|
|
const FNodeClassName& ClassName,
|
|
|
|
|
int32 MajorVersion,
|
|
|
|
|
FSampleRate SampleRate = 48000,
|
|
|
|
|
int32 SamplesPerBlock = 256);
|
2022-12-13 18:22:31 -05:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FMetasoundFrontendDocument Document;
|
|
|
|
|
Frontend::FDocumentHandle DocumentHandle = Frontend::IDocumentController::GetInvalidHandle();
|
|
|
|
|
Frontend::FGraphHandle RootGraph = Frontend::IGraphController::GetInvalidHandle();
|
2023-03-09 17:07:57 -05:00
|
|
|
TArray<FVertexName> AudioOutputNames;
|
2022-12-13 18:22:31 -05:00
|
|
|
};
|
|
|
|
|
}
|