You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Archetype to Interface rename & support for multiple interface versions stored on MetaSoundBase - Added ability to register interfaces - Added spatialization/attenuation interfaces - Added UX to add/remove Interfaces - Fix ensure when deleting UMetaSound asset #rb phil.popp #jira UE-135000 #jira UE-120656 #rnx #preflight 619bd9e33a7219926732337c #ROBOMERGE-AUTHOR: rob.gay #ROBOMERGE-SOURCE: CL 18262648 in //UE5/Release-5.0/... via CL 18262703 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) [CL 18262725 by rob gay in ue5-release-engine-test branch]
86 lines
3.6 KiB
C++
86 lines
3.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
#include "MetasoundInterface.h"
|
|
|
|
#include "IAudioParameterTransmitter.h"
|
|
|
|
|
|
namespace Metasound
|
|
{
|
|
namespace Engine
|
|
{
|
|
void RegisterExternalInterfaces()
|
|
{
|
|
using namespace Audio;
|
|
|
|
auto RegisterExternalInterface = [](FGeneratorInterfacePtr Interface)
|
|
{
|
|
auto ResolveMemberDataType = [](FName DataType, EAudioParameterType ParamType)
|
|
{
|
|
if (!DataType.IsNone())
|
|
{
|
|
const bool bIsRegisteredType = Frontend::IDataTypeRegistry::Get().IsRegistered(DataType);
|
|
if (ensureAlwaysMsgf(bIsRegisteredType, TEXT("Attempting to register Interface member with unregistered DataType '%s'."), *DataType.ToString()))
|
|
{
|
|
return DataType;
|
|
}
|
|
}
|
|
|
|
return Frontend::ConvertParameterToDataType(ParamType);
|
|
};
|
|
|
|
FMetasoundFrontendInterface FrontendInterface;
|
|
FrontendInterface.Version = { Interface->Name, FMetasoundFrontendVersionNumber { Interface->Version.Major, Interface->Version.Minor } };
|
|
|
|
Algo::Transform(Interface->Inputs, FrontendInterface.Inputs, [&](const FGeneratorInterface::FInput& Input)
|
|
{
|
|
FMetasoundFrontendClassInput ClassInput;
|
|
ClassInput.Name = IGeneratorInterfaceRegistry::GetMemberFullName(Interface->Name, Input.InitValue.ParamName);
|
|
ClassInput.DefaultLiteral = FMetasoundFrontendLiteral(Input.InitValue);
|
|
ClassInput.TypeName = ResolveMemberDataType(Input.DataType, Input.InitValue.ParamType);
|
|
ClassInput.Metadata.DisplayName = Input.DisplayName;
|
|
ClassInput.Metadata.Description = Input.Description;
|
|
ClassInput.VertexID = FGuid::NewGuid();
|
|
|
|
return ClassInput;
|
|
});
|
|
|
|
Algo::Transform(Interface->Outputs, FrontendInterface.Outputs, [&](const FGeneratorInterface::FOutput& Output)
|
|
{
|
|
FMetasoundFrontendClassOutput ClassOutput;
|
|
ClassOutput.Name = IGeneratorInterfaceRegistry::GetMemberFullName(Interface->Name, Output.ParamName);
|
|
ClassOutput.TypeName = ResolveMemberDataType(Output.DataType, Output.ParamType);
|
|
ClassOutput.Metadata.DisplayName = Output.DisplayName;
|
|
ClassOutput.Metadata.Description = Output.Description;
|
|
ClassOutput.VertexID = FGuid::NewGuid();
|
|
|
|
return ClassOutput;
|
|
});
|
|
|
|
Algo::Transform(Interface->Environment, FrontendInterface.Environment, [&](const FGeneratorInterface::FEnvironmentVariable& Environment)
|
|
{
|
|
FMetasoundFrontendClassEnvironmentVariable EnvironmentVariable;
|
|
EnvironmentVariable.Name = IGeneratorInterfaceRegistry::GetMemberFullName(Interface->Name, Environment.ParamName);
|
|
EnvironmentVariable.TypeName = ResolveMemberDataType(Environment.DataType, Environment.ParamType);
|
|
EnvironmentVariable.Metadata.DisplayName = Environment.DisplayName;
|
|
EnvironmentVariable.Metadata.Description = Environment.Description;
|
|
|
|
return EnvironmentVariable;
|
|
});
|
|
|
|
// For now, only support interfaces for UMetaSoundSource type
|
|
if (ensureAlways(UMetaSoundSource::StaticClass()->IsChildOf(Interface->Type)))
|
|
{
|
|
// For now, all external interfaces use the ParameterTransmitter and cannot be applied by default to new
|
|
// MetaSound objects. Could pipe either of these through in the future if required/desired.
|
|
constexpr bool bIsDefault = false;
|
|
RegisterInterface<UMetaSoundSource>(FrontendInterface, nullptr, bIsDefault, Audio::IParameterTransmitter::RouterName);
|
|
UE_LOG(LogMetaSound, Verbose, TEXT("Interface '%s' registered as MetaSoundSource assets."), *Interface->Name.ToString());
|
|
}
|
|
};
|
|
|
|
IGeneratorInterfaceRegistry::Get().IterateInterfaces(RegisterExternalInterface);
|
|
IGeneratorInterfaceRegistry::Get().OnRegistration(MoveTemp(RegisterExternalInterface));
|
|
}
|
|
} // namespace Engine
|
|
} // namespace Metasound
|