Files
UnrealEngine/Engine/Plugins/Runtime/Harmonix/Source/HarmonixMetasoundTests/Private/Nodes/MidiClockStateNode.cpp
2025-05-18 13:04:45 +08:00

45 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "NodeTestGraphBuilder.h"
#include "HarmonixDsp/AudioBuffer.h"
#include "HarmonixMetasound/Common.h"
#include "Misc/AutomationTest.h"
#if WITH_DEV_AUTOMATION_TESTS
namespace HarmonixMetasoundTests::MidiClockStateNode
{
using GraphBuilder = Metasound::Test::FNodeTestGraphBuilder;
using namespace Metasound;
using namespace Metasound::Frontend;
using namespace HarmonixMetasound;
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
FMidiClockStateCreateNodeTest,
"Harmonix.Metasound.Nodes.MidiClockStateNode.CreateNode",
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
bool FMidiClockStateCreateNodeTest::RunTest(const FString&)
{
// Build the graph.
constexpr int32 NumSamplesPerBlock = 256;
const TUniquePtr<FMetasoundGenerator> Generator = GraphBuilder::MakeSingleNodeGraph(
{ HarmonixMetasound::HarmonixNodeNamespace, "MidiClockState", "" },
0,
48000,
NumSamplesPerBlock);
UTEST_TRUE("Graph successfully built", Generator.IsValid());
// execute a block
{
TAudioBuffer<float> Buffer{ Generator->GetNumChannels(), NumSamplesPerBlock, EAudioBufferCleanupMode::Delete};
Generator->OnGenerateAudio(Buffer.GetRawChannelData(0), Buffer.GetNumTotalValidSamples());
}
// No output to validate, finish test
return true;
}
}
#endif