Skip to content

Conversation

@EasySouls
Copy link
Owner

@EasySouls EasySouls commented Dec 7, 2025

Summary by CodeRabbit

New Features

  • Integrated comprehensive audio system with support for WAV file playback
  • Added 2D and 3D audio source components for game entities with full playback control
  • Introduced audio listener component for spatial audio configuration
  • Volume adjustment, mute, and playback controls accessible through editor and scripting interface
  • Audio asset management and drag-and-drop support in editor

✏️ Tip: You can customize this high-level summary in your review settings.

Integrated an `AudioManager` system into the `Kerberos` namespace to enable audio management functionality.

- Updated `Application.cpp` to create and initialize the `AudioManager`.
- Modified `Application.h` to include `AudioManager` and prevent copying/moving of the `Application` class.
- Introduced an abstract `AudioManager` interface with methods for initialization, updating, and shutdown.
- Added a `Sound` interface for audio playback and control.
- Implemented a Windows-specific `XAudio2AudioManager` using the XAudio2 library.
  - Handles initialization, resource management, and shutdown.
  - Ensures proper error handling and logging during initialization.
- Added platform-specific preprocessor directives for Windows compatibility.
- Updated the build system to include XAudio2 dependencies.
Updated `Log::Init` to use `stdout_color_sink_mt` for logging to standard output instead of standard error. Added a log message to indicate successful initialization of `XAudio2AudioManager`. Made a minor formatting adjustment in the `BuffersQueued` condition check.

Updated `KerberosScriptCoreLib.dll` and `KerberosScriptCoreLib.pdb` binaries to reflect changes in the codebase.
Introduced `ComputeInfo` to manage compute shader limits in
`GraphicsContext` and implemented querying of OpenGL compute
shader limits in `OpenGLContext`. Enhanced logging for OpenGL
information.

Improved audio resource management in `XAudio2AudioManager`
by fixing cleanup logic, adjusting log levels, and ensuring
proper error handling. Updated `AudioFormat` enum to use
`uint8_t`.

Marked `AssetsPanel` constructor as `explicit` to prevent
implicit conversions. Added `_isPlayingAudio` flag in `Player`
to prevent redundant audio play/stop calls.
Enhanced OpenGL logging and error handling:
- Added GLSL version logging in `OpenGLContext.cpp`.
- Improved debug message formatting in `OpenGLRendererAPI.cpp`.
- Refactored shader error handling in `OpenGLShader.cpp`:
  - Added assertions for unsupported shader types.
  - Improved shader linking error messages and fallback handling.
@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

Walkthrough

Audio system addition featuring an abstract AudioManager interface, Windows XAudio2 implementation, Sound asset type with loading/serialization, audio components for entities (AudioSource2D/3D, AudioListener), C# scripting bindings, and editor UI for audio asset management and component configuration.

Changes

Cohort / File(s) Summary
Core Audio System
Kerberos/src/Kerberos/Audio/AudioManager.h, AudioManager.cpp, Sound.h, Sound.cpp
Abstract AudioManager interface with pure virtual lifecycle and playback methods; Sound class deriving from Asset with play/stop/volume controls forwarding to AudioManager via Application singleton.
Audio Importer & Integration
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h, SoundImporter.cpp
New SoundImporter delegating to AudioManager for loading WAV files; two overloads handling AssetMetadata and filesystem paths.
Windows XAudio2 Backend
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h, XAudio2AudioManager.cpp
Full XAudio2-based audio manager with COM/XAudio2 initialization, WAV parsing, voice management, and per-sound volume/mute control.
Scene Audio Components
Kerberos/src/Kerberos/Scene/Components/AudioComponents.h, Kerberos/src/Kerberos/Scene/Scene.cpp, SceneSerializer.cpp
Three component structs (AudioSource2D/3D, AudioListener) with sound asset references and volume settings; Scene integration for component duplication, serialization, and AudioManager updates during runtime.
Asset System Updates
Kerberos/src/Kerberos/Assets/Asset.h, EditorAssetManager.cpp, AssetImporter.cpp
Sound asset type enum, .wav extension mapping, Sound asset registry support, and AssetImporter Sound case delegation.
Application Layer
Kerberos/src/Kerberos/Application.h, Application.cpp
AudioManager lifecycle (instantiation, Init, storage) and GetAudioManager() accessor; initial WAV load during initialization.
Scripting Support
Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp, KerberosScriptCoreLib/Source/InternalCalls.cs, Components.cs, Player.cs
Internal call bindings for AudioSource2D/3D component play/stop/volume/looping; C# component classes with forwarding methods; Player script audio state tracking.
Editor UI & Constants
KerberosEditor/src/Editor/AssetConstants.h, AssetsPanel.h, AssetsPanel.cpp, HierarchyPanel.cpp, EditorLayer.cpp
Asset browser constants for drag-and-drop payloads; audio component UI in hierarchy panel with sound asset selection, loop/volume controls; asset panel audio file handling.
Graphics & Platform Utilities
Kerberos/src/Kerberos/Renderer/GraphicsContext.h, Kerberos/src/Platform/OpenGL/OpenGLContext.h, OpenGLContext.cpp, OpenGLShader.cpp, OpenGLRendererAPI.cpp, Kerberos/src/Platform/Vulkan/VulkanContext.h, VulkanContext.cpp, Kerberos/src/Kerberos/Utils/PlatformUtils.h, WindowsPlatformUtils.cpp, Log.cpp
ComputeInfo struct and query methods in graphics contexts; Vulkan buffer device address accessor; FileOperations Delete and RevealInFileExplorer methods; OpenGL shader refactoring and debug logging enhancements; console output redirected to stdout.
Configuration & Data
Kerberos.sln.DotSettings.user, premake5.lua, imgui.ini, KerberosEditor/assets/AssetRegistry.kbrar, KerberosEditor/assets/scenes/Example.kerberos
ReSharper dictionary entries (ADPCM, Openg, shaderc); XAudio2.lib added to build config; UI layout adjustments; example scene restructured with audio listener, camera, lights, and environment assets.

Sequence Diagram

sequenceDiagram
    participant Editor as Editor/Scene
    participant App as Application
    participant SI as ScriptInterface
    participant AM as AudioManager
    participant XA as XAudio2Backend
    participant Voice as XAudio2 Voice

    Editor->>App: Initialize
    App->>AM: Create() & Init()
    AM->>XA: Initialize XAudio2 & Master Voice
    
    Editor->>SI: Load Sound Asset
    SI->>AM: Load(filepath)
    AM->>XA: ParseWAV & Create Buffer
    XA-->>AM: Return Sound Object
    AM-->>SI: Return Ref<Sound>
    SI-->>Editor: Asset Ready

    Editor->>SI: Play Audio (via Script/Component)
    SI->>AM: Play(soundID)
    AM->>XA: CreateSourceVoice & SubmitBuffer
    XA->>Voice: Play Audio Data
    Voice-->>XA: Playing
    
    Editor->>SI: Volume Control (SetVolume)
    SI->>AM: SetVolume(soundID, volume)
    AM->>Voice: SetVolume(volume)
    
    App->>AM: Update() [per frame]
    AM->>XA: Update Playing Voices
    XA->>Voice: Check Completion & Cleanup
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • XAudio2AudioManager implementation: Dense logic for WAV file parsing (RIFF/WAVE chunk handling), COM initialization, voice management, and error handling patterns warrant careful review.
  • Scene integration: Multiple new component types, serialization/deserialization paths, and entity duplication logic require verification of data flow and lifecycle correctness.
  • ScriptInterface bindings: Internal call registrations and component forwarding need validation to ensure proper entity ID resolution and state management.
  • Asset system changes: New Sound asset type propagation through importer, manager, and editor layers should be checked for consistency.
  • Editor UI interactions: Audio component property editing in hierarchy panel and drag-and-drop payload handling in asset panel need UI state verification.

Possibly related PRs

  • PR #11: Extends the audio subsystem foundation with additional AudioManager methods and scene-level audio management enhancements.
  • PR #16: Modifies asset importing patterns similarly, adding new importer types and asset registry support alongside other asset handlers.
  • PR #5: Updates AssetsPanel and asset drag-and-drop payload handling, sharing the same editor UI integration patterns.

Suggested labels

Editor

Poem

🎵 Hear the engine sing with sound,
Audio waves spinning 'round,
From XAudio2 down below,
Components make the music flow—
A bunny's code, crisp and bright,
Sets the speakers just right! 🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.27% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely summarizes the main objective: integrating audio functionality using XAudio2, which is the primary theme across the majority of changes in this comprehensive audio system implementation.
✨ Finishing touches
  • 📝 Docstrings were successfully generated.
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch audio

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 17

Note

Due to the large number of review comments, Critical, Major severity comments were prioritized as inline comments.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
KerberosEditor/src/Editor/HierarchyPanel.cpp (1)

1458-1461: Bug: Wrong component removed for TextComponent.

Line 1460 removes EnvironmentComponent instead of TextComponent when the delete action is triggered in the Text component section.

         if (componentDeleted)
         {
-            entity.RemoveComponent<EnvironmentComponent>();
+            entity.RemoveComponent<TextComponent>();
         }
🟡 Minor comments (14)
Kerberos.sln.DotSettings.user-18-18 (1)

18-18: Check whether Openg is a typo

Openg looks like a misspelling (maybe OpenGL or Opengl). Whitelisting it here will hide that typo in inspections. Please confirm the intended identifier and adjust the dictionary entry (and any usage) accordingly.

Kerberos/src/Platform/OpenGL/OpenGLShader.cpp-681-698 (1)

681-698: Typo in error message: "OpengGL" should be "OpenGL".

The enhanced error handling logic is good, but there's a typo on line 689.

 		else
 		{
-			KBR_CORE_ERROR("Shader linking failed ({0}): No OpengGL info log was provided!", m_FilePath);
+			KBR_CORE_ERROR("Shader linking failed ({0}): No OpenGL info log was provided!", m_FilePath);
 		}
Kerberos/src/Platform/OpenGL/OpenGLRendererAPI.cpp-17-46 (1)

17-46: Enhanced debug formatting improves diagnostics.

The refactored OpenGL message callback now provides much richer context by prefixing source and type information before the actual GL message. The implementation correctly handles all GL debug source and type enumerations with appropriate fallback assertions.

However, this OpenGL debugging enhancement appears unrelated to the audio integration PR.

Kerberos/src/Platform/OpenGL/OpenGLContext.cpp-57-91 (1)

57-91: OpenGL compute info changes unrelated to audio integration.

This entire compute shader limits feature appears unrelated to the PR's stated objective of integrating XAudio2 for audio. Consider moving these OpenGL enhancements to a separate PR for better change isolation and review focus.

Kerberos/src/Platform/OpenGL/OpenGLContext.h-17-18 (1)

17-18: Declaration looks good, but unrelated to audio integration.

The QueryComputeInfo() method declaration is correctly placed in the private section. However, this OpenGL compute shader functionality appears unrelated to the audio integration described in the PR objectives.

KerberosScriptCoreLib/Source/Kerberos/Player.cs-16-17 (1)

16-17: Incomplete comment - clarify or remove.

The comment at line 16 appears incomplete: "Implement OnXButtonClicked methods for". Please complete the thought or remove this fragment if it's no longer relevant.

Kerberos/src/Kerberos/Utils/PlatformUtils.h-30-30 (1)

30-30: Typo: "give" should be "given".

-		* @brief Opens the give file with the default application associated with the file type.
+		* @brief Opens the given file with the default application associated with the file type.
Kerberos/src/Platform/Windows/WindowsPlatformUtils.cpp-87-101 (1)

87-101: Log message inconsistency with method name.

Line 91 logs "FileOperations::DeleteFile called..." but the method is named Delete. Update for consistency.

-		KBR_CORE_WARN("FileOperations::DeleteFile called with an empty path.");
+		KBR_CORE_WARN("FileOperations::Delete called with an empty path.");
KerberosEditor/src/Editor/AssetsPanel.cpp-113-118 (1)

113-118: Unused [[nodiscard]] result from Delete.

The return value from FileOperations::Delete is stored but never used. Since Delete is marked [[nodiscard]], handle the failure case (e.g., show notification to user).

 				if (ImGui::MenuItem("Delete"))
 				{
-					const bool success = FileOperations::Delete((m_AssetsDirectory / item).string().c_str());
+					if (!FileOperations::Delete((m_AssetsDirectory / item).string().c_str()))
+					{
+						KBR_CORE_ERROR("Failed to delete asset: {0}", item.string());
+					}
+					else
+					{
+						RefreshAssetTree();
+					}
 				}
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp-14-17 (1)

14-17: Potential null pointer dereference if initialization order is not guaranteed.

GetAudioManager() can return nullptr and is dereferenced without a check. While AudioManager is initialized during Application construction, this code assumes the audio system is always initialized before asset loading. Consider adding a null check for defensive programming, though note this pattern exists throughout the codebase (Sound.cpp, Scene.cpp).

Kerberos/src/Kerberos/Scene/Scene.cpp-120-121 (1)

120-121: Consider null-checking AudioManager before calling Update.

If GetAudioManager() returns nullptr (e.g., audio initialization failed), this will cause a null pointer dereference.

-            Application::Get().GetAudioManager()->Update();
+            if (auto* audioManager = Application::Get().GetAudioManager())
+                audioManager->Update();
Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp-252-262 (1)

252-262: Copy-paste error: variable named textComponent for audio component.

The variable on line 257 is named textComponent but holds an AudioSource2DComponent. This appears in multiple functions.

-		const AudioSource2DComponent& textComponent = entity.GetComponent<AudioSource2DComponent>();
-		if (textComponent.SoundAsset)
+		const AudioSource2DComponent& audioComponent = entity.GetComponent<AudioSource2DComponent>();
+		if (audioComponent.SoundAsset)
 		{
-			textComponent.SoundAsset->Play();
+			audioComponent.SoundAsset->Play();
 		}

Same issue appears in AudioSource2DComponent_Stop (line 269), AudioSource3DComponent_Play (line 318), and AudioSource3DComponent_Stop (line 330).

Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp-39-49 (1)

39-49: XAUDIO2_DEBUG_CONFIGURATION struct not zero-initialized.

The struct may contain additional fields that are left uninitialized, potentially causing unexpected debug behavior.

 #ifdef KBR_DEBUG
-		XAUDIO2_DEBUG_CONFIGURATION debugConfig;
+		XAUDIO2_DEBUG_CONFIGURATION debugConfig = {};
 		debugConfig.TraceMask = XAUDIO2_LOG_ERRORS;
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp-8-11 (1)

8-11: Destructor calling Shutdown() can cause double cleanup.

If Shutdown() is called explicitly before destruction, the destructor will call it again. While guards exist (if (m_MasteringVoice), if (m_XAudio2)), CoUninitialize() will be called unconditionally on line 92, potentially causing issues if COM wasn't initialized or was already uninitialized.

Consider tracking initialization state:

+	bool m_Initialized = false;
+
 	void XAudio2AudioManager::Shutdown() 
 	{
+		if (!m_Initialized)
+			return;
+		m_Initialized = false;
+
 		if (m_MasteringVoice)

And set m_Initialized = true at the end of Init().

Committable suggestion skipped: line range outside the PR's diff.

🧹 Nitpick comments (15)
Kerberos.sln.DotSettings.user (1)

1-30: Consider excluding .DotSettings.user from version control

This is a JetBrains per-user settings file; teams often ignore these (e.g., via .gitignore) to avoid noisy, user-specific diffs. If you don’t rely on sharing these settings, consider dropping it from the repo or moving shared dictionary entries into a non-.user settings file instead.

Kerberos/src/Platform/OpenGL/OpenGLShader.cpp (1)

794-802: descriptorCount is computed but never used.

The descriptorCount variable is calculated inside the if-block but isn't included in the trace output on line 802, unlike the sampled_images section (line 774) which logs the count. Either include it in the trace for consistency, or remove the unused computation.

 		for (const auto& resource : resources.storage_images)
 		{
 			uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
 			uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
+			uint32_t descriptorCount = 1;
 			const spirv_cross::SPIRType& type = compiler.get_type(resource.base_type_id);
 			if (!type.array.empty())
 			{
-				uint32_t descriptorCount = type.array[0];
+				descriptorCount = type.array[0];
 				if (descriptorCount == 0)
-					//descriptorCount = VulkanContext::Get().GetCapabilities().maxStorageImageAllocationCount; // Or some max
 					descriptorCount = 1; // Default to 1 if unsized
 			}
 
-			KBR_CORE_TRACE("      Name: {0}, Set: {1}, Binding: {2}", resource.name, set, binding);
+			KBR_CORE_TRACE("      Name: {0}, Set: {1}, Binding: {2}, Count: {3}", resource.name, set, binding, descriptorCount);
 		}
Kerberos/src/Platform/OpenGL/OpenGLContext.cpp (1)

26-29: Consider using spaces instead of tabs for log alignment.

The logging statements use tab characters for alignment, which may render inconsistently across different console configurations. Consider using spaces for predictable alignment.

Kerberos/src/Kerberos/Application.h (1)

65-65: Consider returning a reference or using smart pointer semantics.

Returning a raw pointer for GetAudioManager() exposes ownership ambiguity. Since callers should not own or delete this pointer, consider returning a reference (if AudioManager is guaranteed to exist) or documenting ownership clearly.

If AudioManager is always guaranteed to be initialized after construction:

-    AudioManager* GetAudioManager() const { return m_AudioManager; }
+    AudioManager& GetAudioManager() const { return *m_AudioManager; }

This makes the API clearer that callers get a non-owning reference, though it requires ensuring m_AudioManager is never null when accessed.

Kerberos/src/Kerberos/Audio/AudioManager.cpp (1)

11-19: Clarify ownership semantics for raw pointer.

The Create() factory returns a raw pointer, which transfers ownership to the caller. Consider documenting this explicitly or using std::unique_ptr<AudioManager> to make ownership transfer clear and prevent potential memory leaks.

Additionally, the implementation only supports Windows (XAudio2). Ensure other platforms are tracked in your roadmap or add a compile-time error for clarity.

Consider this alternative using smart pointers:

-	AudioManager* AudioManager::Create() 
+	std::unique_ptr<AudioManager> AudioManager::Create() 
 	{
 	#ifdef KBR_PLATFORM_WINDOWS
-		return new XAudio2AudioManager();
+		return std::make_unique<XAudio2AudioManager>();
 	#endif
 
 	KBR_CORE_ASSERT(false, "No AudioManager implementation for this platform!");
 	return nullptr;
 }
KerberosEditor/src/EditorLayer.cpp (1)

32-32: LGTM - testing disabled for release.

Disabling the TESTING macro is appropriate for the release build. However, consider using a CMake/build configuration option instead of a source-level #define to make it easier for developers to toggle testing mode without modifying source files.

Kerberos/src/Kerberos/Scene/SceneSerializer.cpp (1)

789-809: Add asset handle validation for audio component deserialization to match the StaticMeshComponent pattern.

Audio components are loaded without validating the asset handle (lines 789-809), unlike StaticMeshComponent deserialization (lines 762-771) which checks meshHandle.IsValid() before loading. While audio components do handle null SoundAsset gracefully—as confirmed by null checks in HierarchyPanel.cpp and ScriptInterface.cpp—adding validation would ensure consistency across the codebase and provide clearer intent.

Apply the same pattern to both AudioSource3DComponent and AudioSource2DComponent:

 if (auto audioSource3DComponent = entity["AudioSource3DComponent"])
 {
 	auto& audioSource3D = deserializedEntity.AddComponent<AudioSource3DComponent>();
-	audioSource3D.SoundAsset = AssetManager::GetAsset<Sound>(AssetHandle(audioSource3DComponent["SoundAsset"].as<uint64_t>()));
+	const AssetHandle soundHandle = AssetHandle(audioSource3DComponent["SoundAsset"].as<uint64_t>());
+	if (soundHandle.IsValid())
+		audioSource3D.SoundAsset = AssetManager::GetAsset<Sound>(soundHandle);
 	audioSource3D.Loop = audioSource3DComponent["Loop"].as<bool>();
 	audioSource3D.Volume = audioSource3DComponent["Volume"].as<float>();
 }
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp (1)

9-12: Unused AssetHandle parameter.

The first parameter is unnamed and unused. If intentional (for interface conformance), consider adding [[maybe_unused]] or a comment to clarify.

-	Ref<Sound> SoundImporter::ImportSound(AssetHandle, const AssetMetadata& metadata) 
+	Ref<Sound> SoundImporter::ImportSound([[maybe_unused]] AssetHandle handle, const AssetMetadata& metadata) 
KerberosEditor/src/Editor/AssetsPanel.cpp (1)

377-405: Consider unifying asset type detection.

The code mixes extension-based detection (textures, meshes) with AssetType enum detection (sound). Since you're already querying assetType on line 377, consider using it consistently for all types to simplify maintenance.

-			if (extension == ".jpg" || extension == ".png" || extension == ".svg")
+			if (assetType == AssetType::Texture2D)
 			{
 				ImGui::SetDragDropPayload(ASSET_BROWSER_TEXTURE, &handle, sizeof(AssetHandle), ImGuiCond_Once);
 				// ...
 			}
-			else if (extension == ".kbrcubemap")
+			else if (assetType == AssetType::TextureCube)
 			{
 				// ...
 			}
-			else if (extension == ".obj")
+			else if (assetType == AssetType::Mesh)
 			{
 				// ...
 			}
KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (2)

116-121: Consider exposing Volume and Looping properties.

The InternalCalls class defines AudioSource2DComponent_SetVolume, AudioSource2DComponent_GetVolume, AudioSource2DComponent_SetLooping, and AudioSource2DComponent_IsLooping methods (per InternalCalls.cs lines 89-98), but these are not exposed in the C# component. This limits scripting capabilities.

 public class AudioSource2DComponent : Component
 {
     public void Play() => InternalCalls.AudioSource2DComponent_Play(Entity.ID);

     public void Stop() => InternalCalls.AudioSource2DComponent_Stop(Entity.ID);
+
+    public float Volume
+    {
+        get => InternalCalls.AudioSource2DComponent_GetVolume(Entity.ID);
+        set => InternalCalls.AudioSource2DComponent_SetVolume(Entity.ID, value);
+    }
+
+    public bool Looping
+    {
+        get => InternalCalls.AudioSource2DComponent_IsLooping(Entity.ID);
+        set => InternalCalls.AudioSource2DComponent_SetLooping(Entity.ID, value);
+    }
 }

123-128: Same properties missing for AudioSource3DComponent.

Similar to AudioSource2DComponent, the 3D variant should also expose Volume and Looping properties to match the available internal calls.

 public class AudioSource3DComponent : Component
 {
     public void Play() => InternalCalls.AudioSource3DComponent_Play(Entity.ID);

     public void Stop() => InternalCalls.AudioSource3DComponent_Stop(Entity.ID);
+
+    public float Volume
+    {
+        get => InternalCalls.AudioSource3DComponent_GetVolume(Entity.ID);
+        set => InternalCalls.AudioSource3DComponent_SetVolume(Entity.ID, value);
+    }
+
+    public bool Looping
+    {
+        get => InternalCalls.AudioSource3DComponent_IsLooping(Entity.ID);
+        set => InternalCalls.AudioSource3DComponent_SetLooping(Entity.ID, value);
+    }
 }
KerberosEditor/src/Editor/HierarchyPanel.cpp (2)

1522-1580: AudioSource3DComponent UI is nearly identical to 2D - consider extracting common logic.

Both AudioSource2DComponent and AudioSource3DComponent UI blocks share nearly identical code. Consider extracting a helper template or function to reduce duplication.


1605-1605: Typo in variable name.

listenerCOmp should be listenerComp for consistency with naming conventions used elsewhere in the codebase.

-                auto& listenerCOmp = entity.GetComponent<AudioListenerComponent>();
+                auto& listenerComp = entity.GetComponent<AudioListenerComponent>();

-                ImGui::DragFloat("Volume", &listenerCOmp.Volume, 0.01f, 0.0f, 1.0f);
+                ImGui::DragFloat("Volume", &listenerComp.Volume, 0.01f, 0.0f, 1.0f);
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp (2)

206-254: Volume controls don't clamp values to valid range.

DecreaseVolume can result in negative volume (phase inversion in XAudio2), and IncreaseVolume has no upper bound. While XAudio2 accepts these values, they're likely unintended.

 		float currentVolume = 0;
 		audio->second->GetVolume(&currentVolume);

-		if (const HRESULT res = audio->second->SetVolume(currentVolume + delta); FAILED(res)) 
+		const float newVolume = std::clamp(currentVolume + delta, 0.0f, 2.0f);
+		if (const HRESULT res = audio->second->SetVolume(newVolume); FAILED(res))

Apply similar clamping in DecreaseVolume and SetVolume.


361-372: Large chunkSize in data chunk could cause allocation issues.

Line 363 resizes the buffer to chunkSize without validating the value. A malformed WAV file with a huge chunk size could cause memory exhaustion or crash.

Consider adding a reasonable size limit:

 			else if (strncmp(chunkId, "data", 4) == 0) {
 				// Read audio data
+				constexpr DWORD maxAudioSize = 100 * 1024 * 1024; // 100 MB limit
+				if (chunkSize > maxAudioSize) {
+					KBR_CORE_ERROR("WAV file data chunk too large: {0}", filepath.string());
+					return;
+				}
 				soundData.buffer.resize(chunkSize);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c539af and 7aab28f.

⛔ Files ignored due to path filters (3)
  • KerberosEditor/Resources/Scripts/KerberosScriptCoreLib.dll is excluded by !**/*.dll
  • KerberosEditor/assets/models/donut/donut_csanad.fbx is excluded by !**/*.fbx
  • KerberosEditor/assets/sounds/Technoshock.wav is excluded by !**/*.wav
📒 Files selected for processing (40)
  • Kerberos.sln.DotSettings.user (2 hunks)
  • Kerberos/src/Kerberos/Application.cpp (1 hunks)
  • Kerberos/src/Kerberos/Application.h (4 hunks)
  • Kerberos/src/Kerberos/Assets/Asset.h (3 hunks)
  • Kerberos/src/Kerberos/Assets/EditorAssetManager.cpp (2 hunks)
  • Kerberos/src/Kerberos/Assets/Importers/AssetImporter.cpp (2 hunks)
  • Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp (1 hunks)
  • Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h (1 hunks)
  • Kerberos/src/Kerberos/Audio/AudioManager.cpp (1 hunks)
  • Kerberos/src/Kerberos/Audio/AudioManager.h (1 hunks)
  • Kerberos/src/Kerberos/Audio/Sound.cpp (1 hunks)
  • Kerberos/src/Kerberos/Audio/Sound.h (1 hunks)
  • Kerberos/src/Kerberos/Log.cpp (1 hunks)
  • Kerberos/src/Kerberos/Renderer/GraphicsContext.h (1 hunks)
  • Kerberos/src/Kerberos/Scene/Components/AudioComponents.h (1 hunks)
  • Kerberos/src/Kerberos/Scene/Scene.cpp (6 hunks)
  • Kerberos/src/Kerberos/Scene/SceneSerializer.cpp (3 hunks)
  • Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp (4 hunks)
  • Kerberos/src/Kerberos/Utils/PlatformUtils.h (3 hunks)
  • Kerberos/src/Platform/OpenGL/OpenGLContext.cpp (2 hunks)
  • Kerberos/src/Platform/OpenGL/OpenGLContext.h (1 hunks)
  • Kerberos/src/Platform/OpenGL/OpenGLRendererAPI.cpp (1 hunks)
  • Kerberos/src/Platform/OpenGL/OpenGLShader.cpp (7 hunks)
  • Kerberos/src/Platform/Vulkan/VulkanContext.cpp (1 hunks)
  • Kerberos/src/Platform/Vulkan/VulkanContext.h (1 hunks)
  • Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp (1 hunks)
  • Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h (1 hunks)
  • Kerberos/src/Platform/Windows/WindowsPlatformUtils.cpp (1 hunks)
  • KerberosEditor/assets/AssetRegistry.kbrar (1 hunks)
  • KerberosEditor/assets/scenes/Example.kerberos (3 hunks)
  • KerberosEditor/imgui.ini (2 hunks)
  • KerberosEditor/src/Editor/AssetConstants.h (1 hunks)
  • KerberosEditor/src/Editor/AssetsPanel.cpp (6 hunks)
  • KerberosEditor/src/Editor/AssetsPanel.h (1 hunks)
  • KerberosEditor/src/Editor/HierarchyPanel.cpp (8 hunks)
  • KerberosEditor/src/EditorLayer.cpp (3 hunks)
  • KerberosScriptCoreLib/Source/InternalCalls.cs (1 hunks)
  • KerberosScriptCoreLib/Source/Kerberos/Player.cs (3 hunks)
  • KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (1 hunks)
  • premake5.lua (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (21)
Kerberos/src/Kerberos/Renderer/GraphicsContext.h (2)
Kerberos/src/Platform/OpenGL/OpenGLContext.h (1)
  • Kerberos (7-24)
Kerberos/src/Platform/OpenGL/OpenGLContext.cpp (4)
  • Init (15-48)
  • Init (15-15)
  • SwapBuffers (50-55)
  • SwapBuffers (50-50)
KerberosEditor/src/Editor/AssetsPanel.h (1)
KerberosEditor/src/Editor/AssetsPanel.cpp (1)
  • AssetsPanel (17-27)
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h (3)
Kerberos/src/Kerberos/Audio/AudioManager.h (1)
  • Kerberos (9-39)
Kerberos/src/Kerberos/Audio/Sound.h (2)
  • Kerberos (6-43)
  • Sound (8-42)
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp (4)
  • ImportSound (9-12)
  • ImportSound (9-9)
  • ImportSound (14-17)
  • ImportSound (14-14)
Kerberos/src/Kerberos/Application.h (1)
Kerberos/src/Kerberos/Application.cpp (2)
  • Application (15-50)
  • Application (52-56)
KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (2)
KerberosScriptCoreLib/Source/InternalCalls.cs (1)
  • InternalCalls (8-124)
Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp (8)
  • AudioSource2DComponent_Play (252-262)
  • AudioSource2DComponent_Play (252-252)
  • AudioSource2DComponent_Stop (264-274)
  • AudioSource2DComponent_Stop (264-264)
  • AudioSource3DComponent_Play (313-323)
  • AudioSource3DComponent_Play (313-313)
  • AudioSource3DComponent_Stop (325-335)
  • AudioSource3DComponent_Stop (325-325)
Kerberos/src/Kerberos/Utils/PlatformUtils.h (1)
Kerberos/src/Platform/Windows/WindowsPlatformUtils.cpp (8)
  • OpenFile (13-34)
  • OpenFile (13-13)
  • OpenFile (59-85)
  • OpenFile (59-59)
  • Delete (87-101)
  • Delete (87-87)
  • RevealInFileExplorer (103-130)
  • RevealInFileExplorer (103-103)
Kerberos/src/Kerberos/Assets/Importers/AssetImporter.cpp (2)
Kerberos/src/Kerberos/Audio/Sound.h (1)
  • Sound (8-42)
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp (4)
  • ImportSound (9-12)
  • ImportSound (9-9)
  • ImportSound (14-17)
  • ImportSound (14-14)
Kerberos/src/Platform/Vulkan/VulkanContext.h (1)
Kerberos/src/Platform/Vulkan/VulkanContext.cpp (2)
  • GetBufferDeviceAddress (1104-1111)
  • GetBufferDeviceAddress (1104-1104)
Kerberos/src/Kerberos/Application.cpp (2)
Kerberos/src/Kerberos/Audio/AudioManager.cpp (2)
  • Create (11-19)
  • Create (11-11)
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp (2)
  • Init (13-52)
  • Init (13-13)
KerberosScriptCoreLib/Source/Kerberos/Player.cs (3)
KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (5)
  • AudioSource2DComponent (116-121)
  • Play (118-118)
  • Play (125-125)
  • Stop (120-120)
  • Stop (127-127)
KerberosScriptCoreLib/Source/Kerberos/Scene/Entity.cs (1)
  • HasComponent (33-36)
KerberosScriptCoreLib/Source/Kerberos/Core/Input.cs (2)
  • Input (3-9)
  • IsKeyDown (5-8)
Kerberos/src/Kerberos/Scene/Components/AudioComponents.h (3)
Kerberos/src/Kerberos/Audio/Sound.h (2)
  • Kerberos (6-43)
  • Sound (8-42)
Kerberos/src/Kerberos/Assets/Asset.h (1)
  • Kerberos (8-79)
KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (1)
  • AudioSource3DComponent (123-128)
Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp (1)
Kerberos/src/Kerberos/Application.h (1)
  • Get (61-61)
Kerberos/src/Kerberos/Audio/AudioManager.h (4)
Kerberos/src/Kerberos/Audio/Sound.h (3)
  • Kerberos (6-43)
  • Sound (8-42)
  • Play (22-32)
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h (1)
  • Kerberos (11-72)
Kerberos/src/Kerberos/Audio/Sound.cpp (14)
  • Play (8-11)
  • Play (8-8)
  • Stop (13-16)
  • Stop (13-13)
  • IncreaseVolume (18-21)
  • IncreaseVolume (18-18)
  • DecreaseVolume (23-26)
  • DecreaseVolume (23-23)
  • SetVolume (28-31)
  • SetVolume (28-28)
  • ResetVolume (33-36)
  • ResetVolume (33-33)
  • Mute (38-41)
  • Mute (38-38)
Kerberos/src/Kerberos/Audio/AudioManager.cpp (2)
  • Create (11-19)
  • Create (11-11)
KerberosEditor/src/Editor/AssetsPanel.cpp (2)
Kerberos/src/Platform/Windows/WindowsPlatformUtils.cpp (2)
  • Delete (87-101)
  • Delete (87-87)
Kerberos/src/Kerberos/Audio/Sound.h (1)
  • Sound (8-42)
Kerberos/src/Platform/OpenGL/OpenGLContext.h (1)
Kerberos/src/Platform/OpenGL/OpenGLContext.cpp (2)
  • QueryComputeInfo (57-91)
  • QueryComputeInfo (57-57)
Kerberos/src/Kerberos/Assets/EditorAssetManager.cpp (2)
Kerberos/src/Kerberos/Audio/Sound.h (1)
  • Sound (8-42)
Kerberos/src/Kerberos/Renderer/TextureCube.h (1)
  • TextureCube (20-28)
Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h (4)
Kerberos/src/Kerberos/Audio/AudioManager.h (2)
  • Kerberos (9-39)
  • AudioManager (11-38)
Kerberos/src/Kerberos/Audio/Sound.h (3)
  • Kerberos (6-43)
  • Sound (8-42)
  • Play (22-32)
Kerberos/src/Kerberos/Assets/Asset.h (1)
  • Kerberos (8-79)
Kerberos/src/Kerberos/Audio/Sound.cpp (14)
  • Play (8-11)
  • Play (8-8)
  • Stop (13-16)
  • Stop (13-13)
  • IncreaseVolume (18-21)
  • IncreaseVolume (18-18)
  • DecreaseVolume (23-26)
  • DecreaseVolume (23-23)
  • SetVolume (28-31)
  • SetVolume (28-28)
  • ResetVolume (33-36)
  • ResetVolume (33-33)
  • Mute (38-41)
  • Mute (38-38)
KerberosScriptCoreLib/Source/InternalCalls.cs (1)
Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp (24)
  • AudioSource2DComponent_Play (252-262)
  • AudioSource2DComponent_Play (252-252)
  • AudioSource2DComponent_Stop (264-274)
  • AudioSource2DComponent_Stop (264-264)
  • AudioSource2DComponent_SetVolume (285-292)
  • AudioSource2DComponent_SetVolume (285-285)
  • AudioSource2DComponent_GetVolume (276-283)
  • AudioSource2DComponent_GetVolume (276-276)
  • AudioSource2DComponent_SetLooping (294-301)
  • AudioSource2DComponent_SetLooping (294-294)
  • AudioSource2DComponent_IsLooping (303-310)
  • AudioSource2DComponent_IsLooping (303-303)
  • AudioSource3DComponent_Play (313-323)
  • AudioSource3DComponent_Play (313-313)
  • AudioSource3DComponent_Stop (325-335)
  • AudioSource3DComponent_Stop (325-325)
  • AudioSource3DComponent_SetVolume (346-354)
  • AudioSource3DComponent_SetVolume (346-346)
  • AudioSource3DComponent_GetVolume (337-344)
  • AudioSource3DComponent_GetVolume (337-337)
  • AudioSource3DComponent_SetLooping (356-363)
  • AudioSource3DComponent_SetLooping (356-356)
  • AudioSource3DComponent_IsLooping (365-372)
  • AudioSource3DComponent_IsLooping (365-365)
Kerberos/src/Kerberos/Scene/SceneSerializer.cpp (2)
Kerberos/src/Kerberos/Core/UUID.h (1)
  • Invalid (33-36)
Kerberos/src/Kerberos/Assets/EditorAssetManager.cpp (2)
  • GetAsset (44-72)
  • GetAsset (44-44)
Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp (2)
Kerberos/src/Kerberos/Scripting/ScriptEngine.cpp (2)
  • GetSceneContext (230-233)
  • GetSceneContext (230-230)
Kerberos/src/Kerberos/Physics/PhysicsSystem.cpp (3)
  • entity (168-168)
  • entity (189-189)
  • entity (224-224)
Kerberos/src/Kerberos/Assets/Asset.h (1)
Kerberos/src/Kerberos/Audio/Sound.h (1)
  • Sound (8-42)
🪛 Clang (14.0.6)
Kerberos/src/Kerberos/Renderer/GraphicsContext.h

[error] 3-3: 'glm/glm.hpp' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Audio/AudioManager.cpp

[error] 1-1: 'kbrpch.h' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h

[error] 3-3: 'Kerberos/Assets/Asset.h' file not found

(clang-diagnostic-error)

KerberosEditor/src/Editor/AssetConstants.h

[error] 3-3: unknown type name 'namespace'

(clang-diagnostic-error)


[error] 3-3: expected ';' after top level declarator

(clang-diagnostic-error)

Kerberos/src/Kerberos/Audio/Sound.cpp

[error] 1-1: 'kbrpch.h' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Scene/Components/AudioComponents.h

[error] 3-3: 'Kerberos/Audio/Sound.h' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp

[error] 1-1: 'kbrpch.h' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Audio/AudioManager.h

[error] 3-3: 'Kerberos/Core.h' file not found

(clang-diagnostic-error)

Kerberos/src/Kerberos/Audio/Sound.h

[error] 3-3: 'Kerberos/Core.h' file not found

(clang-diagnostic-error)

Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp

[error] 1-1: 'kbrpch.h' file not found

(clang-diagnostic-error)

Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h

[error] 3-3: 'Kerberos/Audio/AudioManager.h' file not found

(clang-diagnostic-error)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build on Windows (Debug)
  • GitHub Check: Build on Windows (Release)
🔇 Additional comments (45)
KerberosEditor/imgui.ini (1)

12-12: UI layout adjustments are expected for audio feature integration.

The imgui.ini file is auto-generated by ImGui to store window layout configuration, including positions, sizes, and docking state. The changes reflect reasonable adjustments to the editor UI layout to accommodate the new audio asset management and component configuration panels introduced in this PR. The layout modifications appear consistent and appropriately scaled.

Also applies to: 17-18, 24-24, 29-30, 35-35, 42-42, 48-48, 57-57, 64-65

Kerberos.sln.DotSettings.user (2)

8-8: ADPCM dictionary entry is appropriate

ADPCM is a valid audio-related acronym; adding it to the user dictionary is reasonable and non-impactful.


22-22: shaderc dictionary entry makes sense

shaderc is a common library/tool name; adding it to the dictionary is fine and keeps inspections clean.

Kerberos/src/Platform/OpenGL/OpenGLShader.cpp (4)

41-44: LGTM!

Good addition of the default case to handle unexpected shader types with an assertion. This is consistent with the error handling pattern used elsewhere in the file.


54-57: LGTM!

Consistent handling of unsupported shader types with the previous function.


458-473: LGTM!

Good use of C++17 init-statement to scope the ifstream to its usage block.


583-598: LGTM!

Consistent use of C++17 init-statement pattern.

Kerberos/src/Kerberos/Renderer/GraphicsContext.h (1)

3-3: Static analysis warning can be ignored.

The 'glm/glm.hpp' file not found warning from Clang is a false positive. GLM is a standard graphics math library and the include path is configured correctly at build time.

Kerberos/src/Platform/OpenGL/OpenGLContext.cpp (1)

31-47: LGTM with dependency on fixing MaxWorkGroupInvocations.

The initialization flow correctly calls QueryComputeInfo() and logs compute shader limits for diagnostics. However, the logging of MaxWorkGroupInvocations at lines 44-47 will need to be updated to log a single value rather than a vec3 once the critical issue in GraphicsContext.h is addressed.

Kerberos/src/Kerberos/Log.cpp (1)

17-17: The sink configuration is already consistent between core and client loggers.

Both the core logger (line 17) and client logger (line 25) use stdout_color_sink_mt(), making them uniform. The original concern about switching from stderr to stdout appears to be based on a misunderstanding of the code state. Both loggers output to stdout, which is the intended design in this codebase.

If this logging configuration is unrelated to the audio integration described in the PR title, that concern may still warrant clarification—consider moving unrelated changes to a separate PR.

Likely an incorrect or invalid review comment.

KerberosEditor/assets/scenes/Example.kerberos (2)

25-30: Verify the script class naming convention.

The ClassName value Kerberos.Source.Kerberos.Camera appears to have a redundant or incorrect namespace pattern. Typically, C# script class names follow a simpler convention like Kerberos.Camera or MyProject.Camera. The Source.Kerberos segment seems unusual.

Please verify this is the intended namespace structure for your C# scripts, or if this should be simplified to something like Kerberos.Camera.


159-164: Same naming convention concern for Player script.

Same observation as above - Kerberos.Source.Kerberos.Player has an unusual namespace pattern.

Kerberos/src/Kerberos/Assets/Importers/AssetImporter.cpp (1)

37-38: LGTM!

The Sound asset import case follows the established pattern used by other asset types like Texture2D and TextureCube, properly delegating to the specialized SoundImporter.

KerberosEditor/assets/AssetRegistry.kbrar (1)

47-49: LGTM!

The Sound asset entry follows the established registry format and is properly positioned among other assets.

KerberosEditor/src/Editor/AssetsPanel.h (1)

19-19: LGTM!

Adding explicit to the single-argument constructor prevents unintended implicit conversions, which is a good practice.

Kerberos/src/Kerberos/Application.h (1)

46-49: LGTM!

Explicitly deleting copy/move constructors and assignment operators for the Application singleton is the correct approach to prevent accidental copies or moves.

Kerberos/src/Kerberos/Audio/Sound.cpp (1)

8-41: m_SoundID is properly initialized via UUID's default constructor.

The m_SoundID member, while not explicitly listed in the Sound constructor's member initializer list, is automatically initialized when each Sound object is constructed. The UUID class provides a default constructor that generates a random 64-bit value, and C++ implicitly invokes this constructor for m_SoundID during Sound object construction. Each Sound instance receives a unique random UUID, which is then used to track the sound in the AudioManager's internal mappings.

Kerberos/src/Kerberos/Assets/EditorAssetManager.cpp (2)

22-22: Limited audio format support - verify roadmap.

Currently only WAV format is supported. Ensure the TODO for additional audio formats (e.g., MP3, OGG, FLAC) is tracked properly for future implementation.


222-226: LGTM - transitional implementation.

The explicit type check for Sound is appropriate as a transitional approach. The TODO correctly identifies this as temporary until comprehensive asset type support is implemented.

KerberosScriptCoreLib/Source/Kerberos/Player.cs (1)

36-37: LGTM!

The initialization pattern is consistent with other component retrievals in this method.

Kerberos/src/Kerberos/Scene/SceneSerializer.cpp (1)

423-452: LGTM!

The serialization logic for audio components follows the established pattern used by other asset-referencing components (Mesh, Texture). The null-safety check using UUID::Invalid() for missing SoundAssets is consistent with the codebase conventions.

KerberosEditor/src/EditorLayer.cpp (1)

657-657: LGTM!

Using the ASSET_BROWSER_ITEM constant from AssetConstants.h improves maintainability and reduces the risk of typos compared to magic strings.

Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h (1)

9-14: LGTM!

The SoundImporter interface follows the established pattern used by other asset importers in the codebase. The two static overloads provide flexibility for both asset-system-driven and direct file imports.

Kerberos/src/Kerberos/Assets/Asset.h (2)

18-19: LGTM!

The Sound asset type is properly added to the AssetType enum and maintains the sequential pattern.


53-54: LGTM!

The Sound case is correctly added to AssetTypeToString.

Kerberos/src/Kerberos/Utils/PlatformUtils.h (1)

37-50: LGTM - new file operation methods.

The declarations are well-documented. Consider adding [[nodiscard]] to RevealInFileExplorer for consistency with the other methods, though it's not strictly necessary if fire-and-forget usage is acceptable.

KerberosEditor/src/Editor/AssetConstants.h (1)

1-12: LGTM - centralized asset type constants.

Good refactor to eliminate magic strings for drag-and-drop payloads. The static analysis errors are false positives from the analyzer not recognizing C++ namespace syntax.

KerberosEditor/src/Editor/AssetsPanel.cpp (1)

8-8: Good addition of centralized constants.

Using AssetConstants.h eliminates magic strings and improves maintainability.

KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs (1)

130-132: AudioListenerComponent is empty.

This component has no exposed functionality. If this is intentional (just a marker component), that's fine. Otherwise, consider adding a Volume property similar to the native AudioListenerComponent.Volume field shown in the editor UI.

Kerberos/src/Kerberos/Scene/Scene.cpp (3)

302-313: Audio component duplication looks correct.

The duplication pattern for AudioSource2DComponent, AudioSource3DComponent, and AudioListenerComponent follows the established convention used by other components in this function.


539-550: Audio component copying in Scene::Copy is consistent.

The copying pattern matches the approach used for other components in this function.


987-1001: Empty OnComponentAdded specializations are appropriate.

These empty stubs follow the pattern established by other simple components (e.g., TagComponent, TransformComponent). If audio-specific initialization is needed later, these hooks are already in place.

KerberosEditor/src/Editor/HierarchyPanel.cpp (3)

225-258: Physics submenu restructuring looks good.

The reorganization into a Physics submenu improves UI organization and follows a logical grouping pattern.


273-294: Audio submenu implementation is consistent with the codebase patterns.

The new Audio submenu properly adds the three audio component types and follows the same pattern used for other menu items.


1463-1521: AudioSource2DComponent UI implementation looks correct.

The UI follows the established pattern with proper popup handling, drag-and-drop for sound assets, and controls for Loop and Volume.

Kerberos/src/Kerberos/Scene/Components/AudioComponents.h (3)

23-37: AudioSource2DComponent mirrors 3D variant appropriately.

The 2D component has the same structure as 3D, which makes sense for consistent API. The distinction between 2D and 3D audio will be in the audio backend behavior.


39-45: AudioListenerComponent is minimal but functional.

For a listener component, having just a volume control is reasonable. In the future, you may want to add properties like doppler factor, distance model, etc., but this is sufficient for initial implementation.


7-21: AudioSource3DComponent structure is well-defined.

The component includes all necessary fields for audio playback. The IsPlaying field is correctly handled as runtime-only state—it is intentionally excluded from serialization and defaults to false upon deserialization, preventing stale state after scene load.

Kerberos/src/Kerberos/Audio/Sound.h (2)

32-32: The base Asset::GetType() is declared as non-const (virtual AssetType GetType() = 0), and all derived classes consistently implement it without const qualification (Texture, TextureCube, Material, Mesh, Scene). Adding const to Sound's override would break the method signature contract with the base class and cause compilation errors. The current implementation is correct.

Likely an incorrect or invalid review comment.


36-41: m_SoundID initialization depends on UUID's default constructor.

The concern about uninitialized m_SoundID is valid only if UUID's default constructor does not provide reliable initialization. If UUID has a proper default constructor (as is typical in standard UUID libraries like Boost), this is not an issue.

Kerberos/src/Kerberos/Audio/AudioManager.h (1)

11-38: Clean abstract interface design.

The interface provides a solid foundation for platform-specific audio implementations. The static factory pattern via Create() aligns with the platform abstraction approach visible in AudioManager.cpp.

One consideration: the defaulted copy/move constructors on lines 17-20 are somewhat unusual for an abstract base class (since derived classes like XAudio2AudioManager delete copy operations anyway). This is harmless but could be simplified by just declaring virtual destructor.

Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp (1)

408-420: Audio scripting bindings properly registered.

The internal calls and component type registrations are correctly added and align with the C# declarations.

Also applies to: 463-466

Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h (2)

21-31: AudioData struct design looks good.

The struct properly initializes wfx with memset and uses sensible defaults. Using std::vector<uint8_t> for the buffer is appropriate for managing audio data lifetime.


68-70: No hash specialization issue exists.

std::filesystem::path has a standard std::hash specialization available in C++17 and later. The project uses stdcpplatest (latest C++ standard), so std::unordered_map<std::filesystem::path, ...> compiles and works correctly without any custom hash implementation. The implementation file confirms this pattern is already in use and functioning in production code.

Likely an incorrect or invalid review comment.

KerberosScriptCoreLib/Source/InternalCalls.cs (1)

84-122: Audio component internal call declarations are complete and correct.

The extern declarations match the native C++ implementations registered in ScriptInterface.cpp. Parameter types and naming conventions follow the established patterns in this file.

@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #29

coderabbitai bot added a commit that referenced this pull request Dec 7, 2025
Docstrings generation was requested by @EasySouls.

* #28 (comment)

The following files were modified:

* `Kerberos/src/Kerberos/Application.cpp`
* `Kerberos/src/Kerberos/Application.h`
* `Kerberos/src/Kerberos/Assets/Asset.h`
* `Kerberos/src/Kerberos/Assets/EditorAssetManager.cpp`
* `Kerberos/src/Kerberos/Assets/Importers/AssetImporter.cpp`
* `Kerberos/src/Kerberos/Assets/Importers/SoundImporter.cpp`
* `Kerberos/src/Kerberos/Assets/Importers/SoundImporter.h`
* `Kerberos/src/Kerberos/Audio/AudioManager.cpp`
* `Kerberos/src/Kerberos/Audio/AudioManager.h`
* `Kerberos/src/Kerberos/Audio/Sound.cpp`
* `Kerberos/src/Kerberos/Audio/Sound.h`
* `Kerberos/src/Kerberos/Log.cpp`
* `Kerberos/src/Kerberos/Renderer/GraphicsContext.h`
* `Kerberos/src/Kerberos/Scene/Scene.cpp`
* `Kerberos/src/Kerberos/Scene/SceneSerializer.cpp`
* `Kerberos/src/Kerberos/Scripting/ScriptInterface.cpp`
* `Kerberos/src/Kerberos/Utils/PlatformUtils.h`
* `Kerberos/src/Platform/OpenGL/OpenGLContext.cpp`
* `Kerberos/src/Platform/OpenGL/OpenGLContext.h`
* `Kerberos/src/Platform/OpenGL/OpenGLRendererAPI.cpp`
* `Kerberos/src/Platform/OpenGL/OpenGLShader.cpp`
* `Kerberos/src/Platform/Vulkan/VulkanContext.cpp`
* `Kerberos/src/Platform/Vulkan/VulkanContext.h`
* `Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.cpp`
* `Kerberos/src/Platform/Windows/Audio/XAudio2AudioManager.h`
* `Kerberos/src/Platform/Windows/WindowsPlatformUtils.cpp`
* `KerberosEditor/src/Editor/AssetConstants.h`
* `KerberosEditor/src/Editor/AssetsPanel.cpp`
* `KerberosEditor/src/Editor/AssetsPanel.h`
* `KerberosEditor/src/Editor/HierarchyPanel.cpp`
* `KerberosEditor/src/EditorLayer.cpp`
* `KerberosScriptCoreLib/Source/InternalCalls.cs`
* `KerberosScriptCoreLib/Source/Kerberos/Player.cs`
* `KerberosScriptCoreLib/Source/Kerberos/Scene/Components.cs`
Added volume synchronization for `SoundAsset` in `AudioSource2DComponent`.
Enhanced `XAudio2AudioManager` to stop and clean up existing sounds
before replaying. Updated `VulkanContext` to retrieve buffer device
addresses and added a TODO for extension checks. Marked move
constructors/assignments as `noexcept` in `XAudio2AudioManager` and
added a TODO for proper move behavior with COM pointers.
@EasySouls EasySouls merged commit fb19bec into master Dec 7, 2025
4 checks passed
@EasySouls EasySouls deleted the audio branch December 7, 2025 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants