2021-01-22 03:05:22 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "IAudioExtensionPlugin.h"
|
|
|
|
|
#include "MetasoundDataReference.h"
|
|
|
|
|
#include "MetasoundLog.h"
|
|
|
|
|
#include "MetasoundOperatorSettings.h"
|
|
|
|
|
#include "MetasoundPrimitives.h"
|
|
|
|
|
#include "MetasoundRouter.h"
|
|
|
|
|
|
|
|
|
|
namespace Metasound
|
|
|
|
|
{
|
2021-03-05 20:06:54 -04:00
|
|
|
/** FMetasoundInstanceTransmitter 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.
|
|
|
|
|
*/
|
2021-01-22 03:05:22 -04:00
|
|
|
class METASOUNDFRONTEND_API FMetasoundInstanceTransmitter : public IAudioInstanceTransmitter
|
|
|
|
|
{
|
|
|
|
|
FMetasoundInstanceTransmitter(const FMetasoundInstanceTransmitter&) = delete;
|
|
|
|
|
FMetasoundInstanceTransmitter& operator=(const FMetasoundInstanceTransmitter&) = delete;
|
|
|
|
|
public:
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** FSendInfo describes the MetaSounds input parameters as well as the
|
|
|
|
|
* necessary information to route data to the instances inputs.
|
|
|
|
|
*/
|
2021-01-22 03:05:22 -04:00
|
|
|
struct FSendInfo
|
|
|
|
|
{
|
2021-03-05 20:06:54 -04:00
|
|
|
/** Global address of instance input. */
|
2021-01-22 03:05:22 -04:00
|
|
|
FSendAddress Address;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** Name of parameter on MetaSound instance. */
|
2021-01-22 03:05:22 -04:00
|
|
|
FName ParameterName;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** Type name of parameter on MetaSound instance. */
|
2021-01-22 03:05:22 -04:00
|
|
|
FName TypeName;
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-05 20:06:54 -04:00
|
|
|
/** Initialization parameters for a FMetasoundInstanceTransmitter. */
|
2021-01-22 03:05:22 -04:00
|
|
|
struct FInitParams
|
|
|
|
|
{
|
2021-03-05 20:06:54 -04:00
|
|
|
/** FOperatorSettings must match the operator settings of the MetaSound
|
|
|
|
|
* instance to ensure proper operation. */
|
2021-01-22 03:05:22 -04:00
|
|
|
FOperatorSettings OperatorSettings;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** ID of the MetaSound instance. */
|
2021-01-22 03:05:22 -04:00
|
|
|
uint64 InstanceID;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** Available input parameters on MetaSound instance. */
|
2021-01-22 03:05:22 -04:00
|
|
|
TArray<FSendInfo> Infos;
|
|
|
|
|
|
|
|
|
|
FInitParams(const FOperatorSettings& InSettings, uint64 InInstanceID, const TArray<FSendInfo>& InInfos=TArray<FSendInfo>())
|
|
|
|
|
: OperatorSettings(InSettings)
|
|
|
|
|
, InstanceID(InInstanceID)
|
|
|
|
|
, Infos(InInfos)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FMetasoundInstanceTransmitter(const FMetasoundInstanceTransmitter::FInitParams& InInitParams);
|
|
|
|
|
virtual ~FMetasoundInstanceTransmitter() = default;
|
|
|
|
|
|
2021-04-06 01:41:29 -04:00
|
|
|
bool Shutdown() override;
|
|
|
|
|
|
2021-03-05 20:06:54 -04:00
|
|
|
/** Returns ID of the MetaSound instance associated with this transmitter. */
|
2021-01-22 03:05:22 -04:00
|
|
|
uint64 GetInstanceID() const override;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
/** Set a parameter using a literal.
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - Literal value used to construct paramter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameterWithLiteral(const FName& InParameterName, const FLiteral& InValue);
|
|
|
|
|
|
|
|
|
|
/** Duplicate this transmitter interface. The transmitters association with
|
|
|
|
|
* the MetaSound instance will be maintained. */
|
2021-01-22 03:05:22 -04:00
|
|
|
TUniquePtr<IAudioInstanceTransmitter> Clone() const override;
|
2021-03-11 22:49:38 -04:00
|
|
|
|
|
|
|
|
/** Set a parameter (bool)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - bool value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, bool InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter (bool array)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - bool array r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, TArray<bool>&& InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter (int32)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - in32 value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, int32 InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (int32 array)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - int32 array r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, TArray<int32>&& InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (float)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - float value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, float InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (float array)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - float array r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, TArray<float>&& InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (string)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - string r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, FString&& InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (string array)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - string array r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, TArray<FString>&& InValue) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (Audio::IProxyData)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - Audio::IProxyData r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, Audio::IProxyDataPtr&& ) override;
|
|
|
|
|
|
|
|
|
|
/** Set a parameter overloads (Audio::IProxyData array)
|
|
|
|
|
*
|
|
|
|
|
* @param InParameterName - Name of MetaSound instance parameter.
|
|
|
|
|
* @param InValue - Audio::IProxyData array r-value value used to construct parameter value.
|
|
|
|
|
*
|
|
|
|
|
* @return true on success, false on failure.
|
|
|
|
|
*/
|
|
|
|
|
bool SetParameter(const FName& InName, TArray<Audio::IProxyDataPtr>&& InValue) override;
|
2021-01-22 03:05:22 -04:00
|
|
|
|
|
|
|
|
private:
|
2021-03-05 20:06:54 -04:00
|
|
|
// Find FSendInfo by parameter name.
|
2021-01-22 03:05:22 -04:00
|
|
|
const FSendInfo* FindSendInfo(const FName& InParameterName) const;
|
2021-03-05 20:06:54 -04:00
|
|
|
|
|
|
|
|
// Find ISender by parameter name.
|
2021-01-22 03:05:22 -04:00
|
|
|
ISender* FindSender(const FName& InParameterName);
|
|
|
|
|
|
2021-03-05 20:06:54 -04:00
|
|
|
// Create and store a new ISender for the given FSendInfo.
|
|
|
|
|
ISender* AddSender(const FSendInfo& InInfo);
|
2021-01-22 03:05:22 -04:00
|
|
|
|
|
|
|
|
TArray<FSendInfo> SendInfos;
|
|
|
|
|
FOperatorSettings OperatorSettings;
|
|
|
|
|
uint64 InstanceID;
|
|
|
|
|
|
|
|
|
|
TMap<FName, TUniquePtr<ISender>> InputSends;
|
|
|
|
|
};
|
|
|
|
|
}
|