Enhance audio management and documentation
CI / build-test (push) Successful in 1m10s

Added a MasterVolume property to the AudioManager for unified control over sound effects and music volume. Updated the Play method to incorporate MasterVolume adjustments. Enhanced documentation in CLAUDE.md and architecture.md to reflect changes in audio management and overall engine architecture. Introduced a new test project for audio functionalities in the solution file.
This commit is contained in:
Leonid Pershin
2026-06-12 08:41:39 +03:00
parent 3f3c0200a8
commit ef1111bcb6
8 changed files with 358 additions and 7 deletions
+17 -1
View File
@@ -19,7 +19,23 @@ public sealed class AudioManager : IDisposable
set => _soundVolume = Math.Clamp(value, 0f, 1f);
}
/// <summary>
/// Master volume 0..1 applied on top of <see cref="SoundVolume"/> for sound effects and
/// mirrored onto <see cref="MusicPlayer.Volume"/>, so a single knob (e.g. a settings
/// slider) controls both effects and music.
/// </summary>
public float MasterVolume
{
get => _masterVolume;
set
{
_masterVolume = Math.Clamp(value, 0f, 1f);
Music.Volume = _masterVolume;
}
}
private float _soundVolume = 1f;
private float _masterVolume = 1f;
/// <summary>Plays a sound effect (fire and forget).</summary>
/// <param name="sound">The loaded sound effect.</param>
@@ -27,7 +43,7 @@ public sealed class AudioManager : IDisposable
/// <param name="pitch">Pitch offset in octaves, -1..1.</param>
/// <param name="pan">Stereo pan, -1 (left) .. 1 (right).</param>
public void Play(SoundEffect sound, float volume = 1f, float pitch = 0f, float pan = 0f) =>
sound.Play(Math.Clamp(volume, 0f, 1f) * _soundVolume, pitch, pan);
sound.Play(Math.Clamp(volume, 0f, 1f) * _soundVolume * _masterVolume, pitch, pan);
/// <inheritdoc />
public void Dispose() => Music.Dispose();