Files
UnrealEngineUWP/Engine/Source/Runtime/AudioPlatformConfiguration/Public/AudioCompressionSettings.h
ethan geller 7a7ea94d8d Fix for ensure on cook for Switch/iOS/Android.
#ROBOMERGE-OWNER: lina.halper
#ROBOMERGE-AUTHOR: ethan.geller
#ROBOMERGE-SOURCE: CL 5102439 via CL 5103044 via CL 5103074
#ROBOMERGE-BOT: ANIM (Main -> Dev-Anim)

[CL 5146016 by ethan geller in Dev-Anim branch]
2019-02-22 11:58:17 -05:00

114 lines
4.5 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "AudioCompressionSettings.generated.h"
UENUM()
enum class ESoundwaveSampleRateSettings : uint8
{
Max,
High,
Medium,
Low,
Min,
// Use this setting to resample soundwaves to the device's sample rate to avoid having to perform sample rate conversion at runtime.
MatchDevice
};
/************************************************************************/
/* FPlatformAudioCookOverrides */
/* This struct is used for settings used during the cook to a target */
/* platform (platform-specific compression quality and resampling, etc.)*/
/************************************************************************/
struct FPlatformAudioCookOverrides
{
bool bResampleForDevice;
// Mapping of which sample rates are used for each sample rate quality for a specific platform.
TMap<ESoundwaveSampleRateSettings, float> PlatformSampleRates;
// Scales all compression qualities when cooking to this platform. For example, 0.5 will halve all compression qualities, and 1.0 will leave them unchanged.
float CompressionQualityModifier;
// When set to any platform > 0.0, this will automatically set any USoundWave beyond this value to be streamed from disk.
float AutoStreamingThreshold;
FPlatformAudioCookOverrides()
: bResampleForDevice(false)
, CompressionQualityModifier(1.0f)
, AutoStreamingThreshold(0.0f)
{
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Max, 48000);
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::High, 32000);
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Medium, 24000);
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Low, 12000);
PlatformSampleRates.Add(ESoundwaveSampleRateSettings::Min, 8000);
}
// This is used to invalidate compressed audio for a specific platform
static void GetHashSuffix(const FPlatformAudioCookOverrides* InOverrides, FString& OutSuffix)
{
if (InOverrides == nullptr)
{
return;
}
int32 CompressionQualityHash = FMath::FloorToInt(InOverrides->CompressionQualityModifier * 100.0f);
OutSuffix.AppendInt(CompressionQualityHash);
int32 AutoStreamingThresholdHash = FMath::FloorToInt(InOverrides->AutoStreamingThreshold * 100.0f);
OutSuffix.AppendInt(AutoStreamingThresholdHash);
int32 ResampleBoolHash = (int32)InOverrides->bResampleForDevice;
OutSuffix.AppendInt(ResampleBoolHash);
TMap<ESoundwaveSampleRateSettings, float> SampleRateMap = InOverrides->PlatformSampleRates;
for (auto& SampleRateQuality : SampleRateMap)
{
int32 SampleRateHash = FMath::FloorToInt(SampleRateQuality.Value / 1000.0f);
OutSuffix.AppendInt(SampleRateHash);
}
}
};
USTRUCT()
struct AUDIOPLATFORMCONFIGURATION_API FPlatformRuntimeAudioCompressionOverrides
{
GENERATED_USTRUCT_BODY()
// Set this to true to override Sound Groups and use the Duration Threshold value to determine whether a sound should be fully decompressed during initial loading.
UPROPERTY(EditAnywhere, Category = "DecompressOnLoad")
bool bOverrideCompressionTimes;
// When Override Compression Times is set to true, any sound under this threshold (in seconds) will be fully decompressed on load.
// Otherwise the first chunk of this sound is cached at load and the rest is decompressed in real time.
UPROPERTY(EditAnywhere, Category = "DecompressOnLoad")
float DurationThreshold;
// On this platform, any random nodes on Sound Cues will automatically only preload this number of branches and dispose of any others
// on load. This can drastically cut down on memory usage.
UPROPERTY(EditAnywhere, Category = "SoundCueLoading", meta = (DisplayName = "Maximum Branches on Random SoundCue nodes", ClampMin = "1"))
int32 MaxNumRandomBranches;
// On this platform, use the specified quality at this index to override the quality used for SoundCues on this platform
UPROPERTY(EditAnywhere, Category = "SoundCueLoading", meta = (DisplayName = "Quality Index for Sound Cues", ClampMin = "-1", ClampMax = "50"))
int32 SoundCueQualityIndex;
FPlatformRuntimeAudioCompressionOverrides();
// Get singleton containing default settings for compression.
static FPlatformRuntimeAudioCompressionOverrides* GetDefaultCompressionOverrides()
{
if (DefaultCompressionOverrides == nullptr)
{
DefaultCompressionOverrides = new FPlatformRuntimeAudioCompressionOverrides();
}
return DefaultCompressionOverrides;
}
private:
static FPlatformRuntimeAudioCompressionOverrides* DefaultCompressionOverrides;
};