2021-04-12 03:48:54 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Internationalization/Text.h"
|
|
|
|
|
|
|
|
|
|
#include "MetasoundWave.h"
|
|
|
|
|
#include "MetasoundFacade.h"
|
|
|
|
|
#include "MetasoundPrimitives.h"
|
|
|
|
|
#include "MetasoundAudioBuffer.h"
|
|
|
|
|
#include "MetasoundParamHelper.h"
|
|
|
|
|
#include "MetasoundOperatorSettings.h"
|
|
|
|
|
#include "MetasoundEngineNodesNames.h"
|
|
|
|
|
#include "MetasoundExecutableOperator.h"
|
|
|
|
|
#include "MetasoundNodeRegistrationMacro.h"
|
|
|
|
|
#include "MetasoundStandardNodesCategories.h"
|
|
|
|
|
#include "MetasoundDataTypeRegistrationMacro.h"
|
2021-09-13 14:13:39 -04:00
|
|
|
#include "MetasoundVertex.h"
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "MetasoundWaveInfo"
|
|
|
|
|
|
|
|
|
|
namespace Metasound
|
|
|
|
|
{
|
|
|
|
|
// forward declarations
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
namespace WaveInfoNodeParameterNames
|
|
|
|
|
{
|
|
|
|
|
// inputs
|
|
|
|
|
METASOUND_PARAM(ParamWaveAsset, "Wave", "Input Wave Asset");
|
|
|
|
|
|
|
|
|
|
// outputs
|
|
|
|
|
METASOUND_PARAM(ParamDurationSeconds, "Duration", "Duration of the wave asset in seconds");
|
2024-04-17 02:41:05 -04:00
|
|
|
METASOUND_PARAM(OutParamAssetName, "Name", "Name of the wave asset");
|
|
|
|
|
METASOUND_PARAM(OutParamAssetPath, "Path", "Full path of the wave asset");
|
2021-04-12 03:48:54 -04:00
|
|
|
|
2024-04-17 02:41:05 -04:00
|
|
|
} // namespace WaveInfoNodeParameterNames
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
class FWaveInfoNodeOperator : public TExecutableOperator < FWaveInfoNodeOperator >
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// ctor
|
|
|
|
|
FWaveInfoNodeOperator(const FOperatorSettings& InSettings, const FWaveAssetReadRef& InWaveAsset);
|
|
|
|
|
|
|
|
|
|
// node interface
|
|
|
|
|
static const FNodeClassMetadata& GetNodeInfo();
|
|
|
|
|
static FVertexInterface DeclareVertexInterface();
|
2023-10-13 19:29:51 -04:00
|
|
|
static TUniquePtr<IOperator> CreateOperator(const FBuildOperatorParams& InParams, FBuildResults& OutResults);
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
virtual void BindInputs(FInputVertexInterfaceData& InOutVertexData) override;
|
|
|
|
|
virtual void BindOutputs(FOutputVertexInterfaceData& InOutVertexData) override;
|
2021-04-12 03:48:54 -04:00
|
|
|
virtual FDataReferenceCollection GetInputs() const override;
|
|
|
|
|
virtual FDataReferenceCollection GetOutputs() const override;
|
|
|
|
|
void Execute();
|
2023-03-02 14:40:35 -05:00
|
|
|
void Reset(const IOperator::FResetParams& InParams);
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
private: // members
|
|
|
|
|
// input pins
|
|
|
|
|
FWaveAssetReadRef WaveAsset;
|
|
|
|
|
|
|
|
|
|
// output pins
|
|
|
|
|
FTimeWriteRef DurationSeconds;
|
2024-04-17 02:41:05 -04:00
|
|
|
FStringWriteRef NameOutput;
|
|
|
|
|
FStringWriteRef PathOutput;
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
// other
|
2024-04-17 02:41:05 -04:00
|
|
|
FSoundWaveProxyPtr SoundWaveProxy;
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
}; // class FWaveInfoNodeOperator
|
|
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
|
FWaveInfoNodeOperator::FWaveInfoNodeOperator(const FOperatorSettings& InSettings, const FWaveAssetReadRef& InWaveAsset)
|
|
|
|
|
: WaveAsset(InWaveAsset)
|
|
|
|
|
, DurationSeconds(FTimeWriteRef::CreateNew(0.0f))
|
2024-04-17 02:41:05 -04:00
|
|
|
, NameOutput(FStringWriteRef::CreateNew(TEXT("")))
|
|
|
|
|
, PathOutput(FStringWriteRef::CreateNew(TEXT("")))
|
2021-04-12 03:48:54 -04:00
|
|
|
{
|
|
|
|
|
Execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FNodeClassMetadata& FWaveInfoNodeOperator::GetNodeInfo()
|
|
|
|
|
{
|
|
|
|
|
auto InitNodeInfo = []() -> FNodeClassMetadata
|
|
|
|
|
{
|
|
|
|
|
FNodeClassMetadata Info;
|
2024-04-17 02:41:05 -04:00
|
|
|
Info.ClassName = { Metasound::EngineNodes::Namespace, "Get Wave Duration", " " };
|
2021-04-12 03:48:54 -04:00
|
|
|
Info.MajorVersion = 1;
|
|
|
|
|
Info.MinorVersion = 0;
|
2024-04-17 02:41:05 -04:00
|
|
|
Info.DisplayName = METASOUND_LOCTEXT("MetasoundGetWaveInfo_ClassNodeDisplayName", "Get Wave Info");
|
|
|
|
|
Info.Description = METASOUND_LOCTEXT("GetWaveInfo_NodeDescription", "Returns the Info from the Wave Asset"),
|
2021-04-12 03:48:54 -04:00
|
|
|
Info.Author = PluginAuthor;
|
|
|
|
|
Info.PromptIfMissing = PluginNodeMissingPrompt;
|
|
|
|
|
Info.DefaultInterface = DeclareVertexInterface();
|
2024-04-17 02:41:05 -04:00
|
|
|
Info.CategoryHierarchy.Emplace(NodeCategories::Debug);
|
2024-05-22 02:38:07 -04:00
|
|
|
Info.Keywords = { METASOUND_LOCTEXT("WaveInfoNode_DurationKeyword", "Duration"), METASOUND_LOCTEXT("WaveInfoNode_NameKeyword", "Name"), METASOUND_LOCTEXT("WaveInfoNode_PathKeyword", "Path") };
|
|
|
|
|
|
2021-04-12 03:48:54 -04:00
|
|
|
return Info;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const FNodeClassMetadata Info = InitNodeInfo();
|
|
|
|
|
|
|
|
|
|
return Info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FVertexInterface FWaveInfoNodeOperator::DeclareVertexInterface()
|
|
|
|
|
{
|
|
|
|
|
using namespace WaveInfoNodeParameterNames;
|
|
|
|
|
static const FVertexInterface Interface(
|
|
|
|
|
FInputVertexInterface(
|
2022-03-31 16:49:59 -04:00
|
|
|
TInputDataVertex<FWaveAsset>(METASOUND_GET_PARAM_NAME_AND_METADATA(ParamWaveAsset))
|
2021-04-12 03:48:54 -04:00
|
|
|
),
|
|
|
|
|
FOutputVertexInterface(
|
2024-04-17 02:41:05 -04:00
|
|
|
TOutputDataVertex<FTime>(METASOUND_GET_PARAM_NAME_AND_METADATA(ParamDurationSeconds)),
|
|
|
|
|
TOutputDataVertex<FString>(METASOUND_GET_PARAM_NAME_AND_METADATA(OutParamAssetName)),
|
|
|
|
|
TOutputDataVertex<FString>(METASOUND_GET_PARAM_NAME_AND_METADATA(OutParamAssetPath))
|
2021-04-12 03:48:54 -04:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return Interface;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-13 19:29:51 -04:00
|
|
|
TUniquePtr<IOperator> FWaveInfoNodeOperator::CreateOperator(const FBuildOperatorParams& InParams, FBuildResults& OutResults)
|
2021-04-12 03:48:54 -04:00
|
|
|
{
|
|
|
|
|
using namespace WaveInfoNodeParameterNames;
|
|
|
|
|
|
2023-10-13 19:29:51 -04:00
|
|
|
const FInputVertexInterfaceData& InputData = InParams.InputData;
|
2021-04-12 03:48:54 -04:00
|
|
|
// inputs
|
2023-10-13 19:29:51 -04:00
|
|
|
FWaveAssetReadRef WaveAssetIn = InputData.GetOrConstructDataReadReference<FWaveAsset>(METASOUND_GET_PARAM_NAME(ParamWaveAsset));
|
2021-04-12 03:48:54 -04:00
|
|
|
|
|
|
|
|
return MakeUnique < FWaveInfoNodeOperator >(InParams.OperatorSettings, WaveAssetIn);
|
|
|
|
|
}
|
|
|
|
|
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
void FWaveInfoNodeOperator::BindInputs(FInputVertexInterfaceData& InOutVertexData)
|
2021-04-12 03:48:54 -04:00
|
|
|
{
|
|
|
|
|
using namespace WaveInfoNodeParameterNames;
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
InOutVertexData.BindReadVertex(METASOUND_GET_PARAM_NAME(ParamWaveAsset), WaveAsset);
|
2021-04-12 03:48:54 -04:00
|
|
|
}
|
|
|
|
|
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
void FWaveInfoNodeOperator::BindOutputs(FOutputVertexInterfaceData& InOutVertexData)
|
2021-04-12 03:48:54 -04:00
|
|
|
{
|
|
|
|
|
// expose read access to our output buffer for other processors in the graph
|
|
|
|
|
using namespace WaveInfoNodeParameterNames;
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
InOutVertexData.BindReadVertex(METASOUND_GET_PARAM_NAME(ParamDurationSeconds), DurationSeconds);
|
2024-04-17 02:41:05 -04:00
|
|
|
InOutVertexData.BindReadVertex(METASOUND_GET_PARAM_NAME(OutParamAssetName), NameOutput);
|
|
|
|
|
InOutVertexData.BindReadVertex(METASOUND_GET_PARAM_NAME(OutParamAssetPath), PathOutput);
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
}
|
2021-04-12 03:48:54 -04:00
|
|
|
|
[Metasound Bind] Fixup for bind issues caught by new automated tests.
#jira UE-187406, UE-187390, UE-187404, UE-187403, UE-187405, UE-187392, UE-187391, UE-187395, UE-187399, UE-187398, UE-187389, UE-187393, UE-187394, UE-187396, UE-187397, UE-187401
#rb phil.popp
[CL 26130674 by maxwell hayes in ue5-main branch]
2023-06-20 15:08:54 -04:00
|
|
|
FDataReferenceCollection FWaveInfoNodeOperator::GetInputs() const
|
|
|
|
|
{
|
|
|
|
|
// This should never be called. Bind(...) is called instead. This method
|
|
|
|
|
// exists as a stop-gap until the API can be deprecated and removed.
|
|
|
|
|
checkNoEntry();
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDataReferenceCollection FWaveInfoNodeOperator::GetOutputs() const
|
|
|
|
|
{
|
|
|
|
|
// This should never be called. Bind(...) is called instead. This method
|
|
|
|
|
// exists as a stop-gap until the API can be deprecated and removed.
|
|
|
|
|
checkNoEntry();
|
|
|
|
|
return {};
|
2021-04-12 03:48:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FWaveInfoNodeOperator::Execute()
|
|
|
|
|
{
|
2024-04-17 02:41:05 -04:00
|
|
|
FSoundWaveProxyPtr ProxyPtr = (*WaveAsset).GetSoundWaveProxy();
|
|
|
|
|
|
|
|
|
|
if (SoundWaveProxy != ProxyPtr)
|
2021-04-12 03:48:54 -04:00
|
|
|
{
|
2024-04-17 02:41:05 -04:00
|
|
|
SoundWaveProxy = ProxyPtr;
|
|
|
|
|
|
|
|
|
|
if (SoundWaveProxy.IsValid() && (*WaveAsset).IsSoundWaveValid())
|
|
|
|
|
{
|
|
|
|
|
*DurationSeconds = FTime::FromSeconds((*WaveAsset)->GetDuration());
|
|
|
|
|
|
|
|
|
|
FName AssetName = SoundWaveProxy->GetFName();
|
|
|
|
|
*NameOutput = AssetName.ToString();
|
|
|
|
|
|
|
|
|
|
FString FullPath;
|
|
|
|
|
SoundWaveProxy->GetPackageName().AppendString(FullPath);
|
|
|
|
|
if (!AssetName.IsNone())
|
|
|
|
|
{
|
|
|
|
|
FullPath += TEXT(".");
|
|
|
|
|
AssetName.AppendString(FullPath);
|
|
|
|
|
}
|
|
|
|
|
*PathOutput = FullPath;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*DurationSeconds = FTime::FromSeconds(0.0f);
|
|
|
|
|
*NameOutput = TEXT("");
|
|
|
|
|
*PathOutput = TEXT("");
|
|
|
|
|
}
|
2021-04-12 03:48:54 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 14:40:35 -05:00
|
|
|
void FWaveInfoNodeOperator::Reset(const IOperator::FResetParams& InParams)
|
|
|
|
|
{
|
|
|
|
|
Execute();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 03:48:54 -04:00
|
|
|
class FWaveInfoNode : public FNodeFacade
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// public node api needs to define two conversion constructors:
|
|
|
|
|
// (1: from FString)
|
2021-09-13 14:13:39 -04:00
|
|
|
FWaveInfoNode(const Metasound::FVertexName& InInstanceName, const FGuid& InInstanceID)
|
2021-04-12 03:48:54 -04:00
|
|
|
: FNodeFacade(InInstanceName, InInstanceID, TFacadeOperatorClass < FWaveInfoNodeOperator >())
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
// (2: From an NodeInitData struct)
|
|
|
|
|
FWaveInfoNode(const FNodeInitData& InInitData)
|
|
|
|
|
: FWaveInfoNode(InInitData.InstanceName, InInitData.InstanceID)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
METASOUND_REGISTER_NODE(FWaveInfoNode);
|
|
|
|
|
|
|
|
|
|
} // namespace Metasound
|
|
|
|
|
|
2022-03-31 16:49:59 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE //MetasoundWaveInfo
|