Download

Custom metasound graph node not available in menu

Created a custom metasounds graph node using the BPM to Seconds node as an example. It does compile, however I do not see it in the avaialable nodes in metasounds. Below is the code for the class. Any help is appreciated. Thanks!

// FAudioClamp.h

#include "FAudioClamp.h"

#include "Internationalization/Text.h"
#include "MetasoundPrimitives.h"
#include "MetasoundExecutableOperator.h"
#include "MetasoundTime.h"
#include "MetasoundNodeRegistrationMacro.h"

#define LOCTEXT_NAMESPACE "MetasoundStandardNodes_AudioClamp"

class FAudioClampOperator : public TExecutableOperator<FAudioClampOperator>
{
public:
	static const FNodeClassMetadata& GetNodeInfo();
	static const FVertexInterface& GetVertexInterface();
	static TUniquePtr<IOperator> CreateOperator(const FCreateOperatorParams& InParams, FBuildErrorArray& OutErrors);

	FAudioClampOperator(const FOperatorSettings& InSettings, const FFloatReadRef& FloatIn);

	virtual FDataReferenceCollection GetInputs() const override;
	virtual FDataReferenceCollection GetOutputs() const override;
	void Execute();

private:
	FFloatReadRef FloatIn;
	FFloatWriteRef FloatOut;
};

FAudioClampOperator::FAudioClampOperator(const FOperatorSettings& InSettings, const FFloatReadRef& FloatIn)
	: FloatIn(FloatIn)
	  , FloatOut(TDataWriteReferenceFactory<float>::CreateAny(InSettings))
{
	//UpdateTime();
}

FDataReferenceCollection FAudioClampOperator::GetInputs() const
{
	FDataReferenceCollection InputDataReferences;
	InputDataReferences.AddDataReadReference(TEXT("Example In"), FloatIn);
	return InputDataReferences;
}

FDataReferenceCollection FAudioClampOperator::GetOutputs() const
{
	FDataReferenceCollection OutputDataReferences;
	OutputDataReferences.AddDataWriteReference(TEXT("Example Out"), FloatOut);
	return OutputDataReferences;
}

const FVertexInterface& FAudioClampOperator::GetVertexInterface()
{
	static const FVertexInterface Interface (
		FInputVertexInterface(
			TInputDataVertexModel<float>(TEXT("Example In"), LOCTEXT("ExmpleAsInput", "Example input value."), 27.7f)				
		),
		FOutputVertexInterface(
			TOutputDataVertexModel<float>(TEXT("Example Out"), LOCTEXT("ExampleAsOutput", "Example output value"))
		)
	);
	return Interface;
}


void FAudioClampOperator::Execute()
{
	//FloatOut = (*FloatIn > 1.f) ? 1.f : FloatIn;
}

const FNodeClassMetadata& FAudioClampOperator::GetNodeInfo()
{
	auto InitNodeInfo = []() -> FNodeClassMetadata
	{
		FNodeClassMetadata Info;
		Info.ClassName = {FName("SomethingCustom"), TEXT("AudioClamp"), TEXT("Some text goes here")};
		Info.MajorVersion = 1;
		Info.MinorVersion = 0;
		Info.DisplayName = LOCTEXT("AudioClampDisplayName", "Custom Audio clamp");
		Info.Description = LOCTEXT("AudioClampDesc", "Simple example for custom audio clamp.");
		Info.Author = PluginAuthor;
		Info.PromptIfMissing = PluginNodeMissingPrompt;
		Info.DefaultInterface = GetVertexInterface();
		return Info;
	};

	static const FNodeClassMetadata Info = InitNodeInfo();
	return Info;
}

TUniquePtr<IOperator> FAudioClampOperator::CreateOperator(const FCreateOperatorParams& InParams,
                                                          FBuildErrorArray& OutErrors)
{
	const FDataReferenceCollection& InputCollection = InParams.InputDataReferences;
	const FInputVertexInterface& InputInterface = GetVertexInterface().GetInputInterface();

	FFloatReadRef InFloatIn = InputCollection.GetDataReadReferenceOrConstructWithVertexDefault<float>(
		InputInterface, TEXT("Example In"), InParams.OperatorSettings);

	return MakeUnique<FAudioClampOperator>(InParams.OperatorSettings, InFloatIn);
}

	
FAudioClamp::FAudioClamp(const FNodeInitData& InitData) : FNodeFacade(InitData.InstanceName, InitData.InstanceID, TFacadeOperatorClass<FAudioClampOperator>())
{
}

METASOUND_REGISTER_NODE(FAudioClamp);


1 Like

Ok, it works now. Three restarts/rebuilds and it is there now. Not sure what the procedure should be for loading these. Any information on that, would be great.

Ok, now running into another problem. When I create a plugin and use the same code it does not load. I tried adding the following to the uplugin file.

 "Modules": [
		{
			"Name": "MetasoundTools",
			"Type": "Runtime",
			"LoadingPhase": "PostDefault"
		}
	],
	"Plugins": [
		{
			"Name": "Metasound",
			"Enabled": true
		}
	]