123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- #pragma once
- #include "AkAcousticTexture.h"
- #include "Engine/EngineTypes.h"
- #include "PhysicalMaterials/PhysicalMaterial.h"
- #include "AssetRegistry/AssetRegistryModule.h"
- #include "WwiseDefines.h"
- #include "AkRtpc.h"
- #include "Engine/DataTable.h"
- #include "AkSettings.generated.h"
- class UAkInitBank;
- class UAkAcousticTexture;
- DECLARE_MULTICAST_DELEGATE(FOnSoundBanksPathChangedDelegate);
- UENUM(BlueprintType)
- enum EAkCollisionChannel
- {
- EAKCC_WorldStatic UMETA(DisplayName = "WorldStatic"),
- EAKCC_WorldDynamic UMETA(DisplayName = "WorldDynamic"),
- EAKCC_Pawn UMETA(DisplayName = "Pawn"),
- EAKCC_Visibility UMETA(DisplayName = "Visibility", TraceQuery = "1"),
- EAKCC_Camera UMETA(DisplayName = "Camera", TraceQuery = "1"),
- EAKCC_PhysicsBody UMETA(DisplayName = "PhysicsBody"),
- EAKCC_Vehicle UMETA(DisplayName = "Vehicle"),
- EAKCC_Destructible UMETA(DisplayName = "Destructible"),
- EAKCC_UseIntegrationSettingsDefault UMETA(DisplayName = "Use Integration Settings Default"),
- };
- UENUM()
- enum class EAkUnrealAudioRouting
- {
- Custom UMETA(DisplayName = "Default", ToolTip = "Custom Unreal audio settings set up by the developer"),
- Separate UMETA(DisplayName = "Both Wwise and Unreal audio", ToolTip = "Use default Unreal audio at the same time than Wwise SoundEngine (might be incompatible with some platforms)"),
- AudioLink UMETA(DisplayName = "Route through AudioLink [UE5.1+]", ToolTip = "Use WwiseAudioLink to route all Unreal audio sources to Wwise SoundEngine Inputs (requires Unreal Engine 5.1 or higher)"),
- AudioMixer UMETA(DisplayName = "Route through AkAudioMixer", ToolTip = "Use AkAudioMixer to route Unreal submixes to a Wwise SoundEngine Input"),
- EnableWwiseOnly UMETA(DisplayName = "Enable Wwise SoundEngine only", ToolTip = "Only use Wwise SoundEngine, and disable Unreal audio"),
- EnableUnrealOnly UMETA(DisplayName = "Enable Unreal Audio only", ToolTip = "Only use Unreal audio, and disable Wwise SoundEngine")
- };
- USTRUCT()
- struct FAkGeometrySurfacePropertiesToMap
- {
- GENERATED_BODY()
- UPROPERTY(EditAnywhere, Category = "AkGeometry Surface Properties Map")
- TSoftObjectPtr<class UAkAcousticTexture> AcousticTexture = nullptr;
- UPROPERTY(EditAnywhere, DisplayName = "Transmission Loss", Category = "AkGeometry Surface Properties Map", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float OcclusionValue = 1.f;
- bool operator==(const FAkGeometrySurfacePropertiesToMap& Rhs) const
- {
- if (OcclusionValue != Rhs.OcclusionValue)
- {
- return false;
- }
- if (!AcousticTexture.IsValid() != !Rhs.AcousticTexture.IsValid())
- {
- return false;
- }
- if (!AcousticTexture.IsValid())
- {
- return true;
- }
- return AcousticTexture->GetFName() == Rhs.AcousticTexture->GetFName();
- }
- };
- USTRUCT()
- struct FWwiseGeometrySurfacePropertiesRow : public FTableRowBase
- {
- GENERATED_BODY()
- FWwiseGeometrySurfacePropertiesRow() {}
- FWwiseGeometrySurfacePropertiesRow(TSoftObjectPtr<class UAkAcousticTexture> InAcousticTexture, float InTransmissionLoss)
- {
- AcousticTexture = InAcousticTexture;
- TransmissionLoss = InTransmissionLoss;
- }
-
-
-
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry Surface Properties")
- TSoftObjectPtr<class UAkAcousticTexture> AcousticTexture = nullptr;
-
-
-
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Geometry Surface Properties", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float TransmissionLoss = 1.f;
- };
- USTRUCT()
- struct FWwiseDecayAuxBusRow : public FTableRowBase
- {
- GENERATED_BODY()
- FWwiseDecayAuxBusRow() {}
- FWwiseDecayAuxBusRow(float InDecay, TSoftObjectPtr<class UAkAuxBus> InAuxBus)
- {
- Decay = InDecay;
- AuxBus = InAuxBus;
- }
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reverb Assignment", meta = (ClampMin = "0.0"))
- float Decay = 0.f;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reverb Assignment")
- TSoftObjectPtr<class UAkAuxBus> AuxBus = nullptr;
- };
- USTRUCT()
- struct FAkAcousticTextureParams
- {
- GENERATED_BODY()
- UPROPERTY()
- FVector4 AbsorptionValues = FVector4(FVector::ZeroVector, 0.0f);
- uint32 shortID = 0;
- float AbsorptionLow() const { return AbsorptionValues[0]; }
- float AbsorptionMidLow() const { return AbsorptionValues[1]; }
- float AbsorptionMidHigh() const { return AbsorptionValues[2]; }
- float AbsorptionHigh() const { return AbsorptionValues[3]; }
- TArray<float> AsTArray() const { return { AbsorptionLow(), AbsorptionMidLow(), AbsorptionMidHigh(), AbsorptionHigh() }; }
- };
- #define AK_MAX_AUX_PER_OBJ 4
- DECLARE_EVENT(UAkSettings, ActivatedNewAssetManagement);
- DECLARE_EVENT(UAkSettings, ReverbAssignmentChanged);
- DECLARE_EVENT(UAkSettings, GlobalDecayAbsorptionChanged);
- DECLARE_EVENT(UAkSettings, ReverbRTPCChanged);
- DECLARE_EVENT_TwoParams(UAkSettings, SoundDataFolderChanged, const FString&, const FString&);
- DECLARE_EVENT_OneParam(UAkSettings, AcousticTextureParamsChanged, const FGuid&)
- UCLASS(config = Game, defaultconfig)
- class AKAUDIO_API UAkSettings : public UObject
- {
- GENERATED_BODY()
- public:
- UAkSettings(const FObjectInitializer& ObjectInitializer);
- ~UAkSettings();
-
- static ECollisionChannel ConvertFitToGeomCollisionChannel(EAkCollisionChannel CollisionChannel);
-
- static ECollisionChannel ConvertOcclusionCollisionChannel(EAkCollisionChannel CollisionChannel);
-
-
- UPROPERTY(Config, EditAnywhere, DisplayName = "Max Simultaneous Reverb", Category="Reverb")
- uint8 MaxSimultaneousReverbVolumes = AK_MAX_AUX_PER_OBJ;
-
- UPROPERTY(Config, EditAnywhere, Category="Installation", meta=(FilePathFilter="wproj", AbsolutePath))
- FFilePath WwiseProjectPath;
-
- UPROPERTY()
- FDirectoryPath WwiseSoundDataFolder;
-
- UPROPERTY(Config, EditAnywhere, Category="Installation", meta=( AbsolutePath))
- FDirectoryPath RootOutputPath;
- UPROPERTY(Config)
- FDirectoryPath GeneratedSoundBanksFolder_DEPRECATED;
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Cooking", meta=(RelativeToGameContentDir))
- FDirectoryPath WwiseStagingDirectory = {TEXT("WwiseAudio")};
-
- UPROPERTY(Config)
- bool bSoundBanksTransfered = false;
-
- UPROPERTY(Config)
- bool bAssetsMigrated = false;
-
- UPROPERTY(Config)
- bool bProjectMigrated = false;
- UPROPERTY(Config)
- bool bAutoConnectToWAAPI_DEPRECATED = false;
-
- UPROPERTY(Config, EditAnywhere, Category = "Obstruction Occlusion", meta = (DisplayName = "DefaultCollisionChannel"))
- TEnumAsByte<ECollisionChannel> DefaultOcclusionCollisionChannel = ECollisionChannel::ECC_Visibility;
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Fit To Geometry")
- TEnumAsByte<ECollisionChannel> DefaultFitToGeometryCollisionChannel = ECollisionChannel::ECC_WorldStatic;
-
-
- UPROPERTY(Config)
- TMap<TSoftObjectPtr<UPhysicalMaterial>, FAkGeometrySurfacePropertiesToMap> AkGeometryMap;
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Geometry Surface Properties")
- TSoftObjectPtr<class UAkAcousticTexture> DefaultAcousticTexture = nullptr;
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Geometry Surface Properties", meta = (ClampMin = "0.0", ClampMax = "1.0"))
- float DefaultTransmissionLoss = 0.0f;
-
-
-
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Geometry Surface Properties")
- TSoftObjectPtr<UDataTable> GeometrySurfacePropertiesTable;
-
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment", meta = (ClampMin = 0.1f, ClampMax = 1.0f, UIMin = 0.1f, UIMax = 1.0f))
- float GlobalDecayAbsorption = .5f;
-
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment")
- TSoftObjectPtr<class UAkAuxBus> DefaultReverbAuxBus = nullptr;
-
-
-
- UPROPERTY(Config)
- TMap<float, TSoftObjectPtr<class UAkAuxBus>> EnvironmentDecayAuxBusMap;
-
-
-
-
-
-
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment")
- TSoftObjectPtr<UDataTable> ReverbAssignmentTable;
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- FString HFDampingName = "";
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- FString DecayEstimateName = "";
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- FString TimeToFirstReflectionName = "";
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- TSoftObjectPtr<UAkRtpc> HFDampingRTPC = nullptr;
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- TSoftObjectPtr<UAkRtpc> DecayEstimateRTPC = nullptr;
- UPROPERTY(Config, EditAnywhere, Category = "Reverb Assignment|RTPCs")
- TSoftObjectPtr<UAkRtpc> TimeToFirstReflectionRTPC = nullptr;
-
- UPROPERTY(Config, EditAnywhere, Category = "Initialization")
- TSoftObjectPtr<class UAkAudioEvent> AudioInputEvent = nullptr;
- UPROPERTY(Config, meta = (Deprecated, DeprecationMessage = "AcousticTextureParamsMap is now an internal map."))
- TMap<FGuid, FAkAcousticTextureParams> AcousticTextureParamsMap_DEPRECATED;
-
-
- UPROPERTY(Config, meta = (Deprecated, DeprecationMessage="Setting now exists for each AK Audio Event"))
- bool SplitSwitchContainerMedia = false;
-
-
- UPROPERTY(Config)
- bool SplitMediaPerFolder= false;
-
-
- UPROPERTY(Config)
- bool UseEventBasedPackaging= false;
-
- UPROPERTY()
- FString CommandletCommitMessage = TEXT("Unreal Wwise Sound Data auto-generation");
-
- UPROPERTY(Config, EditAnywhere, Category = "Localization")
- TMap<FString, FString> UnrealCultureToWwiseCulture;
-
- UPROPERTY(Config, EditAnywhere, Category = "Asset Creation")
- FString DefaultAssetCreationPath = "/Game/WwiseAudio";
-
- UPROPERTY(Config, EditAnywhere, Category = "Initialization")
- TSoftObjectPtr<UAkInitBank> InitBank;
-
- UPROPERTY(Config, EditAnywhere, Category = "Initialization", DisplayName = "Unreal Audio Routing", meta=(ConfigRestartRequired=true))
- EAkUnrealAudioRouting AudioRouting = EAkUnrealAudioRouting::Custom;
- UPROPERTY(Config, EditAnywhere, Category = "Initialization", meta=(ConfigRestartRequired=true, EditCondition="AudioRouting == EAkUnrealAudioRouting::Custom"))
- bool bWwiseSoundEngineEnabled = true;
- UPROPERTY(Config, EditAnywhere, Category = "Initialization", meta=(ConfigRestartRequired=true, EditCondition="AudioRouting == EAkUnrealAudioRouting::Custom"))
- bool bWwiseAudioLinkEnabled = false;
- UPROPERTY(Config, EditAnywhere, Category = "Initialization", meta=(ConfigRestartRequired=true, EditCondition="AudioRouting == EAkUnrealAudioRouting::Custom"))
- bool bAkAudioMixerEnabled = false;
- UPROPERTY(Config)
- bool AskedToUseNewAssetManagement_DEPRECATED = false;
- UPROPERTY(Config)
- bool bEnableMultiCoreRendering_DEPRECATED = false;
- UPROPERTY(Config)
- bool MigratedEnableMultiCoreRendering = false;
- UPROPERTY(Config)
- bool FixupRedirectorsDuringMigration = false;
- UPROPERTY(Config)
- FDirectoryPath WwiseWindowsInstallationPath_DEPRECATED;
- UPROPERTY(Config)
- FFilePath WwiseMacInstallationPath_DEPRECATED;
- static FString DefaultSoundDataFolder;
- virtual void PostInitProperties() override;
- bool ReverbRTPCsInUse() const;
- bool DecayRTPCInUse() const;
- bool DampingRTPCInUse() const;
- bool PredelayRTPCInUse() const;
- bool GetAssociatedAcousticTexture(const UPhysicalMaterial* physMaterial, UAkAcousticTexture*& acousticTexture) const;
- bool GetAssociatedOcclusionValue(const UPhysicalMaterial* physMaterial, float& occlusionValue) const;
- #if WITH_EDITOR
- bool UpdateGeneratedSoundBanksPath();
- bool UpdateGeneratedSoundBanksPath(FString Path);
- bool GeneratedSoundBanksPathExists() const;
- bool AreSoundBanksGenerated() const;
- void RefreshAcousticTextureParams() const;
- #if AK_SUPPORT_WAAPI
-
- void InitWaapiSync();
-
- void SetTextureColor(FGuid textureID, int colorIndex);
- #endif
- void RemoveSoundDataFromAlwaysStageAsUFS(const FString& SoundDataPath);
- void RemoveSoundDataFromAlwaysCook(const FString& SoundDataPath);
- void EnsurePluginContentIsInAlwaysCook() const;
- AK_DEPRECATED(2023.1, "Use InitGeometrySurfacePropertiesTable instead.")
- void InitAkGeometryMap() { InitGeometrySurfacePropertiesTable(); }
- void InitGeometrySurfacePropertiesTable();
- void VerifyAndUpdateGeometrySurfacePropertiesTable();
- void InitReverbAssignmentTable();
- #endif
- protected:
- #if WITH_EDITOR
- virtual void PostEditChangeProperty( struct FPropertyChangedEvent& PropertyChangedEvent ) override;
- virtual void PreEditChange(FProperty* PropertyAboutToChange) override;
- virtual void OnReverbAssignmentTableChanged();
- #endif
- private:
- #if WITH_EDITOR
- FString PreviousWwiseProjectPath;
- FString PreviousWwiseGeneratedSoundBankFolder;
- bool bTextureMapInitialized = false;
- TMap< UPhysicalMaterial*, UAkAcousticTexture* > TextureMapInternal;
- FAssetRegistryModule* AssetRegistryModule;
- void OnAssetAdded(const FAssetData& NewAssetData);
- void OnAssetRemoved(const struct FAssetData& AssetData);
- void UpdateGeometrySurfacePropertiesTable(const TArray<FAssetData>& PhysicalMaterials, const TArray<FAssetData>& AcousticTextureAssets);
- void FillGeometrySurfacePropertiesTable();
- void SanitizeProjectPath(FString& Path, const FString& PreviousPath, const FText& DialogMessage);
- void OnAudioRoutingUpdate();
-
- bool bGeometrySurfacePropertiesTableInitialized = false;
- FDelegateHandle ReverbAssignmentTableChangedHandle;
- #if AK_SUPPORT_WAAPI
- TMap<FGuid, TArray<uint64>> WaapiTextureSubscriptions;
- TMap<FGuid, uint64> WaapiTextureColorSubscriptions;
- TMap<FGuid, uint64> WaapiTextureColorOverrideSubscriptions;
- FDelegateHandle WaapiProjectLoadedHandle;
- FDelegateHandle WaapiConnectionLostHandle;
- #endif
- #endif
- TMap<FGuid, FAkAcousticTextureParams> AcousticTextureParamsMap;
- public:
- bool bRequestRefresh = false;
- #if WITH_EDITOR
- const FAkAcousticTextureParams* GetTextureParams(const uint32& shortID) const;
- void SetAcousticTextureParams(const FGuid& textureID, const FAkAcousticTextureParams& params);
- void ClearTextureParamsMap();
- #if AK_SUPPORT_WAAPI
- void WaapiProjectLoaded();
- void WaapiDisconnected();
- void RegisterWaapiTextureCallback(const FGuid& textureID);
- void UnregisterWaapiTextureCallback(const FGuid& textureID);
- void ClearWaapiTextureCallbacks();
-
- void UpdateTextureParams(const FGuid& textureID);
-
- void UpdateTextureColor(const FGuid& textureID);
- #endif
- mutable AcousticTextureParamsChanged OnTextureParamsChanged;
- #endif
- #if WITH_EDITORONLY_DATA
- ReverbAssignmentChanged OnReverbAssignmentChanged;
- GlobalDecayAbsorptionChanged OnGlobalDecayAbsorptionChanged;
- ReverbRTPCChanged OnReverbRTPCChanged;
- FOnSoundBanksPathChangedDelegate OnGeneratedSoundBanksPathChanged;
- #endif
-
- UAkAuxBus* GetAuxBusForDecayValue(float Decay);
- void GetAudioInputEvent(class UAkAudioEvent*& OutInputEvent);
- };
|