UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AudioDebug.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5
6#include "AudioDefines.h" // For ENABLE_AUDIO_DEBUG
7#include "Audio.h"
8
9namespace Audio
10{
11 // enum shortener for logging.
12 inline const TCHAR* ShortEnumString(const TCHAR* InString)
13 {
14 if (const TCHAR* DoubleColon = FCString::Strstr(InString, TEXT("::")))
15 {
16 return DoubleColon + 2;
17 }
18 return InString;
19 }
20
21#if UE_BUILD_SHIPPING
22 inline bool MatchesLogFilter(const TCHAR* InName) { return false; } // Off for shipping.
23#else
24 ENGINE_API bool MatchesLogFilter(const TCHAR* InName);
25#endif // UE_BUILD_SHIPPING
26
27 inline bool MatchesLogFilter(const FName& InName)
28 {
29#if UE_BUILD_SHIPPING
30 return false; // Off for shipping.
31#else
32 return MatchesLogFilter(*InName.ToString());
33#endif //
34 }
35}
36
37#if ENABLE_AUDIO_DEBUG
38
39 // Forward Declarations
40struct FActiveSound;
42struct FListener;
43struct FWaveInstance;
44
45class FSoundSource;
46class FViewportClient;
47class USoundWave;
48class UWorld;
49
50
51namespace Audio
52{
53 namespace DebugStatNames
54 {
55 ENGINE_API extern const FName SoundWaves;
56 ENGINE_API extern const FName SoundCues;
57 ENGINE_API extern const FName Sounds;
58 ENGINE_API extern const FName SoundMixes;
59 ENGINE_API extern const FName SoundModulation;
60 ENGINE_API extern const FName SoundReverb;
61 ENGINE_API extern const FName AudioStreaming;
62
63 // TODO: Move to console variables
64 ENGINE_API extern const FName DebugSounds;
65 ENGINE_API extern const FName LongSoundNames;
66 }
67
68 class FAudioDebugger
69 {
70 public:
72
74 struct FDebugNames
75 {
82
84 FString DebugSoundName;
85 bool bDebugSoundName;
86
89 {}
90 };
91
92 static ENGINE_API void DrawDebugInfo(const FSoundSource& SoundSource);
93 static ENGINE_API void DrawDebugInfo(const FActiveSound& ActiveSound, const TArray<FWaveInstance*>& ThisSoundsWaveInstances, const float DeltaTime);
94 static ENGINE_API void DrawDebugInfo(UWorld& World, const TArray<FListener>& Listeners);
95 static ENGINE_API void DrawDebugInfo(const FAudioVirtualLoop& VirtualLoop);
96 static ENGINE_API int32 DrawDebugStats(UWorld& World, FViewport* Viewport, FCanvas* Canvas, int32 Y);
98 static ENGINE_API bool PostStatModulatorHelp(UWorld* World, FCommonViewportClient* ViewportClient, const TCHAR* Stream);
99 static ENGINE_API int32 RenderStatCues(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y);
100 static ENGINE_API int32 RenderStatMixes(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y);
101 static ENGINE_API int32 RenderStatModulators(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y, const FVector* ViewLocation, const FRotator* ViewRotation);
102 static ENGINE_API int32 RenderStatReverb(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y);
103 static ENGINE_API int32 RenderStatSounds(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y);
104 static ENGINE_API int32 RenderStatWaves(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y);
105 static ENGINE_API int32 RenderStatStreaming(UWorld* World, FViewport* Viewport, FCanvas* Canvas, int32 X, int32 Y, const FVector* ViewLocation, const FRotator* ViewRotation);
106 static ENGINE_API void RemoveDevice(const FAudioDevice& AudioDevice);
107 static ENGINE_API void ResolveDesiredStats(FViewportClient* ViewportClient);
108 static ENGINE_API void SendUpdateResultsToGameThread(const FAudioDevice& AudioDevice, const int32 FirstActiveIndex);
109 static ENGINE_API void UpdateAudibleInactiveSounds(const uint32 FirstIndex, const TArray<FWaveInstance*>& WaveInstances);
112 static ENGINE_API void SetStats(const TSet<FName>& StatsToToggle, UWorld* InWorld);
113
115
117 ENGINE_API bool IsMuteOrSoloActive() const;
118 ENGINE_API void DumpActiveSounds() const;
119
120 ENGINE_API bool IsVisualizeDebug3dEnabled() const;
122
123#if WITH_EDITOR
124 static ENGINE_API void OnBeginPIE();
125 static ENGINE_API void OnEndPIE();
126#endif // WITH_EDITOR
127
128 // Evaluate Mute/Solos
129 ENGINE_API void QuerySoloMuteSoundClass(const FString& Name, bool& bOutIsSoloed, bool& bOutIsMuted, FString& OutReason) const;
130 ENGINE_API void QuerySoloMuteSoundWave(const FString& Name, bool& bOutIsSoloed, bool& bOutIsMuted, FString& OutReason) const;
131 ENGINE_API void QuerySoloMuteSoundCue(const FString& Name, bool& bOutIsSoloed, bool& bOutIsMuted, FString& OutReason) const;
132
133 // Is Mute/Solos. (only audio thread).
134 bool IsSoloSoundClass(FName InName) const { return DebugNames.SoloSoundClass.Contains(InName); }
135 bool IsSoloSoundWave(FName InName) const { return DebugNames.SoloSoundWave.Contains(InName); }
136 bool IsSoloSoundCue(FName InName) const { return DebugNames.SoloSoundCue.Contains(InName); }
137 bool IsMuteSoundClass(FName InName) const { return DebugNames.MuteSoundClass.Contains(InName); }
138 bool IsMuteSoundWave(FName InName) const { return DebugNames.MuteSoundWave.Contains(InName); }
139 bool IsMuteSoundCue(FName InName) const { return DebugNames.MuteSoundCue.Contains(InName); }
140
141 // Mute/Solos toggles. (any thread). (If exclusive, toggle-on will clear everything first, and toggle-off will clear all).
142 void ToggleSoloSoundClass(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.SoloSoundClass, bExclusive); }
143 void ToggleSoloSoundWave(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.SoloSoundWave, bExclusive); }
144 void ToggleSoloSoundCue(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.SoloSoundCue, bExclusive); }
145 void ToggleMuteSoundClass(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.MuteSoundClass, bExclusive); }
146 void ToggleMuteSoundWave(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.MuteSoundWave, bExclusive); }
147 void ToggleMuteSoundCue(FName InName, bool bExclusive = false) { ToggleNameArray(InName, DebugNames.MuteSoundCue, bExclusive); }
148
149 // Set Mute/Solo. (any thread).
150 void SetMuteSoundCue(FName InName, bool bInOnOff) { SetNameArray(InName, DebugNames.MuteSoundCue, bInOnOff); }
151 void SetMuteSoundWave(FName InName, bool bInOnOff) { SetNameArray(InName, DebugNames.MuteSoundWave, bInOnOff); }
152 void SetSoloSoundCue(FName InName, bool bInOnOff) { SetNameArray(InName, DebugNames.SoloSoundCue, bInOnOff); }
153 void SetSoloSoundWave(FName InName, bool bInOnOff) { SetNameArray(InName, DebugNames.SoloSoundWave, bInOnOff); }
154
155 ENGINE_API void SetAudioMixerDebugSound(const TCHAR* SoundName);
156 ENGINE_API void SetAudioDebugSound(const TCHAR* SoundName);
157
158 ENGINE_API const FString& GetAudioMixerDebugSoundName() const;
160
161 private:
164 ENGINE_API void ToggleNameArray(FName InName, TArray<FName>& NameArray, bool bExclusive);
166
168 const FString& Name, const TArray<FName>& Solos, const TArray<FName>& Mutes,
169 bool& bOutIsSoloed, bool& bOutIsMuted, FString& OutReason) const;
170
171 ENGINE_API void ClearStats(FDeviceId DeviceId, FName StatsToClear);
172
173 ENGINE_API void SetStats(FDeviceId DeviceId, const TSet<FName>& StatsToSet);
174
176 ENGINE_API void ToggleStats(FDeviceId DeviceId, const TSet<FName>& StatsToToggle);
177
179
181 FDebugNames DebugNames;
182
185 };
186} // namespace Audio
187#endif // ENABLE_AUDIO_DEBUG
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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
#define X(Name, Desc)
Definition FormatStringSan.h:47
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AudioDevice.h:417
Definition CanvasTypes.h:211
Definition ViewportClient.h:417
Definition IDelegateInstance.h:14
Definition NameTypes.h:617
CORE_API FString ToString() const
Definition UnrealNames.cpp:3537
Definition Audio.h:627
Definition ViewportClient.h:28
Definition UnrealClient.h:412
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SoundWave.h:417
Definition World.h:918
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
const TCHAR * ShortEnumString(const TCHAR *InString)
Definition AudioDebug.h:12
ENGINE_API bool MatchesLogFilter(const TCHAR *InName)
@ false
Definition radaudio_common.h:23
Definition ActiveSound.h:283
Definition AudioVirtualLoop.h:13
Definition AudioDevice.h:156
Definition Audio.h:180
static UE_FORCEINLINE_HINT const CharType * Strstr(const CharType *String, const CharType *Find)
Definition CString.h:1066