Files
charlie huguenard 628c226a65 [Metasound] Remove tick from UMetaSoundOutputSubsystem, only drain queues when there is new data.
#jira UE-214437
#rb ryan.mangin
#tests automated tests

#virtualized

[CL 33556994 by charlie huguenard in ue5-main branch]
2024-05-09 15:58:51 -04:00

54 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "MetasoundGeneratorHandle.h"
#include "Subsystems/WorldSubsystem.h"
#include "MetasoundOutputSubsystem.generated.h"
class UAudioComponent;
/**
* Provides access to a playing Metasound generator's outputs
*/
UCLASS()
class METASOUNDENGINE_API UMetaSoundOutputSubsystem : public UWorldSubsystem
{
GENERATED_BODY()
public:
virtual ~UMetaSoundOutputSubsystem() override = default;
/**
* Watch an output on a Metasound playing on a given audio component.
*
* @param AudioComponent - The audio component
* @param OutputName - The user-specified name of the output in the Metasound
* @param OnOutputValueChanged - The event to fire when the output's value changes
* @param AnalyzerName - (optional) The name of the analyzer to use on the output, defaults to a passthrough
* @param AnalyzerOutputName - (optional) The name of the output on the analyzer to watch, defaults to the passthrough output
* @returns true if the watch setup succeeded, false otherwise
*/
UFUNCTION(BlueprintCallable, Category="MetaSoundOutput", meta=(AdvancedDisplay = "3"))
bool WatchOutput(
UAudioComponent* AudioComponent,
FName OutputName,
const FOnMetasoundOutputValueChanged& OnOutputValueChanged,
FName AnalyzerName = NAME_None,
FName AnalyzerOutputName = NAME_None);
bool WatchOutput(
UAudioComponent* AudioComponent,
FName OutputName,
const FOnMetasoundOutputValueChangedNative& OnOutputValueChanged,
FName AnalyzerName = NAME_None,
FName AnalyzerOutputName = NAME_None);
private:
TSharedPtr<Metasound::FMetasoundGeneratorHandle> GetOrCreateGeneratorHandle(UAudioComponent* AudioComponent);
void CleanUpInvalidGeneratorHandles();
TArray<TSharedPtr<Metasound::FMetasoundGeneratorHandle>> TrackedGenerators;
};