2023-10-13 17:49:56 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Containers/Array.h"
|
|
|
|
|
#include "Containers/Map.h"
|
|
|
|
|
#include "MetasoundOperatorInterface.h"
|
|
|
|
|
#include "Misc/Guid.h"
|
|
|
|
|
#include "HAL/CriticalSection.h"
|
|
|
|
|
#include "Templates/UniquePtr.h"
|
2023-10-13 19:20:20 -04:00
|
|
|
#include "Sound/SoundGenerator.h"
|
2023-10-13 17:49:56 -04:00
|
|
|
#include "Subsystems/AudioEngineSubsystem.h"
|
|
|
|
|
|
|
|
|
|
#include "MetasoundSource.h"
|
|
|
|
|
|
|
|
|
|
#include "MetasoundOperatorCacheSubsystem.generated.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* UMetaSoundCacheSubsystem
|
|
|
|
|
*/
|
|
|
|
|
UCLASS()
|
|
|
|
|
class METASOUNDENGINE_API UMetaSoundCacheSubsystem : public UAudioEngineSubsystem
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
//~ Begin USubsystem interface
|
|
|
|
|
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
|
|
|
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
2024-02-08 18:23:13 -05:00
|
|
|
virtual void Update() override;
|
2023-10-13 17:49:56 -04:00
|
|
|
//~ End USubsystem interface
|
|
|
|
|
|
|
|
|
|
/* Builds the requested number of MetaSound operators (asynchronously) and puts them in the pool for playback.
|
2024-02-08 18:23:13 -05:00
|
|
|
(If these operators are not yet available when the MetaSound attempts to play, one will be created Independent of this request.) */
|
2024-02-13 20:57:28 -05:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "MetaSound", meta = (DisplayName = "Precache MetaSound"))
|
|
|
|
|
void PrecacheMetaSound(UPARAM(DisplayName = "MetaSound Source") UMetaSoundSource* InMetaSound, UPARAM(DisplayName = "Num Instances") int32 InNumInstances = 1);
|
2023-10-13 17:49:56 -04:00
|
|
|
|
2023-10-31 18:35:37 -04:00
|
|
|
/* same as PrecacheMetaSound except cached operator that already exists in the cache will be moved to the top instead of building,
|
|
|
|
|
any operators that we couldn't move to the top, will be built.
|
|
|
|
|
(i.e. if 2 operators are already cached and Num Instances is 4, it will construct 2 and move the existing 2 to the top of the cache) */
|
2024-02-13 20:57:28 -05:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "MetaSound", meta = (DisplayName = "Touch or Precache MetaSound"))
|
|
|
|
|
void TouchOrPrecacheMetaSound(UPARAM(DisplayName = "MetaSound Source") UMetaSoundSource* InMetaSound, UPARAM(DisplayName = "Num Instances") int32 InNumInstances = 1);
|
2023-10-31 18:35:37 -04:00
|
|
|
|
|
|
|
|
/* Clear the operator pool of any operators associated with the given MetaSound */
|
2024-02-13 20:57:28 -05:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "MetaSound", meta = (DisplayName = "RemoveCached Operators for MetaSound"))
|
|
|
|
|
void RemoveCachedOperatorsForMetaSound(UPARAM(DisplayName = "MetaSound Source") UMetaSoundSource* InMetaSound);
|
2023-10-31 18:35:37 -04:00
|
|
|
|
2023-10-13 17:49:56 -04:00
|
|
|
private:
|
2023-10-13 19:20:20 -04:00
|
|
|
FSoundGeneratorInitParams BuildParams;
|
2023-10-13 17:49:56 -04:00
|
|
|
}; //UMetaSoundCacheSubsystem
|
|
|
|
|
|