Files
UnrealEngineUWP/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Public/MetasoundParameterTransmitter.h
rob gay d2e6910760 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

#ROBOMERGE-AUTHOR: rob.gay
#ROBOMERGE-SOURCE: CL 18344347 in //UE5/Release-5.0/... via CL 18344412
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18344446 by rob gay in ue5-release-engine-test branch]
2021-12-01 15:59:03 -05:00

124 lines
4.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AudioParameterControllerInterface.h"
#include "IAudioParameterTransmitter.h"
#include "MetasoundDataReference.h"
#include "MetasoundFrontendLiteral.h"
#include "MetasoundLog.h"
#include "MetasoundOperatorSettings.h"
#include "MetasoundPrimitives.h"
#include "MetasoundRouter.h"
struct FMetasoundFrontendLiteral;
namespace Metasound
{
namespace Frontend
{
METASOUNDFRONTEND_API FLiteral ConvertParameterToLiteral(FAudioParameter&& InValue);
METASOUNDFRONTEND_API FName ConvertParameterToDataType(EAudioParameterType InParameterType);
}
/** FMetaSoundParameterTransmitter provides a communication interface for
* sending values to a MetaSound instance. It relies on the send/receive transmission
* system to ferry data from the transmitter to the MetaSound instance. Data will
* be safely ushered across thread boundaries in scenarios where the instance
* transmitter and metasound instance live on different threads.
*/
class METASOUNDFRONTEND_API FMetaSoundParameterTransmitter : public Audio::IParameterTransmitter
{
FMetaSoundParameterTransmitter(const FMetaSoundParameterTransmitter&) = delete;
FMetaSoundParameterTransmitter& operator=(const FMetaSoundParameterTransmitter&) = delete;
public:
/** FSendInfo describes the MetaSounds input parameters as well as the
* necessary information to route data to the instances inputs.
*/
struct FSendInfo
{
/** Global address of instance input. */
FSendAddress Address;
/** Name of parameter on MetaSound instance. */
FName ParameterName;
/** Type name of parameter on MetaSound instance. */
FName TypeName;
};
/** Initialization parameters for a FMetaSoundParameterTransmitter. */
struct FInitParams
{
/** FOperatorSettings must match the operator settings of the MetaSound
* instance to ensure proper operation. */
FOperatorSettings OperatorSettings;
/** ID of the MetaSound instance. */
uint64 InstanceID;
/** Available input parameters on MetaSound instance. */
TArray<FSendInfo> Infos;
FInitParams(const FOperatorSettings& InSettings, uint64 InInstanceID, const TArray<FSendInfo>& InInfos=TArray<FSendInfo>())
: OperatorSettings(InSettings)
, InstanceID(InInstanceID)
, Infos(InInfos)
{
}
};
/** Creates a unique send address using the given MetaSound environment. */
static FSendAddress CreateSendAddressFromEnvironment(const FMetasoundEnvironment& InEnvironment, const FVertexName& InVertexName, const FName& InTypeName);
/** Creates a unique send address using the given InstanceID. */
static FSendAddress CreateSendAddressFromInstanceID(uint64 InInstanceID, const FVertexName& InVertexName, const FName& InTypeName);
FMetaSoundParameterTransmitter(const FMetaSoundParameterTransmitter::FInitParams& InInitParams);
virtual ~FMetaSoundParameterTransmitter() = default;
bool Reset() override;
/** Returns ID of the MetaSound instance associated with this transmitter. */
uint64 GetInstanceID() const override;
/** Sets a parameter using an AudioParameter struct
*
* @param InParameter - Parameter to set.
*/
bool SetParameter(FAudioParameter&& InParameter) override;
/** Set a parameter using a literal.
*
* @param InParameterName - Name of MetaSound instance parameter.
* @param InValue - Literal value used to construct parameter value.
*
* @return true on success, false on failure.
*/
bool SetParameterWithLiteral(FName InParameterName, const FLiteral& InValue);
/** Duplicate this transmitter interface. The transmitters association with
* the MetaSound instance will be maintained. */
TUniquePtr<Audio::IParameterTransmitter> Clone() const override;
private:
// Find FSendInfo by parameter name.
const FSendInfo* FindSendInfo(const FName& InParameterName) const;
// Find ISender by parameter name.
ISender* FindSender(const FName& InParameterName);
// Create and store a new ISender for the given FSendInfo.
ISender* AddSender(const FSendInfo& InInfo);
TArray<FSendInfo> SendInfos;
FOperatorSettings OperatorSettings;
uint64 InstanceID;
TMap<FName, TUniquePtr<ISender>> InputSends;
};
}