You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[FYI] rob.gay Original CL Desc ----------------------------------------------------------------- MetaSounds Interfaces Checkpoint 2: - Version up source archetypes to become two interfaces: channel interfaces (mono/stereo) & base source namespace - Clean-up Interface panel to support namespacing better - Fix bugs with assuming interfaces are always and the only base namespace members - Allow namespacing for any arbitrary interface member - Add lock icon to clarify what interface members cannot be modified individually (i.e. cannot add, remove, or rename them as they are interface members) - Organize members alphabetically #jira UE-135000 #rnx #rb phil.popp #preflight 61a7d1079c77d610079303ec #p4v-cherrypick 18344347 #ROBOMERGE-AUTHOR: aurel.cordonnier #ROBOMERGE-SOURCE: CL 18369256 via CL 18369273 via CL 18369290 via CL 18434224 via CL 18435611 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271) [CL 18436532 by aurel cordonnier in ue5-release-engine-test branch]
88 lines
3.7 KiB
C++
88 lines
3.7 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
|
|
const UClass* SourceClass = UMetaSoundSource::StaticClass();
|
|
check(SourceClass);
|
|
if (ensureAlways(SourceClass->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 for asset type '%s'."), *Interface->Name.ToString(), *SourceClass->GetName());
|
|
}
|
|
};
|
|
|
|
IGeneratorInterfaceRegistry::Get().IterateInterfaces(RegisterExternalInterface);
|
|
IGeneratorInterfaceRegistry::Get().OnRegistration(MoveTemp(RegisterExternalInterface));
|
|
}
|
|
} // namespace Engine
|
|
} // namespace Metasound
|