You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Move bIsDefault/bCanEdit(renamed bIsModifiable) from InterfaceRegistryEntry to Interface data definition - Add checks in builder to disallow mutation of interfaces that shouldn't be via editor or document builder (ex. SourceInterface which is default and then never changed) - Optimize SearchEngine query for finding default interfaces - Tweak MetaSoundUObjectRegistry to support non MetasoundAssetBase classes and add UMetaSoundBuilderDocument. Update iterator w/optional param to only return asset types (true by default for back compat) - Move FName class name comparitors to use new TopLevelAssetPath #rb phil.popp #jira UE-181360 #rnx #p4v-preflight-copy 24658328 #preflight 642b10834d26bcd1eb0e566c [CL 24920763 by rob gay in ue5-main branch]
138 lines
4.8 KiB
C++
138 lines
4.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Interfaces/MetasoundInterface.h"
|
|
|
|
#include "Algo/Transform.h"
|
|
#include "AudioParameterControllerInterface.h"
|
|
#include "IAudioParameterInterfaceRegistry.h"
|
|
#include "IAudioParameterTransmitter.h"
|
|
#include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
|
|
#include "Interfaces/MetasoundFrontendSourceInterface.h"
|
|
#include "Interfaces/MetasoundInputFormatInterfaces.h"
|
|
#include "Interfaces/MetasoundOutputFormatInterfaces.h"
|
|
#include "Metasound.h"
|
|
#include "MetasoundFrontendDataTypeRegistry.h"
|
|
#include "MetasoundFrontendDocument.h"
|
|
#include "MetasoundFrontendTransform.h"
|
|
#include "MetasoundLog.h"
|
|
#include "MetasoundParameterTransmitter.h"
|
|
#include "MetasoundSource.h"
|
|
#include "MetasoundUObjectRegistry.h"
|
|
#include "Templates/SharedPointer.h"
|
|
#include "Templates/UniquePtr.h"
|
|
#include "UObject/Class.h"
|
|
#include "UObject/NoExportTypes.h"
|
|
|
|
|
|
namespace Metasound::Engine
|
|
{
|
|
FInterfaceRegistryEntry::FInterfaceRegistryEntry(FMetasoundFrontendInterface&& InInterface, FName InRouterName)
|
|
: Interface(MoveTemp(InInterface))
|
|
, RouterName(InRouterName)
|
|
{
|
|
}
|
|
|
|
FInterfaceRegistryEntry::FInterfaceRegistryEntry(const FMetasoundFrontendInterface& InInterface, FName InRouterName)
|
|
: Interface(InInterface)
|
|
, RouterName(InRouterName)
|
|
{
|
|
}
|
|
|
|
FInterfaceRegistryEntry::FInterfaceRegistryEntry(const FMetasoundFrontendInterface& InInterface, TUniquePtr<Frontend::IDocumentTransform>&& InUpdateTransform, FName InRouterName)
|
|
: Interface(InInterface)
|
|
, UpdateTransform(MoveTemp(InUpdateTransform))
|
|
, RouterName(InRouterName)
|
|
{
|
|
}
|
|
|
|
FName FInterfaceRegistryEntry::GetRouterName() const
|
|
{
|
|
return RouterName;
|
|
}
|
|
|
|
const FMetasoundFrontendInterface& FInterfaceRegistryEntry::GetInterface() const
|
|
{
|
|
return Interface;
|
|
}
|
|
|
|
bool FInterfaceRegistryEntry::UpdateRootGraphInterface(Frontend::FDocumentHandle InDocument) const
|
|
{
|
|
if (UpdateTransform.IsValid())
|
|
{
|
|
return UpdateTransform->Transform(InDocument);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void RegisterAudioFormatInterfaces()
|
|
{
|
|
using namespace Frontend;
|
|
|
|
IInterfaceRegistry& Reg = IInterfaceRegistry::Get();
|
|
|
|
// Input Formats
|
|
{
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(FMetasoundFrontendInterface(InputFormatMonoInterface::CreateInterface()), IDataReference::RouterName));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(InputFormatStereoInterface::CreateInterface(), IDataReference::RouterName));
|
|
}
|
|
|
|
// Output Formats
|
|
{
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(OutputFormatMonoInterface::CreateInterface()));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(OutputFormatStereoInterface::CreateInterface()));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(OutputFormatQuadInterface::CreateInterface()));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(OutputFormatFiveDotOneInterface::CreateInterface()));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(OutputFormatSevenDotOneInterface::CreateInterface()));
|
|
}
|
|
}
|
|
|
|
void RegisterExternalInterfaces()
|
|
{
|
|
// Register External Interfaces (Interfaces defined externally & can be managed directly by end-user).
|
|
auto RegisterExternalInterface = [](Audio::FParameterInterfacePtr Interface)
|
|
{
|
|
using namespace Frontend;
|
|
|
|
bool bSupportedInterface = false;
|
|
IMetasoundUObjectRegistry::Get().IterateRegisteredUClasses([&bSupportedInterface, &Interface](UClass& InRegisteredClass)
|
|
{
|
|
const TArray<const UClass*> SupportedUClasses = Interface->FindSupportedUClasses();
|
|
bSupportedInterface |= SupportedUClasses.IsEmpty();
|
|
for (const UClass* SupportedUClass : SupportedUClasses)
|
|
{
|
|
check(SupportedUClass);
|
|
bSupportedInterface |= SupportedUClass->IsChildOf(&InRegisteredClass);
|
|
}
|
|
});
|
|
|
|
if (bSupportedInterface)
|
|
{
|
|
IInterfaceRegistry::Get().RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(FMetasoundFrontendInterface(Interface), Audio::IParameterTransmitter::RouterName));
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogMetaSound, Warning, TEXT("Parameter interface '%s' not supported by MetaSounds"), *Interface->GetName().ToString());
|
|
}
|
|
};
|
|
|
|
Audio::IAudioParameterInterfaceRegistry::Get().IterateInterfaces(RegisterExternalInterface);
|
|
Audio::IAudioParameterInterfaceRegistry::Get().OnRegistration(MoveTemp(RegisterExternalInterface));
|
|
}
|
|
|
|
void RegisterInterfaces()
|
|
{
|
|
using namespace Frontend;
|
|
|
|
IInterfaceRegistry& Reg = IInterfaceRegistry::Get();
|
|
|
|
// Default Source Interfaces
|
|
{
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(SourceInterface::CreateInterface(*UMetaSoundSource::StaticClass()), MakeUnique<SourceInterface::FUpdateInterface>()));
|
|
Reg.RegisterInterface(MakeUnique<FInterfaceRegistryEntry>(SourceOneShotInterface::CreateInterface(*UMetaSoundSource::StaticClass())));
|
|
}
|
|
|
|
RegisterAudioFormatInterfaces();
|
|
RegisterExternalInterfaces();
|
|
}
|
|
} // namespace Metasound::Engine
|