UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IWaveformTransformation.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "HAL/Platform.h"
10#include "UObject/Object.h"
12#include "UObject/ObjectPtr.h"
14
15#include "IWaveformTransformation.generated.h"
16
17class USoundWave;
18
19namespace Audio
20{
21 // information about the current state of the wave file we are transforming
30
32 {
33 None = 0,
34 Low,
35 High
36 };
37
38 /*
39 * Base class for the object that processes waveform data
40 * Pass tweakable variables from its paired settings UObject in the constructor in UWaveformTransformationBase::CreateTransformation
41 *
42 * note: WaveTransformation vs WaveformTransformation is to prevent UHT class name conflicts without having to namespace everything - remember this in derived classes!
43 */
45 {
46 public:
47
48 // Applies the transformation to the waveform and modifies WaveInfo with the resulting changes
50
51 virtual bool SupportsRealtimePreview() const { return false; }
53 virtual bool CanChangeChannelCount() const { return false; }
54
56 };
57
59}
60
61// Struct defining a cue point in a sound wave asset
62USTRUCT(BlueprintType)
64{
66
67 // Unique identifier for the wave cue point
68 UPROPERTY(Category = Info, VisibleAnywhere, BlueprintReadOnly)
69 int32 CuePointID = INDEX_NONE;
70
71 // The label for the cue point
72 UPROPERTY(Category = Info, EditAnywhere, BlueprintReadOnly)
73 FString Label;
74
75 // The frame position of the cue point
76 UPROPERTY(Category = Info, EditAnywhere, BlueprintReadOnly, meta = (ClampMin = 0))
77 int64 FramePosition = 0;
78
79 // The frame length of the cue point (non-zero if it's a region)
80 UPROPERTY(Category = Info, EditAnywhere, BlueprintReadOnly, meta = (ClampMin = 0))
81 int64 FrameLength = 0;
82
83 bool IsLoopRegion() const { return bIsLoopRegion; }
84 void SetLoopRegion(bool value) { bIsLoopRegion = value; }
85
86#if WITH_EDITORONLY_DATA
87 void ScaleFrameValues(float Factor)
88 {
89 FramePosition = FMath::FloorToInt64((float)FramePosition * Factor);
90 FrameLength = FMath::FloorToInt64((float)FrameLength * Factor);
91 }
92#endif // WITH_EDITORONLY_DATA
93
94 friend class USoundFactory;
95 friend class USoundWave;
96
97protected:
98 // intentionally kept private.
99 // only USoundFactory should modify this value on import
100 UPROPERTY(Category = Info, EditAnywhere, BlueprintReadOnly)
101 bool bIsLoopRegion = false;
102};
103
104// Information about the the wave file we are transforming for Transformation UObjects
106{
108 float SampleRate = 0;
109 float StartTime = 0.f;
110 float EndTime = -1.f;
111 TArray<FSoundWaveCuePoint> WaveCues; // List of cues parsed from the wave file
112 bool bIsPreviewingLoopRegion = false;
113 bool bCachedSoundWaveLoopState = false;
114};
115
116#if WITH_EDITORONLY_DATA
117// Information to be retrieved from each transformation (Add members as needed when new transformation types are added)
119{
120 TArray<FSoundWaveCuePoint> AllCuePoints; // Cue Points and Loop Regions
121 TArray<FSoundWaveCuePoint> AllCuePointsRelativeToStartTime; // Cue Points and Loop Regions offset by start time
122};
123#endif //WITH_EDITORONLY_DATA
124
125// Base class to hold editor configurable properties for an arbitrary transformation of audio waveform data
126UCLASS(Abstract, EditInlineNew, MinimalAPI)
128{
130
131public:
132 virtual Audio::FTransformationPtr CreateTransformation() const { return nullptr; }
134 virtual void OverwriteTransformation() {};
136
137 // Sort to ensure proper order of operation for audio processing
139 {
141 {
143 {
144 return false;
145 }
146 else if (TransformationA && !TransformationB)
147 {
148 return true;
149 }
150
151 return TransformationA->GetTransformationPriority() > TransformationB->GetTransformationPriority();
152 });
153 }
154
155#if WITH_EDITOR
158
159 AUDIOEXTENSIONS_API virtual void PostEditUndo() override;
160 AUDIOEXTENSIONS_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
161
162 void NotifyPropertyChange(FProperty* Property);
163#endif //WITH_EDITOR
164
165 virtual bool IsEditorOnly() const override { return true; }
166
167
168 // Execute when the soundwave needs a recook to apply new transformation changes, bool flag if it should mark the file dirty
171
172 // Execute when only the rendering needs to be updated, but can wait for a recook
175};
176
177// Object that holds an ordered list of transformations to perform on a sound wave
178UCLASS(EditInlineNew, MinimalAPI)
180{
182
183public:
184 UPROPERTY(EditAnywhere, Instanced, Category = "Transformations")
186
187 virtual bool IsEditorOnly() const override { return true; }
188
189 AUDIOEXTENSIONS_API TArray<Audio::FTransformationPtr> CreateTransformations() const;
190};
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IWaveformTransformation.h:45
virtual bool SupportsRealtimePreview() const
Definition IWaveformTransformation.h:51
virtual bool CanChangeChannelCount() const
Definition IWaveformTransformation.h:53
virtual constexpr ETransformationPriority FileChangeLengthPriority() const
Definition IWaveformTransformation.h:52
virtual void ProcessAudio(FWaveformTransformationWaveInfo &InOutWaveInfo) const
Definition IWaveformTransformation.h:49
virtual ~IWaveTransformation()
Definition IWaveformTransformation.h:55
Definition UnrealType.h:174
Definition UniquePtr.h:107
Definition Object.h:95
Definition SoundWave.h:417
int32 SampleRate
Definition SoundWave.h:799
int32 NumChannels
Definition SoundWave.h:774
Definition IWaveformTransformation.h:128
virtual bool IsEditorOnly() const override
Definition IWaveformTransformation.h:165
virtual void UpdateConfiguration(FWaveTransformUObjectConfiguration &InOutConfiguration)
Definition IWaveformTransformation.h:133
static void SortTransformationsArray(TArray< TObjectPtr< UWaveformTransformationBase > > &InOutTransformations)
Definition IWaveformTransformation.h:138
virtual constexpr Audio::ETransformationPriority GetTransformationPriority() const
Definition IWaveformTransformation.h:135
FOnTransformationChanged OnTransformationChanged
Definition IWaveformTransformation.h:170
DECLARE_DELEGATE_OneParam(FOnTransformationChanged, bool)
DECLARE_DELEGATE(FOnTransformationRenderChanged)
virtual void OverwriteTransformation()
Definition IWaveformTransformation.h:134
FOnTransformationRenderChanged OnTransformationRenderChanged
Definition IWaveformTransformation.h:174
virtual Audio::FTransformationPtr CreateTransformation() const
Definition IWaveformTransformation.h:132
Definition IWaveformTransformation.h:180
UE_REWRITE void Sort(RangeType &&Range)
Definition Sort.h:16
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
ETransformationPriority
Definition IWaveformTransformation.h:32
@ false
Definition radaudio_common.h:23
Definition IWaveformTransformation.h:23
float SampleRate
Definition IWaveformTransformation.h:24
uint32 StartFrameOffset
Definition IWaveformTransformation.h:27
uint32 NumEditedSamples
Definition IWaveformTransformation.h:28
int32 NumChannels
Definition IWaveformTransformation.h:25
Definition UnrealType.h:6865
Definition IWaveformTransformation.h:64
void SetLoopRegion(bool value)
Definition IWaveformTransformation.h:84
Definition IWaveformTransformation.h:106
TArray< FSoundWaveCuePoint > WaveCues
Definition IWaveformTransformation.h:111
Definition ObjectPtr.h:488