UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SoundWave.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
9#include "CoreMinimal.h"
11#include "Sound/AudioSettings.h"
14#include "Misc/Guid.h"
15#include "Async/AsyncWork.h"
16#include "Async/Mutex.h"
17#include "Async/UniqueLock.h"
18#include "Sound/SoundBase.h"
24#include "Sound/SoundGroups.h"
26#include "UObject/ObjectKey.h"
27#include "AudioMixerTypes.h"
30#include "ContentStreaming.h"
34#include "Templates/DontCopy.h"
35#include "SoundWave.generated.h"
36
37class FSoundWaveData;
38class ITargetPlatform;
39enum EAudioSpeakers : int;
40struct FActiveSound;
43
44UENUM()
55
57{
58#define CASE_TO_STRING(X) case X: return TEXT(#X);
59 switch(InType)
60 {
62 default: break;
63 }
64 return TEXT("Unknown");
65#undef CASE_TO_STRING
66}
67
72UENUM()
78
81{
84 Done
85};
86
88
93{
95 void Serialize(FArchive& Ar, UObject* Owner, int32 ChunkIndex);
96
98 bool GetCopy(void** OutChunkData);
99
100 /* Moves the memory out of the byte bulk-data. (Does copy with Discard original) */
102
105
108
111
114
115private:
116 uint8* CachedDataPtr{ nullptr };
117
118public:
119
120#if WITH_EDITORONLY_DATA
122 FString DerivedDataKey;
123
125 bool bLoadedFromCookedPackage = false;
126
128 bool bInlineChunk = false;
129
134 uint32 StoreInDerivedDataCache(const FString& InDerivedDataKey, const FStringView& SoundWaveName);
135#endif // #if WITH_EDITORONLY_DATA
136};
137
141USTRUCT()
143{
145
146
147 FName AudioFormat;
150
151#if WITH_EDITORONLY_DATA
153 FString DerivedDataKey;
158#endif // #if WITH_EDITORONLY_DATA
159
162
165
173 ENGINE_API int32 GetChunkFromDDC(int32 ChunkIndex, uint8** OutChunkData, bool bMakeSureChunkIsLoaded = false);
174
177
179 ENGINE_API int32 GetNumChunks() const;
180
182 ENGINE_API FName GetAudioFormat() const;
183
185 ENGINE_API void Serialize(FArchive& Ar, class USoundWave* Owner);
186
187#if WITH_EDITORONLY_DATA
189 ENGINE_API void FinishCache();
190 ENGINE_API bool IsFinishedCache() const;
191 ENGINE_API bool IsAsyncWorkComplete() const;
192 ENGINE_API bool IsCompiling() const;
194
195 UE_DEPRECATED(5.0, "Use AreDerivedChunksAvailable with the context instead.")
197
199#endif // WITH_EDITORONLY_DATA
200
201private:
202#if WITH_EDITORONLY_DATA
203 friend class USoundWave;
208#endif
209
218 ENGINE_API int32 DeserializeChunkFromDDC(TArray<uint8> SerializedData, FStreamedAudioChunk &ChunkToDeserializeInto, int32 ChunkIndex, uint8** &OutChunkData);
219};
220
221USTRUCT(BlueprintType)
223{
225
226 // The frequency (in Hz) of the spectrum value
227 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
228 float FrequencyHz = 0.0f;
229
230 // The magnitude of the spectrum at this frequency
231 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
232 float Magnitude = 0.0f;
233
234 // The normalized magnitude of the spectrum at this frequency
235 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
236 float NormalizedMagnitude = 0.0f;
237};
238
239USTRUCT(BlueprintType)
241{
243
244 // The array of current spectral data for this sound wave
245 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
247
248 // The current playback time of this sound wave
249 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
250 float PlaybackTime = 0.0f;
251
252 // The sound wave this spectral data is associated with
253 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SpectralData")
255};
256
257USTRUCT(BlueprintType)
259{
261
262 // The current envelope of the playing sound
263 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvelopeData")
264 float Envelope = 0.0f;
265
266 // The current playback time of this sound wave
267 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvelopeData")
268 float PlaybackTime = 0.0f;
269
270 // The sound wave this envelope data is associated with
271 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnvelopeData")
273};
274
275// Sort predicate for sorting spectral data by frequency (lowest first)
277{
279 {
280 return A.FrequencyHz < B.FrequencyHz;
281 }
282};
283
284
285// Struct used to store spectral data with time-stamps
286USTRUCT()
288{
290
291 // The magnitude of the spectrum at this frequency
292 UPROPERTY()
293 float Magnitude = 0.0f;
294
295 // The normalized magnitude of the spectrum at this frequency
296 UPROPERTY()
297 float NormalizedMagnitude = 0.0f;
298};
299
300
301// Struct used to store spectral data with time-stamps
302USTRUCT()
304{
306
307 // The spectral data at the given time. The array indices correspond to the frequencies set to analyze.
308 UPROPERTY()
310
311 // The timestamp associated with this spectral data
312 UPROPERTY()
313 float TimeSec = 0.0f;
314};
315
316// Struct used to store time-stamped envelope data
317USTRUCT()
319{
321
322 // The normalized linear amplitude of the audio
323 UPROPERTY()
324 float Amplitude = 0.0f;
325
326 // The timestamp of the audio
327 UPROPERTY()
328 float TimeSec = 0.0f;
329};
330
331// The FFT size (in audio frames) to use for baked FFT analysis
332UENUM(BlueprintType)
341
342// Sound Asset Compression Type
343UENUM(BlueprintType)
345{
346 // Perceptual-based codec which supports all features across all platforms.
347 BinkAudio,
348
349 // Will encode the asset using ADPCM, a time-domain codec that has fixed-sized quality and about ~4x compression ratio, but is relatively cheap to decode.
350 ADPCM,
351
352 // Uncompressed audio. Large memory usage (streamed chunks contain less audio per chunk) but extremely cheap to decode and supports all features.
353 PCM,
354
355 // Opus is a highly versatile audio codec. It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications.
356 Opus,
357
358 // Encodes the asset to a platform specific format and will be different depending on the platform. It does not currently support seeking.
360
361 // The project defines the codec used for this asset.
363
364 // As BinkAudio, except better quality. Comparable CPU usage. Only valid sample rates are: 48000, 44100, 32000, and 24000.
365 RADAudio UMETA(DisplayName = "RAD Audio"),
366};
367
368
369namespace Audio
370{
372 {
373 switch (InDecoderType)
374 {
375 case ESoundAssetCompressionType::RADAudio: return NAME_RADA;
382 default:
383 ensure(false);
384 return TEXT("UNKNOWN");
385 }
386 }
387
403}
404
406{
408 virtual ~ISoundWaveClient() {}
409
410 // OnBeginDestroy() returns true to unsubscribe as an ISoundWaveClient
411 virtual bool OnBeginDestroy(class USoundWave* Wave) = 0;
412 virtual bool OnIsReadyForFinishDestroy(class USoundWave* Wave) const = 0;
413 virtual void OnFinishDestroy(class USoundWave* Wave) = 0;
414};
415UCLASS(hidecategories=Object, editinlinenew, BlueprintType, meta= (LoadBehavior = "LazyOnDemand"), MinimalAPI)
417{
419
420private:
421
423 UPROPERTY(Config, EditAnywhere, Category = "Format|Quality", meta = (DisplayName = "Compression", ClampMin = "1", ClampMax = "100", EditCondition = "SoundAssetCompressionType != ESoundAssetCompressionType::PCM && SoundAssetCompressionType != ESoundAssetCompressionType::ADPCM"), AssetRegistrySearchable)
424 int32 CompressionQuality;
425
426public:
427
428 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "5.0 - Property is deprecated. Streaming priority has no effect with stream caching enabled."))
430
435 UPROPERTY(EditAnywhere, Category = "Format|Quality")
437
439 TEnumAsByte<EDecompressionType> DecompressionType;
440
441 UPROPERTY(EditAnywhere, Category = Sound, meta = (DisplayName = "Group"))
443
445 UPROPERTY(EditAnywhere, Category = Sound, AssetRegistrySearchable)
446 uint8 bLooping : 1;
447
449 UPROPERTY()
450 uint8 bStreaming : 1;
451
452private:
453
454 // Deprecated compression type properties
455 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "5.0 - Property is deprecated. bSeekableStreaming now means ADPCM codec in SoundAssetCompressionType."))
456 uint8 bSeekableStreaming : 1;
457
458 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "5.0 - Property is deprecated. bUseBinkAudio now means Bink codec in SoundAssetCompressionType."))
459 uint8 bUseBinkAudio : 1;
460
462 UPROPERTY(Config, EditAnywhere, Category = "Format", AssetRegistrySearchable)
464
465public:
466 void AddPlayingSource()
467 {
468 NumSourcesPlaying.Increment();
469 }
470
472 {
473 check(NumSourcesPlaying.GetValue() > 0);
474 NumSourcesPlaying.Decrement();
475 }
476
478 UFUNCTION(BlueprintPure, Category = "Audio")
479 ENGINE_API ESoundAssetCompressionType GetSoundAssetCompressionType() const;
480
482 ENGINE_API ESoundAssetCompressionType GetSoundAssetCompressionTypeEnum() const;
483
485 UFUNCTION(BlueprintCallable, Category = "Audio")
486 ENGINE_API void SetSoundAssetCompressionType(ESoundAssetCompressionType InSoundAssetCompressionType, bool bMarkDirty = true);
487
489 UFUNCTION(BlueprintCallable, Category = "Audio")
490 ENGINE_API TArray<FSoundWaveCuePoint> GetCuePoints() const;
491 ENGINE_API void SetAllCuePoints(TArray<FSoundWaveCuePoint> InCuePoints) const;
492
493#if WITH_EDITOR
496
499
501 ENGINE_API void SetLoudnessValues(const float InLUFS, const float InSamplePeakDB);
502#endif //WITH_EDITOR
503
505 UFUNCTION(BlueprintCallable, Category = "Audio")
506 ENGINE_API TArray<FSoundWaveCuePoint> GetLoopRegions() const;
507
509 ENGINE_API FName GetRuntimeFormat() const;
510
516 ENGINE_API void ResetInvalidTemplateArguments();
517
518private:
519 // cached proxy
520 FSoundWaveProxyPtr Proxy{ nullptr };
521
522public:
523
525
526#if WITH_EDITORONLY_DATA
528 UPROPERTY(EditAnywhere, Category = "Analysis")
530
535 UPROPERTY(EditAnywhere, Category = "Analysis")
537
539 UPROPERTY(EditAnywhere, Category = "Analysis|FFT")
541
543 UPROPERTY(EditAnywhere, Category = "Analysis|Envelope")
545
547 UPROPERTY(EditAnywhere, Category = "Analysis|FFT", meta = (EditCondition = "bEnableBakedFFTAnalysis"))
548 ESoundWaveFFTSize FFTSize;
549
551 UPROPERTY(EditAnywhere, Category = "Analysis|FFT", meta = (EditCondition = "bEnableBakedFFTAnalysis", ClampMin = "512", UIMin = "512"))
553
555 UPROPERTY(EditAnywhere, Category = "Analysis|FFT", meta = (EditCondition = "bEnableBakedFFTAnalysis", ClampMin = "0", UIMin = "0"))
557
559 UPROPERTY(EditAnywhere, Category = "Analysis|FFT", meta = (EditCondition = "bEnableBakedFFTAnalysis", ClampMin = "0", UIMin = "0"))
561
563 UPROPERTY(EditAnywhere, Category = "Analysis|Envelope", meta = (EditCondition = "bEnableAmplitudeEnvelopeAnalysis", ClampMin = "512", UIMin = "512"))
565
567 UPROPERTY(EditAnywhere, Category = "Analysis|Envelope", meta = (EditCondition = "bEnableAmplitudeEnvelopeAnalysis", ClampMin = "0", UIMin = "0"))
568 int32 EnvelopeFollowerAttackTime;
569
571 UPROPERTY(EditAnywhere, Category = "Analysis|Envelope", meta = (EditCondition = "bEnableAmplitudeEnvelopeAnalysis", ClampMin = "0", UIMin = "0"))
572 int32 EnvelopeFollowerReleaseTime;
573#endif // WITH_EDITORONLY_DATA
574
576 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Modulation")
578
580 UPROPERTY(EditAnywhere, Category = "Analysis|FFT", meta = (EditCondition = "bEnableBakedFFTAnalysis"))
581 TArray<float> FrequenciesToAnalyze;
582
584 UPROPERTY()
585 TArray<FSoundWaveSpectralTimeData> CookedSpectralTimeData;
586
588 UPROPERTY()
589 TArray<FSoundWaveEnvelopeTimeData> CookedEnvelopeTimeData;
590
592 ENGINE_API bool GetInterpolatedCookedFFTDataForTime(float InTime, uint32& InOutLastIndex, TArray<FSoundWaveSpectralData>& OutData, bool bLoop);
593 ENGINE_API bool GetInterpolatedCookedEnvelopeDataForTime(float InTime, uint32& InOutLastIndex, float& OutAmplitude, bool bLoop);
594
598 ENGINE_API void GetHandleForChunkOfAudio(TFunction<void(FAudioChunkHandle&&)> OnLoadCompleted, bool bForceSync = false, int32 ChunkIndex = 1, ENamedThreads::Type CallbackThread = ENamedThreads::GameThread);
599
603 ENGINE_API void RetainCompressedAudio(bool bForceSync = false);
604
606 ENGINE_API void ReleaseCompressedAudio();
607
608 ENGINE_API bool IsRetainingAudio();
614 ENGINE_API void OverrideLoadingBehavior(ESoundWaveLoadingBehavior InLoadingBehavior);
615
620 ENGINE_API ESoundWaveLoadingBehavior GetLoadingBehavior(bool bCheckSoundClasses = true) const;
621
622#if WITH_EDITORONLY_DATA
624 UPROPERTY(AdvancedDisplay, meta = (DeprecatedProperty))
626#endif
627
628#if WITH_EDITOR
631 // Pass in a Transformations array to overwrite this soundwave with another soundwaves transformation data
634
635#endif
636
637private:
638
640 ENGINE_API uint32 GetInterpolatedCookedFFTDataForTimeInternal(float InTime, uint32 StartingIndex, TArray<FSoundWaveSpectralData>& OutData, bool bLoop);
641 ENGINE_API uint32 GetInterpolatedCookedEnvelopeDataForTimeInternal(float InTime, uint32 StartingIndex, float& OutAmplitude, bool bLoop);
642
644 FThreadSafeCounter PrecacheState;
645
646public:
649
650private:
651
652 TArray<FSoundWaveClientPtr> SourcesPlaying;
653
654 // This is the sample rate retrieved from platform settings.
655 mutable float CachedSampleRateOverride;
656
657 // We cache a soundwave's loading behavior on the first call to USoundWave::GetLoadingBehaviorForWave(true);
658 // Caches resolved loading behavior from the SoundClass graph. Must be called on the game thread.
659 ENGINE_API void CacheInheritedLoadingBehavior() const;
660
661 // Called when we change any properties about the underlying audio asset
662#if WITH_EDITOR
663 ENGINE_API void UpdateAsset(bool bMarkDirty = true);
664#endif
665
666public:
667
670
673
676
679
682
684 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Subtitles, AssetRegistrySearchable)
685 uint8 bMature : 1;
686
688 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Subtitles)
689 uint8 bManualWordWrap : 1;
690
692 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Subtitles)
693 uint8 bSingleLine : 1;
694
695#if WITH_EDITORONLY_DATA
696 UPROPERTY()
698#endif // WITH_EDITORONLY_DATA
699
703 UPROPERTY(EditAnywhere, Category = Format)
704 uint8 bIsAmbisonics : 1;
705
707 uint8 bDecompressedFromOgg : 1;
708
709#if WITH_EDITOR
711 std::atomic<int32> CurrentChunkRevision = 0;
712#endif
713
714private:
715
716 // This is set to false on initialization, then set to true on non-editor platforms when we cache appropriate sample rate.
717 mutable uint8 bCachedSampleRateFromPlatformSettings : 1;
718
719 // This is set when SetSampleRate is called to invalidate our cached sample rate while not re-parsing project settings.
720 uint8 bSampleRateManuallyReset : 1;
721
722#if WITH_EDITOR
723 // Whether or not the thumbnail supports generation
725
726 // Whether this asset is loaded from cooked data.
728#endif // !WITH_EDITOR
729
730 enum class ESoundWaveResourceState : uint8
731 {
732 NeedsFree,
733 Freeing,
734 Freed
735 };
736
737 ESoundWaveResourceState ResourceState : 2;
738
739public:
740 // Loading behavior members are lazily initialized in const getters
742 UPROPERTY(EditAnywhere, Category = "Loading", meta = (DisplayName = "Loading Behavior Override"))
744
745private:
747 mutable UE::FMutex SourcesPlayingCs;
748
749public:
750#if WITH_EDITORONLY_DATA
752 UPROPERTY(EditAnywhere, Category = Loading, meta = (UIMin = 0, UIMax = 10, EditCondition = "LoadingBehavior == ESoundWaveLoadingBehavior::RetainOnLoad || LoadingBehavior == ESoundWaveLoadingBehavior::PrimeOnLoad"), DisplayName="Size of First Audio Chunk (seconds)")
754#endif //WITH_EDITOR_ONLY_DATA
755
757 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "Use Subtitles instead."))
758 FString SpokenText_DEPRECATED;
759
761 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Subtitles)
762 float SubtitlePriority;
763
765 UPROPERTY(Category = Sound, meta = (ClampMin = "0.0"), EditAnywhere)
766 float Volume;
767
769 UPROPERTY(Category = Sound, meta = (ClampMin = "0.125", ClampMax = "4.0"), EditAnywhere)
770 float Pitch;
771
773 UPROPERTY(Category = Info, AssetRegistrySearchable, VisibleAnywhere)
774 int32 NumChannels;
775
776#if WITH_EDITORONLY_DATA
778 UPROPERTY()
780
782 UPROPERTY()
784
786 UPROPERTY(Category = Info, AssetRegistrySearchable, VisibleAnywhere)
787 float LUFS;
788
790 UPROPERTY(Category = Info, AssetRegistrySearchable, VisibleAnywhere)
791 float SamplePeakDB;
792
793#endif // WITH_EDITORONLY_DATA
794
795protected:
796
798 UPROPERTY(Category = Info, AssetRegistrySearchable, VisibleAnywhere)
799 int32 SampleRate;
800
801#if WITH_EDITORONLY_DATA
803 UPROPERTY(Category = Info, AssetRegistrySearchable, VisibleAnywhere)
805
807 UPROPERTY(Category = Info, VisibleAnywhere, BlueprintGetter = GetCuePoints)
809
813 UPROPERTY(Category = Info, EditAnywhere)
815#endif
816
817 ENGINE_API virtual void SerializeCuePoints(FArchive& Ar, const bool bIsLoadingFromCookedArchive);
818
819public:
820
821 // Returns the compression quality of the sound asset.
822 ENGINE_API int32 GetCompressionQuality() const;
823
826
827 ENGINE_API int32 GetResourceSize() const;
828
831
835 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Subtitles)
837
838#if WITH_EDITORONLY_DATA
840 UPROPERTY(EditAnywhere, Category = Subtitles)
841 FString Comment;
842
843#endif // WITH_EDITORONLY_DATA
844
845#if WITH_EDITORONLY_DATA
846
848 UPROPERTY(VisibleAnywhere, Category = Info)
849 FSoundWaveTimecodeInfo TimecodeInfo;
850
851#endif // WITH_EDITORONLY_DATA
852
853#if WITH_EDITORONLY_DATA
854 UPROPERTY()
856
857 UPROPERTY()
859
860 UPROPERTY(VisibleAnywhere, Instanced, Category = ImportSettings)
862
863#endif // WITH_EDITORONLY_DATA
864
865protected:
866
868 UPROPERTY(EditAnywhere, Category = SoundWave, AdvancedDisplay)
869 TObjectPtr<class UCurveTable> Curves;
870
872 UPROPERTY()
873 TObjectPtr<class UCurveTable> InternalCurves;
874
875#if WITH_EDITORONLY_DATA
876protected:
878 UPROPERTY(EditAnywhere, Category = "Format", Meta=(DisplayName="Enable cloud streaming", DisplayAfter="SoundAssetCompressionType", EditCondition = "LoadingBehavior != ESoundWaveLoadingBehavior::ForceInline"), AssetRegistrySearchable)
881 UPROPERTY(EditAnywhere, config, Category="Platform specific", Meta=(DisplayName="Platform specific settings", ToolTip="Optionally disables cloud streaming per platform"))
883public:
885 ENGINE_API void SetCloudStreamingEnabled(bool bEnabled);
891#endif // WITH_EDITORONLY_DATA
892
893public:
897 static ENGINE_API ITargetPlatform* GetRunningPlatform();
898
900 static ENGINE_API const TCHAR* GetDefaultLoadingBehaviorCVarName();
901
902 static ENGINE_API ESoundWaveLoadingBehavior GetDefaultLoadingBehavior();
903
907
910
913
916
919
922public:
923 ENGINE_API const uint8* GetResourceData() const;
924
925#if WITH_EDITORONLY_DATA
938 {
940
941 // The container soundwave for this raw data. This must be non-null for any non-metadata instances.
942 // We need this in order to parse the multichannel layout of the raw data - and we also use this
943 // in place of the BulkData Owner parameter in many places because many call sites pass null incorrectly,
944 // resulting in the bulk data not being correlated with our asset.
946
947 enum class EPayloadFlags : uint8
948 {
949 None,
951 };
952
954 : RawData()
955 , SoundWave()
956 {
957 }
958
960 {
962 }
963
964 ENGINE_API void CreateFromBulkData(FBulkData& InBulkData, const FGuid& InGuid, UObject* Owner);
966 ENGINE_API TFuture<FSharedBuffer> GetPayload(const EPayloadFlags Flags = EPayloadFlags::None) const;
967 ENGINE_API bool HasPayloadData() const;
968 ENGINE_API void UpdatePayload(FSharedBuffer InPayload, UObject* Owner = nullptr);
969
970 //
971 // Deprecated unused API forwarding for potential backwards compatability issues.
972 // As the raw data needs to be converted before use or storage, always access it via the above functions.
973 //
974#pragma region Deprecated Pass Thru
975 UE_DEPRECATED(5.4, "CreateLegacyUniqueIdentifier is provided just for API backwards compatibility.")
976 void CreateLegacyUniqueIdentifier(UObject* Owner)
977 {
978 RawData.CreateLegacyUniqueIdentifier(Owner);
979 }
980 UE_DEPRECATED(5.4, "Reset is provided just for API backwards compatibility.")
981 void Reset()
982 {
983 RawData.Reset();
984 }
985 UE_DEPRECATED(5.4, "UnloadData is provided just for API backwards compatibility.")
986 void UnloadData()
987 {
988 RawData.UnloadData();
989 }
990 UE_DEPRECATED(5.4, "DetachFromDisk is provided just for API backwards compatibility.")
991 void DetachFromDisk(FArchive* Ar, bool bEnsurePayloadIsLoaded)
992 {
993 RawData.DetachFromDisk(Ar, bEnsurePayloadIsLoaded);
994 }
995 UE_DEPRECATED(5.4, "GetIdentifier is provided just for API backwards compatibility.")
996 FGuid GetIdentifier() const
997 {
998 return RawData.GetIdentifier();
999 }
1000 UE_DEPRECATED(5.4, "GetPayloadId is provided just for API backwards compatibility.")
1001 const FIoHash& GetPayloadId() const
1002 {
1003 return RawData.GetPayloadId();
1004 }
1005 int64 GetPayloadSize() const
1006 {
1007 return RawData.GetPayloadSize();
1008 }
1009 UE_DEPRECATED(5.4, "DoesPayloadNeedLoading is provided just for API backwards compatibility.")
1010 bool DoesPayloadNeedLoading() const
1011 {
1012 return RawData.DoesPayloadNeedLoading();
1013 }
1014 UE_DEPRECATED(5.4, "GetCompressedPayload is provided just for API backwards compatibility.")
1015 TFuture<FCompressedBuffer> GetCompressedPayload() const
1016 {
1017 return RawData.GetCompressedPayload();
1018 }
1019 UE_DEPRECATED(5.4, "UpdatePayload is provided just for API backwards compatibility.")
1020 void UpdatePayload(FCompressedBuffer InPayload, UObject* Owner = nullptr)
1021 {
1022 RawData.UpdatePayload(InPayload, Owner);
1023 }
1024 UE_DEPRECATED(5.4, "UpdatePayload is provided just for API backwards compatibility.")
1025 void UpdatePayload(UE::Serialization::FEditorBulkData::FSharedBufferWithID InPayload, UObject* Owner = nullptr)
1026 {
1027 RawData.UpdatePayload(MoveTemp(InPayload), Owner);
1028 }
1029 UE_DEPRECATED(5.4, "SetCompressionOptions is provided just for API backwards compatibility.")
1030 void SetCompressionOptions(UE::Serialization::ECompressionOptions Option)
1031 {
1032 RawData.SetCompressionOptions(Option);
1033 }
1034 UE_DEPRECATED(5.4, "SetCompressionOptions is provided just for API backwards compatibility.")
1035 void SetCompressionOptions(ECompressedBufferCompressor Compressor, ECompressedBufferCompressionLevel CompressionLevel)
1036 {
1037 RawData.SetCompressionOptions(Compressor, CompressionLevel);
1038 }
1039 UE_DEPRECATED(5.4, "GetBulkDataVersions is provided just for API backwards compatibility.")
1041 {
1043 }
1044 UE_DEPRECATED(5.4, "TearOff is provided just for API backwards compatibility.")
1045 void TearOff()
1046 {
1047 RawData.TearOff();
1048 }
1049 UE_DEPRECATED(5.4, "CopyTornOff is provided just for API backwards compatibility.")
1050 UE::Serialization::FEditorBulkData CopyTornOff() const
1051 {
1052 return RawData.CopyTornOff();
1053 }
1054 UE_DEPRECATED(5.4, "SerializeForRegistry is provided just for API backwards compatibility.")
1055 void SerializeForRegistry(FArchive& Ar)
1056 {
1057 RawData.SerializeForRegistry(Ar);
1058 }
1059 UE_DEPRECATED(5.4, "CanSaveForRegistry is provided just for API backwards compatibility.")
1060 bool CanSaveForRegistry() const
1061 {
1062 return RawData.CanSaveForRegistry();
1063 }
1064 UE_DEPRECATED(5.4, "HasPlaceholderPayloadId is provided just for API backwards compatibility.")
1065 bool HasPlaceholderPayloadId() const
1066 {
1067 return RawData.HasPlaceholderPayloadId();
1068 }
1069 UE_DEPRECATED(5.4, "IsMemoryOnlyPayload is provided just for API backwards compatibility.")
1070 bool IsMemoryOnlyPayload() const
1071 {
1072 return RawData.IsMemoryOnlyPayload();
1073 }
1074 UE_DEPRECATED(5.4, "UpdatePayloadId is provided just for API backwards compatibility.")
1075 void UpdatePayloadId()
1076 {
1077 return RawData.UpdatePayloadId();
1078 }
1079 UE_DEPRECATED(5.4, "LocationMatches is provided just for API backwards compatibility.")
1080 bool LocationMatches(const UE::Serialization::FEditorBulkData& Other) const
1081 {
1082 return RawData.LocationMatches(Other);
1083 }
1084 UE_DEPRECATED(5.4, "UpdateRegistrationOwner is provided just for API backwards compatibility.")
1085 void UpdateRegistrationOwner(UObject* Owner)
1086 {
1087 RawData.UpdateRegistrationOwner(Owner);
1088 }
1089#pragma endregion
1090 } RawData;
1091
1096 UPROPERTY(EditAnywhere, Instanced, Category = "Waveform Processing")
1097 TArray<TObjectPtr<class UWaveformTransformationBase>> Transformations;
1098#endif
1099
1102
1103#if WITH_EDITORONLY_DATA
1105
1108
1109#endif // WITH_EDITORONLY_DATA
1111 TSortedMap<FString, FStreamedAudioPlatformData*> CookedPlatformData;
1112
1113 //~ Begin UObject Interface.
1114 ENGINE_API virtual void Serialize(FArchive& Ar) override;
1115 ENGINE_API virtual void PostInitProperties() override;
1116 ENGINE_API virtual bool IsReadyForFinishDestroy() override;
1117 ENGINE_API virtual void FinishDestroy() override;
1118 ENGINE_API virtual void PostLoad() override;
1119
1120 // Returns true if the zeroth chunk is loaded, or attempts to load it if not already loaded,
1121 // returning true if the load was successful. Can return false if either an error was encountered
1122 // in attempting to load the chunk or if stream caching is not enabled for the given sound.
1123 ENGINE_API bool LoadZerothChunk();
1124
1125 // Returns the amount of chunks this soundwave contains if it's streaming,
1126 // or zero if it is not a streaming source.
1127 ENGINE_API uint32 GetNumChunks() const;
1128
1129 ENGINE_API uint32 GetSizeOfChunk(uint32 ChunkIndex) const;
1130
1131 // Calculates audio streaming cache usage for this sound wave.
1132 // @param OutTotalBytesOfAudioData - The accumulated number of bytes of all audio data of all chunks for this sound wave.
1133 // @param OutMaxChunkBytesOfAudioData - The maximum number of bytes of audio data for all audio chunks for this sound wave.
1135
1136 ENGINE_API virtual void BeginDestroy() override;
1137#if WITH_EDITOR
1138 ENGINE_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
1139 ENGINE_API virtual bool CanEditChange(const FProperty* InProperty) const override;
1140
1142 ENGINE_API virtual bool IsCompiling() const override;
1145 ENGINE_API bool IsAsyncWorkComplete() const;
1146
1147 ENGINE_API void PostImport();
1148
1149 ENGINE_API virtual void PreSave(FObjectPreSaveContext SaveContext) override;
1150 ENGINE_API virtual void OnCookEvent(UE::Cook::ECookEvent CookEvent, UE::Cook::FCookEventContext& CookContext) override;
1151
1152private:
1153 friend class FSoundWaveCompilingManager;
1158
1161
1162public:
1163#endif // WITH_EDITOR
1164
1165#if WITH_EDITORONLY_DATA
1166 ENGINE_API TArray<Audio::FTransformationPtr> CreateTransformations() const;
1167#endif // WITH_EDITORONLY_DATA
1168
1169 ENGINE_API virtual void GetResourceSizeEx(FResourceSizeEx& CumulativeResourceSize) override;
1170 ENGINE_API virtual FName GetExporterName() override;
1171 ENGINE_API virtual FString GetDesc() override;
1172 ENGINE_API virtual void GetAssetRegistryTags(FAssetRegistryTagsContext Context) const override;
1173 UE_DEPRECATED(5.4, "Implement the version that takes FAssetRegistryTagsContext instead.")
1174 ENGINE_API virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override;
1175 //~ End UObject Interface.
1176
1177 //~ Begin USoundBase Interface.
1178 ENGINE_API virtual bool IsPlayable() const override;
1179 ENGINE_API virtual void Parse(class FAudioDevice* AudioDevice, const UPTRINT NodeWaveInstanceHash, FActiveSound& ActiveSound, const FSoundParseParameters& ParseParams, TArray<FWaveInstance*>& WaveInstances) override;
1180 ENGINE_API virtual float GetDuration() const override;
1181 ENGINE_API virtual float GetSubtitlePriority() const override;
1182 ENGINE_API virtual bool SupportsSubtitles() const override;
1183 ENGINE_API virtual bool GetSoundWavesWithCookedAnalysisData(TArray<USoundWave*>& OutSoundWaves) override;
1184 ENGINE_API virtual bool HasCookedFFTData() const override;
1185 ENGINE_API virtual bool HasCookedAmplitudeEnvelopeData() const override;
1186 virtual bool IsProcedurallyGenerated() const override { return bProcedural; }
1187 //~ End USoundBase Interface.
1188
1189 ENGINE_API FSoundWaveProxyPtr CreateSoundWaveProxy();
1190
1191 //~Begin IAudioProxyDataFactory Interface.
1192 ENGINE_API virtual TSharedPtr<Audio::IProxyData> CreateProxyData(const Audio::FProxyDataInitParams& InitParams) override;
1193 //~ End IAudioProxyDataFactory Interface.
1194
1195 // Called when the procedural sound wave begins on the render thread. Only used in the audio mixer and when bProcedural is true.
1196 virtual void OnBeginGenerate() {}
1197
1198 // Called when the procedural sound wave is done generating on the render thread. Only used in the audio mixer and when bProcedural is true..
1199 virtual void OnEndGenerate() {};
1200 virtual void OnEndGenerate(ISoundGeneratorPtr Generator) {};
1201
1202 ENGINE_API void AddPlayingSource(const FSoundWaveClientPtr& Source);
1203 ENGINE_API void RemovePlayingSource(const FSoundWaveClientPtr& Source);
1204
1206 {
1207 bool bIsGeneratingAudio = false;
1208 UE::TUniqueLock Lock(SourcesPlayingCs);
1209 bIsGeneratingAudio = SourcesPlaying.Num() > 0;
1210
1211 return bIsGeneratingAudio;
1212 }
1213
1215 {
1216#if WITH_EDITORONLY_DATA
1218#endif
1219 }
1220
1222 {
1223#if WITH_EDITORONLY_DATA
1224 return ImportedSampleRate;
1225#else
1226 return 0;
1227#endif
1228 }
1229
1230#if WITH_EDITORONLY_DATA
1233#endif //WITH_EDITORONLY_DATA
1234
1238 ENGINE_API void SetSampleRate(uint32 InSampleRate, const bool bFromDecoders=false);
1239
1243 ENGINE_API void SetNumFrames(uint32 InNumFrames);
1244
1248 ENGINE_API uint32 GetNumFrames() const;
1249
1255 ENGINE_API virtual int32 GetResourceSizeForFormat(FName Format);
1256
1262 ENGINE_API void FreeResources(bool bStopSoundsUsingThisResource = true);
1263
1265 ENGINE_API bool CleanupDecompressor(bool bForceCleanup = false);
1266
1270 ENGINE_API virtual void InitAudioResource(FByteBulkData& CompressedData);
1271
1278 ENGINE_API virtual bool InitAudioResource(FName Format);
1279
1283 ENGINE_API void RemoveAudioResource();
1284
1288 ENGINE_API FWaveInstance& HandleStart(FActiveSound& ActiveSound, const UPTRINT WaveInstanceHash) const;
1289
1296 virtual int32 GeneratePCMData(uint8* PCMData, const int32 SamplesNeeded) { ensure(false); return 0; }
1297
1305
1313 SIZE_T GetCompressedDataSize(FName Format, const FPlatformAudioCookOverrides* CompressionOverrides = GetPlatformCompressionOverridesForCurrentPlatform())
1314 {
1315 FByteBulkData* Data = GetCompressedData(Format, CompressionOverrides);
1316 return Data ? Data->GetBulkDataSize() : 0;
1317 }
1318
1319 ENGINE_API virtual bool HasCompressedData(FName Format, ITargetPlatform* TargetPlatform = GetRunningPlatform()) const;
1320
1321#if WITH_EDITOR
1324
1327
1332
1333#endif //WITH_EDITOR
1334
1335
1336 static ENGINE_API FName GetPlatformSpecificFormat(FName Format, const FPlatformAudioCookOverrides* CompressionOverrides);
1337
1338private:
1339#if WITH_EDITOR
1340 // Removes any in-progress async loading data formats.
1342
1343 // Waits for audio rendering commands to execute
1344 ENGINE_API void FlushAudioRenderingCommands() const;
1345
1348
1350#endif //WITH_EDITOR
1351
1352public:
1353
1354#if WITH_EDITOR
1355 ENGINE_API void LogBakedData();
1356
1358 ENGINE_API bool IsCompressedDataReady(FName Format, const FPlatformAudioCookOverrides* CompressionOverrides) const;
1359
1361#endif //WITH_EDITOR
1362
1363 ENGINE_API virtual void BeginGetCompressedData(FName Format, const FPlatformAudioCookOverrides* CompressionOverrides, const ITargetPlatform* InTargetPlatform);
1364
1373 ENGINE_API virtual FByteBulkData* GetCompressedData(FName Format, const FPlatformAudioCookOverrides* CompressionOverrides = GetPlatformCompressionOverridesForCurrentPlatform(),
1374 const ITargetPlatform* InTargetPlatform = GetRunningPlatform());
1375
1380 ENGINE_API void InvalidateCompressedData(bool bFreeResources = false, bool bRebuildStreamingChunks = true);
1381
1383 virtual class UCurveTable* GetCurveData() const override { return Curves; }
1384
1385 // This function returns true if there are streamable chunks in this asset.
1386 ENGINE_API bool HasStreamingChunks();
1387
1388#if WITH_EDITOR
1392 class UCurveTable* GetInternalCurveData() const { return InternalCurves; }
1393
1395 bool HasInternalCurves() const { return InternalCurves != nullptr; }
1396
1398 void SetCurveData(UCurveTable* InCurves) { Curves = InCurves; }
1399
1401 void SetInternalCurveData(UCurveTable* InCurves) { InternalCurves = InCurves; }
1402
1404 static FName GetCurvePropertyName() { return GET_MEMBER_NAME_CHECKED(USoundWave, Curves); }
1405#endif // WITH_EDITOR
1406
1408public:
1409 ENGINE_API bool IsStreaming(const TCHAR* PlatformName = nullptr) const;
1410 ENGINE_API bool IsStreaming(const FPlatformAudioCookOverrides& Overrides) const;
1411
1416 ENGINE_API virtual bool IsSeekable() const;
1417
1421 ENGINE_API bool ShouldUseStreamCaching() const;
1422
1426 ENGINE_API TArrayView<const uint8> GetZerothChunk(bool bForImmediatePlayback = false);
1427
1431 ENGINE_API void UpdatePlatformData();
1432
1433 ENGINE_API void CleanupCachedRunningPlatformData();
1434
1438 ENGINE_API virtual void SerializeCookedPlatformData(class FArchive& Ar);
1439
1440 /*
1441 * Returns a sample rate if there is a specific sample rate override for this platform, -1.0 otherwise.
1442 */
1443 ENGINE_API float GetSampleRateForCurrentPlatform() const;
1444
1448 static ENGINE_API const FPlatformAudioCookOverrides* GetPlatformCompressionOverridesForCurrentPlatform();
1449
1450 /*
1451 * Returns a sample rate if there is a specific sample rate override for this platform, -1.0 otherwise.
1452 */
1453 ENGINE_API float GetSampleRateForCompressionOverrides(const FPlatformAudioCookOverrides* CompressionOverrides) const;
1454
1455 ENGINE_API void SetError(const TCHAR* InErrorMsg=nullptr);
1456 ENGINE_API void ResetError();
1457 ENGINE_API bool HasError() const;
1458
1459#if WITH_EDITORONLY_DATA
1460
1461#if WITH_EDITOR
1462
1463 /*
1464 * Used to determine the loading behavior that's applied by the owner of this wave. Will determine
1465 * the most appropriate loading behavior if there are multiple owners. If there is no owner "Unintialized"
1466 * will be returned. The results are cached in TMap below.
1467 */
1468 ISoundWaveLoadingBehaviorUtil::FClassData GetOwnerLoadingBehavior(const ITargetPlatform* InTargetPlatform) const;
1469
1472
1473 /*
1474 * Returns this SoundWave's CuePoints array with the frame values scaled by
1475 * InSampleRate / ImportedSampleRate to account for resampling of the sound wave source data.
1476 * If no resampling is necessary, returns the CuePoints as-is.
1477 *
1478 * @param InSampleRate The sample rate the SoundWave
1479 * @return CuePoints array scaled if resampling occurred
1480 */
1482
1483 /*
1484 * Modifies the InOutCuePoints array with the frame values scaled by
1485 * InSampleRate / ImportedSampleRate to account for resampling of the sound wave source data.
1486 * Does not modify InOutCuePoints if no resampling is necessary
1487 *
1488 * @param InSampleRate The sample rate the SoundWave
1489 * @param InOutCuePoints The CuePoints array to re-scale
1490 */
1492
1493 /*
1494 * Returns a sample rate if there is a specific sample rate override for this platform, -1.0 otherwise.
1495 */
1496 ENGINE_API float GetSampleRateForTargetPlatform(const ITargetPlatform* TargetPlatform);
1497
1499
1503 ENGINE_API virtual void BeginCacheForCookedPlatformData(const ITargetPlatform* TargetPlatform) override;
1504
1505 ENGINE_API virtual bool IsCachedCookedPlatformDataLoaded(const ITargetPlatform* TargetPlatform) override;
1506
1511 ENGINE_API virtual void ClearAllCachedCookedPlatformData() override;
1512
1513 ENGINE_API virtual void ClearCachedCookedPlatformData(const ITargetPlatform* TargetPlatform) override;
1514
1515 ENGINE_API virtual void WillNeverCacheCookedPlatformDataAgain() override;
1516
1517 ENGINE_API virtual bool GetRedrawThumbnail() const;
1518 ENGINE_API virtual void SetRedrawThumbnail(bool bInRedraw);
1519 ENGINE_API virtual bool CanVisualizeAsset() const;
1520
1521#endif // WITH_EDITOR
1522
1526 ENGINE_API virtual void CachePlatformData(bool bAsyncCache = false);
1527
1531 ENGINE_API virtual void BeginCachePlatformData();
1532
1536 ENGINE_API virtual void FinishCachePlatformData();
1537
1542#endif // WITH_EDITORONLY_DATA
1543
1549 ENGINE_API bool GetChunkData(int32 ChunkIndex, uint8** OutChunkData, bool bMakeSureChunkIsLoaded = false);
1550
1552 {
1553 PrecacheState.Set((int32)InState);
1554 }
1555
1557 {
1558 return (ESoundWavePrecacheState)PrecacheState.GetValue();
1559 }
1560
1561
1562private:
1564
1565 friend class FSoundWaveProxy;
1566 friend class USoundFactory;
1567};
1568
1569
1571{
1572public:
1574
1576 : bIsLooping(0)
1577 , bIsTemplate(0)
1578 , bIsStreaming(0)
1579 , bIsSeekable(0)
1580 , bShouldUseStreamCaching(0)
1581 , bLoadingBehaviorOverridden(0)
1582 , bHasError(0)
1585#endif //WITH_EDITOR
1586 {
1587 }
1588
1589 // dtor
1591
1592 // non-const arg for internal call to FAudioDevice::GetRuntimeFormat
1594
1596
1597 const FGuid& GetGUID() const { return WaveGuid; }
1598 const FName& GetFName() const { return NameCached; }
1599 const FName& GetPackageName() const { return PackageNameCached; }
1600 const FName& GetRuntimeFormat() const { return RuntimeFormat; }
1601 const FObjectKey& GetFObjectKey() const { return SoundWaveKeyCached; };
1602
1603 float GetSampleRate() const { return SampleRate; }
1604 uint32 GetNumChannels() const { return NumChannels; }
1605 const TArray<FSoundWaveCuePoint>& GetCuePoints() const { return CuePoints; }
1606 const TArray<FSoundWaveCuePoint>& GetLoopRegions() const { return LoopRegions; }
1608
1610 ENGINE_API uint32 GetSizeOfChunk(uint32 ChunkIndex) const;
1611 int32 GetNumFrames() const { return NumFrames; }
1612 float GetDuration() const { return Duration; }
1613
1615
1616 ENGINE_API void SetError(const TCHAR* InErrorMsg=nullptr);
1617 ENGINE_API bool HasError() const;
1618 ENGINE_API bool ResetError();
1619
1620 bool IsStreaming() const { return bIsStreaming; }
1621 ESoundAssetCompressionType GetSoundCompressionType() const { return SoundAssetCompressionType; }
1622 bool IsLooping() const { return bIsLooping; }
1623 bool ShouldUseStreamCaching() const { return bShouldUseStreamCaching; }
1624 bool IsSeekable() const { return bIsSeekable; }
1625 bool IsRetainingAudio() const { return FirstChunk.IsValid(); }
1626 bool WasLoadingBehaviorOverridden() const { return bLoadingBehaviorOverridden; }
1627 ESoundWaveLoadingBehavior GetLoadingBehavior() const { return LoadingBehavior; }
1628
1629 bool IsTemplate() const { return bIsTemplate; }
1630
1633
1634 ENGINE_API bool GetChunkData(int32 ChunkIndex, uint8** OutChunkData, bool bMakeSureChunkIsLoaded = false);
1635
1638
1641
1642 // Returns true if the zeroth chunk is loaded, or attempts to load it if not already loaded,
1643 // returning true if the load was successful. Can return false if either an error was encountered
1644 // in attempting to load the chunk or if stream caching is not enabled for the given sound.
1646
1647 #if WITH_EDITOR
1649 #endif // #if WITH_EDITOR
1650
1653
1654#if WITH_EDITORONLY_DATA
1655 ENGINE_API FString GetDerivedDataKey() const;
1657#endif // #if WITH_EDITORONLY_DATA
1658
1659 int32 GetResourceSize() { return ResourceSize; }
1660 const uint8* GetResourceData() const { return ResourceData.GetView().GetData(); }
1661 uint32 GetNumChannels() { return NumChannels; }
1662
1663 void SetSampleRate(const int32 InSampleRate) { SampleRate = static_cast<float>(InSampleRate); }
1664 void SetNumFrames(const int32 InNumFrames) { NumFrames = InNumFrames; }
1665
1666private:
1667 ENGINE_API void DiscardZerothChunkData();
1668
1669 ENGINE_API FName FindRuntimeFormat(const USoundWave&) const;
1670
1676 ENGINE_API void CacheRuntimeFormatDependentState(const FName InFormatName);
1677
1679 FBulkDataBuffer<uint8> ZerothChunkData;
1680#if WITH_EDITOR
1682#endif
1683
1684 /* Accessor to get the zeroth chunk which might perform additional work in editor to handle async tasks. */
1685 ENGINE_API FBulkDataBuffer<uint8>& GetZerothChunkData() const;
1686
1688 FStreamedAudioPlatformData RunningPlatformData;
1689
1690 FAudioChunkHandle FirstChunk;
1691
1692 FFormatContainer CompressedFormatData;
1693
1694 int32 ResourceSize = 0;
1695
1696 FBulkDataBuffer<uint8> ResourceData;
1697
1699
1700#if WITH_EDITORONLY_DATA
1701 // Set by CacheInheritedLoadingBehavior after traversing the Soundclass heirarchy
1703#endif //WITH_EDITORONLY_DATA
1704
1705#if WITH_EDITOR
1707#endif // #if WITH_EDITOR
1708
1709 FName NameCached;
1710 FName PackageNameCached;
1711 FName RuntimeFormat{ "FSoundWaveProxy_InvalidFormat" };
1712 FObjectKey SoundWaveKeyCached;
1714 TArray<FSoundWaveCuePoint> LoopRegions;
1716 FGuid WaveGuid;
1717
1718 float SampleRate = 0;
1719 float Duration = 0;
1720
1721 uint32 NumChannels = 0;
1722 int32 NumFrames = 0;
1723
1724 // shared flags
1725 uint8 bIsLooping : 1;
1726 uint8 bIsTemplate : 1;
1727 uint8 bIsStreaming : 1;
1728 uint8 bIsSeekable : 1;
1729 uint8 bShouldUseStreamCaching : 1;
1730 uint8 bLoadingBehaviorOverridden : 1;
1731 uint8 bHasError : 1;
1732
1733#if WITH_EDITOR
1735#endif //WITH_EDITOR
1736
1737 friend class USoundWave;
1738}; // class FSoundWaveData
1739
1741class FSoundWaveProxy : public Audio::TProxyData<FSoundWaveProxy>
1742{
1743public:
1745
1747
1749
1751
1752 // USoundWave Interface
1754
1755 // Returns true if the zeroth chunk is loaded, or attempts to load it if not already loaded,
1756 // returning true if the load was successful. Can return false if either an error was encountered
1757 // in attempting to load the chunk or if stream caching is not enabled for the given sound.
1759 ENGINE_API bool GetChunkData(int32 ChunkIndex, uint8** OutChunkData, bool bMakeSureChunkIsLoaded = false);
1760
1761 // Getters
1762 ENGINE_API const FName& GetFName() const;
1763 ENGINE_API const FName& GetPackageName() const;
1764 ENGINE_API const FName& GetRuntimeFormat() const;
1765 ENGINE_API const FObjectKey& GetFObjectKey() const;
1766
1767 ENGINE_API float GetDuration() const;
1768 ENGINE_API float GetSampleRate() const;
1769
1773 ENGINE_API uint32 GetSizeOfChunk(uint32 ChunkIndex) const;
1777
1778 ENGINE_API bool IsLooping() const;
1779 ENGINE_API bool IsTemplate() const;
1780 ENGINE_API bool IsStreaming() const;
1781 ENGINE_API bool IsRetainingAudio() const;
1783 ENGINE_API bool IsSeekable() const;
1787
1789
1791
1793
1795
1796
1797#if WITH_EDITOR
1799#endif // #if WITH_EDITOR
1800
1803
1804#if WITH_EDITORONLY_DATA
1805 ENGINE_API FString GetDerivedDataKey() const;
1806#endif // #if WITH_EDITORONLY_DATA
1807
1809 ENGINE_API const uint8* GetResourceData() const;
1810
1812
1814 {
1815 return InProxy.TypeHash;
1816 }
1817
1818private:
1820 uint32 TypeHash = uint32(INDEX_NONE);
1821};
1822
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
int Volume
Definition AndroidPlatformMisc.cpp:380
#define check(expr)
Definition AssertionMacros.h:314
#define GET_MEMBER_NAME_CHECKED(ClassName, MemberName)
Definition AssertionMacros.h:493
#define ensure( InExpression)
Definition AssertionMacros.h:464
void AsyncTask(ENamedThreads::Type Thread, TUniqueFunction< void()> Function)
Definition Async.cpp:54
ESoundwaveSampleRateSettings
Definition AudioCompressionSettings.h:15
EDefaultAudioCompressionType
Definition AudioSettings.h:56
EAudioSpeakers
Definition Audio.h:77
#define WITH_EDITOR
Definition Build.h:67
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::UPTRINT UPTRINT
An unsigned integer the same size as a pointer.
Definition Platform.h:1146
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
return true
Definition ExternalRpcRegistry.cpp:601
const size_t ChannelOffsets[4]
int32 ParseParams(const FString &ParamStr, TArray< FString > &OutArray)
Definition NativeJSScripting.cpp:193
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EQueuedWorkPriority
Definition QueuedThreadPool.h:14
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
ESoundGroup
Definition SoundGroups.h:11
ESoundWaveLoadingBehavior
Definition SoundWaveLoadingBehavior.h:24
#define CASE_TO_STRING(X)
ESoundWaveFFTSize
Definition SoundWave.h:334
ESoundAssetCompressionType
Definition SoundWave.h:345
constexpr uint64 InvalidAudioStreamCacheLookupID
Definition SoundWave.h:87
EDecompressionType
Definition SoundWave.h:46
@ DTYPE_Procedural
Definition SoundWave.h:50
@ DTYPE_Setup
Definition SoundWave.h:47
@ DTYPE_RealTime
Definition SoundWave.h:49
@ DTYPE_MAX
Definition SoundWave.h:53
@ DTYPE_Xenon
Definition SoundWave.h:51
@ DTYPE_Streaming
Definition SoundWave.h:52
@ DTYPE_Invalid
Definition SoundWave.h:48
const TCHAR * LexToString(const EDecompressionType InType)
Definition SoundWave.h:56
ESoundWavePrecacheState
Definition SoundWave.h:81
ESoundWaveCuePointOrigin
Definition SoundWave.h:74
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
if(Failed) console_printf("Failed.\n")
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IAudioProxyInitializer.h:106
Definition Archive.h:1208
Definition AssetRegistryTagsContext.h:98
Definition AsyncWork.h:585
Definition ContentStreaming.h:110
ENGINE_API bool IsValid() const
Definition ContentStreaming.cpp:1543
Definition AudioDevice.h:417
Definition BulkDataBuffer.h:16
const ViewType & GetView() const
Definition BulkDataBuffer.h:133
Definition BulkData.h:470
Definition CompressedBuffer.h:50
Definition CustomVersion.h:111
Definition BulkData.h:1139
Definition NameTypes.h:617
Definition ObjectSaveContext.h:244
Definition UnrealType.h:174
Definition QueuedThreadPool.h:105
Definition SharedBuffer.h:341
Definition SoundWave.h:1571
void SetNumFrames(const int32 InNumFrames)
Definition SoundWave.h:1664
ENGINE_API void OverrideRuntimeFormat(const FName &InRuntimeFormat)
Definition SoundWave.cpp:300
ENGINE_API void InitializeDataFromSoundWave(USoundWave &InWave)
Definition SoundWave.cpp:256
bool IsLooping() const
Definition SoundWave.h:1622
uint32 GetNumChannels()
Definition SoundWave.h:1661
int32 GetResourceSize()
Definition SoundWave.h:1659
const uint8 * GetResourceData() const
Definition SoundWave.h:1660
ESoundWaveLoadingBehavior GetLoadingBehavior() const
Definition SoundWave.h:1627
const TArray< FSoundWaveCuePoint > & GetCuePoints() const
Definition SoundWave.h:1605
ENGINE_API FByteBulkData * GetCompressedData(FName Format, const FPlatformAudioCookOverrides *CompressionOverrides=USoundWave::GetPlatformCompressionOverridesForCurrentPlatform())
Definition SoundWave.cpp:501
ENGINE_API FStreamedAudioChunk & GetChunk(uint32 ChunkIndex)
Definition SoundWave.cpp:694
ENGINE_API uint32 GetSizeOfChunk(uint32 ChunkIndex) const
Definition SoundWave.cpp:408
bool IsRetainingAudio() const
Definition SoundWave.h:1625
ENGINE_API bool IsZerothChunkDataLoaded() const
Definition SoundWave.cpp:551
ENGINE_API void SetError(const TCHAR *InErrorMsg=nullptr)
Definition SoundWave.cpp:480
ENGINE_API int32 FindChunkIndexForSeeking(uint32 InTimeInAudioFrames) const
Definition SoundWave.cpp:585
ENGINE_API bool HasCompressedData(FName Format, ITargetPlatform *TargetPlatform=USoundWave::GetRunningPlatform()) const
Definition SoundWave.cpp:430
ENGINE_API uint32 GetNumChunks() const
Definition SoundWave.cpp:371
ENGINE_API ~FSoundWaveData()
Definition SoundWave.cpp:232
const FName & GetFName() const
Definition SoundWave.h:1598
ENGINE_API int32 GetChunkFromDDC(int32 ChunkIndex, uint8 **OutChunkData, bool bMakeSureChunkIsLoaded)
Definition SoundWave.cpp:706
bool WasLoadingBehaviorOverridden() const
Definition SoundWave.h:1626
bool IsSeekable() const
Definition SoundWave.h:1624
ENGINE_API bool HasChunkSeekTable(int32 InChunkIndex) const
Definition SoundWave.cpp:575
void SetSampleRate(const int32 InSampleRate)
Definition SoundWave.h:1663
bool IsStreaming() const
Definition SoundWave.h:1620
ENGINE_API bool GetChunkData(int32 ChunkIndex, uint8 **OutChunkData, bool bMakeSureChunkIsLoaded=false)
Definition SoundWave.cpp:523
bool ShouldUseStreamCaching() const
Definition SoundWave.h:1623
ENGINE_API void ReleaseCompressedAudio()
Definition SoundWave.cpp:423
FSoundWaveData()
Definition SoundWave.h:1575
const FGuid & GetGUID() const
Definition SoundWave.h:1597
ENGINE_API bool HasError() const
Definition SoundWave.cpp:489
const FName & GetRuntimeFormat() const
Definition SoundWave.h:1600
const FName & GetPackageName() const
Definition SoundWave.h:1599
float GetSampleRate() const
Definition SoundWave.h:1603
ENGINE_API const TArrayView< uint8 > GetZerothChunkDataView() const
Definition SoundWave.cpp:568
ENGINE_API bool ResetError()
Definition SoundWave.cpp:494
bool IsTemplate() const
Definition SoundWave.h:1629
int32 GetNumFrames() const
Definition SoundWave.h:1611
UE_NONCOPYABLE(FSoundWaveData)
ESoundAssetCompressionType GetSoundCompressionType() const
Definition SoundWave.h:1621
const FObjectKey & GetFObjectKey() const
Definition SoundWave.h:1601
float GetDuration() const
Definition SoundWave.h:1612
void SetAllCuePoints(const TArray< FSoundWaveCuePoint > &InCuePoints)
Definition SoundWave.cpp:390
uint32 GetNumChannels() const
Definition SoundWave.h:1604
ENGINE_API bool LoadZerothChunk()
Definition SoundWave.cpp:612
const TArray< FSoundWaveCuePoint > & GetLoopRegions() const
Definition SoundWave.h:1606
Definition SoundWave.h:1742
ENGINE_API const TArray< FSoundWaveCuePoint > GetCuePointsAndLoopRegions() const
Definition SoundWave.cpp:5398
ENGINE_API bool IsZerothChunkDataLoaded() const
Definition SoundWave.cpp:5452
ENGINE_API int32 GetResourceSize() const
Definition SoundWave.cpp:5290
IMPL_AUDIOPROXY_CLASS(FSoundWaveProxy)
ENGINE_API int32 GetChunkFromDDC(int32 ChunkIndex, uint8 **OutChunkData, bool bMakeSureChunkIsLoaded)
Definition SoundWave.cpp:5276
ENGINE_API FSoundWaveProxy(const FSoundWaveProxy &Other)
friend uint32 GetTypeHash(const FSoundWaveProxy &InProxy)
Definition SoundWave.h:1813
ENGINE_API void ReleaseCompressedAudio()
Definition SoundWave.cpp:5308
static ENGINE_API TArrayView< const uint8 > GetZerothChunk(const FSoundWaveProxyPtr &SoundWaveProxy, bool bForImmediatePlayback=false)
Definition SoundWave.cpp:5488
ENGINE_API const uint8 * GetResourceData() const
Definition SoundWave.cpp:5296
ENGINE_API bool IsLooping() const
Definition SoundWave.cpp:5415
ENGINE_API const TArrayView< uint8 > GetZerothChunkDataView() const
Definition SoundWave.cpp:5476
ENGINE_API const TArray< FSoundWaveCuePoint > & GetLoopRegions() const
Definition SoundWave.cpp:5392
ENGINE_API bool LoadZerothChunk()
Definition SoundWave.cpp:5314
ENGINE_API const FName & GetRuntimeFormat() const
Definition SoundWave.cpp:5338
ENGINE_API const FName & GetFName() const
Definition SoundWave.cpp:5326
ENGINE_API const TArray< FSoundWaveCuePoint > & GetCuePoints() const
Definition SoundWave.cpp:5386
ENGINE_API float GetDuration() const
Definition SoundWave.cpp:5350
ENGINE_API bool IsSeekable() const
Definition SoundWave.cpp:5445
ENGINE_API const FSoundWavePtr GetSoundWaveData()
Definition SoundWave.cpp:5302
ENGINE_API bool ShouldUseStreamCaching() const
Definition SoundWave.cpp:5439
ENGINE_API const FObjectKey & GetFObjectKey() const
Definition SoundWave.cpp:5344
ENGINE_API FByteBulkData * GetCompressedData(FName Format, const FPlatformAudioCookOverrides *CompressionOverrides=USoundWave::GetPlatformCompressionOverridesForCurrentPlatform())
Definition SoundWave.cpp:5482
ENGINE_API ~FSoundWaveProxy()
Definition SoundWave.cpp:5257
ENGINE_API bool HasCompressedData(FName Format, ITargetPlatform *TargetPlatform=USoundWave::GetRunningPlatform()) const
Definition SoundWave.cpp:5464
ENGINE_API float GetSampleRate() const
Definition SoundWave.cpp:5356
ENGINE_API const FName & GetPackageName() const
Definition SoundWave.cpp:5332
ENGINE_API FStreamedAudioChunk & GetChunk(uint32 ChunkIndex)
Definition SoundWave.cpp:5270
ENGINE_API bool IsStreaming() const
Definition SoundWave.cpp:5427
ENGINE_API bool WasLoadingBehaviorOverridden() const
Definition SoundWave.cpp:5458
ENGINE_API uint32 GetNumChannels() const
Definition SoundWave.cpp:5374
ENGINE_API ESoundWaveLoadingBehavior GetLoadingBehavior() const
Definition SoundWave.cpp:5470
ENGINE_API bool GetChunkData(int32 ChunkIndex, uint8 **OutChunkData, bool bMakeSureChunkIsLoaded=false)
Definition SoundWave.cpp:5320
ENGINE_API bool IsTemplate() const
Definition SoundWave.cpp:5421
ENGINE_API bool IsRetainingAudio() const
Definition SoundWave.cpp:5433
ENGINE_API uint32 GetNumChunks() const
Definition SoundWave.cpp:5368
ENGINE_API uint32 GetSizeOfChunk(uint32 ChunkIndex) const
Definition SoundWave.cpp:5380
ENGINE_API int32 GetNumFrames() const
Definition SoundWave.cpp:5362
Definition ThreadSafeCounter.h:14
int32 GetValue() const
Definition ThreadSafeCounter.h:120
int32 Set(int32 Value)
Definition ThreadSafeCounter.h:99
Definition IAudioProxyInitializer.h:128
Definition Interface_AsyncCompilation.h:21
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition EnumAsByte.h:22
Definition AndroidPlatformMisc.h:14
Definition Future.h:393
Definition IndirectArray.h:20
Definition UnrealString.h.inl:34
Definition AssetImportData.h:72
Definition CurveTable.h:43
Definition EditorBulkData.h:132
Definition UniqueLock.h:20
Definition Object.h:95
Definition SoundBase.h:109
Definition SoundWave.h:417
static ENGINE_API const FPlatformAudioCookOverrides * GetPlatformCompressionOverridesForCurrentPlatform()
Definition SoundWave.cpp:1674
uint8 bProcedural
Definition SoundWave.h:669
FGuid CompressedDataGuid
Definition SoundWave.h:1101
uint8 bDynamicResource
Definition SoundWave.h:681
virtual void OnEndGenerate(ISoundGeneratorPtr Generator)
Definition SoundWave.h:1200
bool IsGeneratingAudio() const
Definition SoundWave.h:1205
void SetImportedSampleRate(uint32 InImportedSampleRate)
Definition SoundWave.h:1214
virtual void OnBeginGenerate()
Definition SoundWave.h:1196
uint32 GetImportedSampleRate() const
Definition SoundWave.h:1221
void RemovePlayingSource()
Definition SoundWave.h:471
uint8 bCanProcessAsync
Definition SoundWave.h:678
int32 TrackedMemoryUsage
Definition SoundWave.h:830
int32 NumPrecacheFrames
Definition SoundWave.h:912
FAsyncAudioDecompress * AudioDecompressor
Definition SoundWave.h:906
virtual class UCurveTable * GetCurveData() const override
Definition SoundWave.h:1383
void SetPrecacheState(ESoundWavePrecacheState InState)
Definition SoundWave.h:1551
uint8 bIsSourceBus
Definition SoundWave.h:675
uint8 bRequiresStopFade
Definition SoundWave.h:672
virtual void OnEndGenerate()
Definition SoundWave.h:1199
virtual Audio::EAudioMixerStreamDataFormat::Type GetGeneratedPCMDataFormat() const
Definition SoundWave.h:1304
int32 RawPCMDataSize
Definition SoundWave.h:915
virtual int32 GeneratePCMData(uint8 *PCMData, const int32 SamplesNeeded)
Definition SoundWave.h:1296
ESoundWavePrecacheState GetPrecacheState() const
Definition SoundWave.h:1556
int32 ResourceID
Definition SoundWave.h:825
SIZE_T GetCompressedDataSize(FName Format, const FPlatformAudioCookOverrides *CompressionOverrides=GetPlatformCompressionOverridesForCurrentPlatform())
Definition SoundWave.h:1313
uint8 * CachedRealtimeFirstBuffer
Definition SoundWave.h:909
uint8 * RawPCMData
Definition SoundWave.h:918
static ENGINE_API ITargetPlatform * GetRunningPlatform()
Definition SoundWave.cpp:803
FAsyncTask< class FAsyncAudioDecompressWorker > FAsyncAudioDecompress
Definition SoundWave.h:905
FThreadSafeCounter NumSourcesPlaying
Definition SoundWave.h:648
Definition IWaveformTransformation.h:128
Definition Adpcm.cpp:7
Type
Definition AudioMixerTypes.h:11
@ Int16
Definition AudioMixerTypes.h:14
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
FName NAME_ADPCM(TEXT("ADPCM"))
FName NAME_PLATFORM_SPECIFIC(TEXT("PLATFORM_SPECIFIC"))
FName NAME_OPUS(TEXT("OPUS"))
FName NAME_PCM(TEXT("PCM"))
FName NAME_PROJECT_DEFINED(TEXT("PROJECT_DEFINED"))
ESoundAssetCompressionType ToSoundAssetCompressionType(EDefaultAudioCompressionType InDefaultCompressionType)
Definition SoundWave.h:388
FName ToName(ESoundAssetCompressionType InDecoderType)
Definition SoundWave.h:371
FName NAME_BINKA(TEXT("BINKA"))
FName NAME_RADA(TEXT("RADA"))
Definition TaskGraph.cpp:63
IMAGECORE_API int NumChannels(Type Format)
Definition ImageCore.cpp:1452
ECompressor
Definition OodleDataCompression.h:49
ECompressionLevel
Definition OodleDataCompression.h:94
int
Definition TestServer.py:515
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition IAudioProxyInitializer.h:119
Definition ActiveSound.h:283
Definition SoundWave.h:277
bool operator()(const FSoundWaveSpectralData &A, const FSoundWaveSpectralData &B) const
Definition SoundWave.h:278
Definition Guid.h:109
Definition IoHash.h:33
Definition ObjectKey.h:19
Definition ObjectVersion.h:762
Definition PerPlatformProperties.h:304
Definition AudioCompressionSettings.h:61
Definition UnrealType.h:6865
Definition ResourceSize.h:31
Definition SoundModulationDestination.h:134
Definition ActiveSound.h:64
Definition ISoundWaveCloudStreaming.h:98
Definition IWaveformTransformation.h:64
Definition SoundWave.h:259
Definition SoundWave.h:319
Definition SoundWave.h:288
Definition SoundWave.h:241
Definition SoundWave.h:223
Definition SoundWave.h:304
Definition SoundWaveTimecodeInfo.h:10
Definition SoundWave.h:93
int32 DataSize
Definition SoundWave.h:104
uint32 SeekOffsetInAudioFrames
Definition SoundWave.h:110
FBulkDataBuffer< uint8 > MoveOutAsBuffer()
Definition SoundWave.cpp:945
bool GetCopy(void **OutChunkData)
Definition SoundWave.cpp:912
FByteBulkData BulkData
Definition SoundWave.h:113
int32 AudioDataSize
Definition SoundWave.h:107
Definition SoundWave.h:143
Definition EngineTypes.h:2097
Definition Audio.h:180
Definition IWaveformTransformation.h:106
Definition SoundWave.h:406
virtual bool OnIsReadyForFinishDestroy(class USoundWave *Wave) const =0
virtual ~ISoundWaveClient()
Definition SoundWave.h:408
virtual bool OnBeginDestroy(class USoundWave *Wave)=0
virtual void OnFinishDestroy(class USoundWave *Wave)=0
ISoundWaveClient()
Definition SoundWave.h:407
Definition DontCopy.h:13
Definition NumericLimits.h:41
Definition ObjectPtr.h:488
Definition Optional.h:131
Definition Object.h:827